Skip to content

Commit

Permalink
[dashboard]: Add test for 'inResource'
Browse files Browse the repository at this point in the history
  • Loading branch information
CuriousCorrelation authored and roboquat committed Jul 6, 2022
1 parent fdc44f4 commit 3217a65
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions components/dashboard/src/utils.test.ts
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);

});

0 comments on commit 3217a65

Please sign in to comment.