-
-
Notifications
You must be signed in to change notification settings - Fork 756
/
Copy pathroutes.test.js
34 lines (33 loc) · 1.04 KB
/
routes.test.js
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
import config from './registry';
import { getExternalRoutes } from './routes';
describe('externalRoutes', () => {
it('computes regular externalRoutes correctly', () => {
config.settings.externalRoutes = [
{
match: {
path: '/test',
},
},
];
const testRoute = getExternalRoutes().find((r) => r.path === '/test');
expect(testRoute).not.toBeUndefined();
});
it('computes shorthand externalRoutes correctly', () => {
config.settings.externalRoutes = [{ match: '/test' }];
const testRoute = getExternalRoutes().find((r) => r.path === '/test');
expect(testRoute).not.toBeUndefined();
});
it('ignores invalid routes', () => {
config.settings.externalRoutes = [
'/test',
{ '/test': true },
['/test'],
{ match: ['/test'] },
{ match: 123 },
];
const externalRoutes = getExternalRoutes();
const testRoute = externalRoutes.find((r) => r.path === '/test');
expect(testRoute).toBeUndefined();
expect(externalRoutes.length).toEqual(0);
});
});