-
Notifications
You must be signed in to change notification settings - Fork 574
Expand file tree
/
Copy pathroutePaths.test.ts
More file actions
41 lines (38 loc) · 1.57 KB
/
Copy pathroutePaths.test.ts
File metadata and controls
41 lines (38 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import { isAllowedWhileBlocked, isOrganisationUsage } from 'web/routePaths'
// App renders <Blocked /> wherever this is false, so a wrong answer either
// locks a blocked organisation out, or lets it back in.
describe('isAllowedWhileBlocked', () => {
it.each`
pathname | allowed
${'/organisation/7528/usage'} | ${true}
${'/organisations'} | ${true}
${'/organisation/7528/projects'} | ${false}
${'/organisation/7528/settings'} | ${false}
${'/organisation-settings'} | ${false}
${'/project/1/environment/abc/features'} | ${false}
${'/account'} | ${false}
`(
'$pathname is reachable while blocked: $allowed',
({ allowed, pathname }) => {
expect(isAllowedWhileBlocked(pathname)).toBe(allowed)
},
)
// Allowed by pattern, not by prefix.
it('does not open anything nested under the usage page', () => {
expect(isAllowedWhileBlocked('/organisation/7528/usage/breakdown')).toBe(
false,
)
})
})
// App hides its app-wide quota banner here, where the page has its own.
describe('isOrganisationUsage', () => {
it.each`
pathname | isUsage
${'/organisation/7528/usage'} | ${true}
${'/organisation/7528/projects'} | ${false}
${'/organisation/7528/usage/charts'} | ${false}
${'/organisations'} | ${false}
`('$pathname is the usage page: $isUsage', ({ isUsage, pathname }) => {
expect(isOrganisationUsage(pathname)).toBe(isUsage)
})
})