-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[dashboard]: Add test for 'inResource'
- Loading branch information
1 parent
fdc44f4
commit 3217a65
Showing
1 changed file
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/** | ||
* Copyright (c) 2022 Gitpod GmbH. All rights reserved. | ||
* Licensed under the GNU Affero General Public License (AGPL). | ||
* See License-AGPL.txt in the project root for license information. | ||
*/ | ||
|
||
import { inResource } from "./utils"; | ||
|
||
test("inResource", () => { | ||
|
||
// Given root path is a part of resources specified | ||
expect(inResource("/app", ["new", "app", "teams"])).toBe(true); | ||
|
||
// Given path is a part of resources specified | ||
expect(inResource("/app/testing", ["new", "app", "teams"])).toBe(true); | ||
|
||
// Empty resources | ||
expect(inResource("/just/a/path", [])).toBe(false); | ||
|
||
// Both resources starting with '/' | ||
expect(inResource("/app", ["/app"])).toBe(true); | ||
|
||
// Both resources ending with '/' | ||
expect(inResource("app/", ["app/"])).toBe(true); | ||
|
||
// Both resources containing path with subdirectories | ||
expect(inResource("/admin/teams/someTeam/somePerson", ["/admin/teams"])).toBe(true); | ||
|
||
}); |