library regexp tests added

This commit is contained in:
svetlagasheva 2019-12-17 11:03:00 +02:00
parent 0aa6b06df2
commit 3354f79caf

View file

@ -112,7 +112,52 @@ describe('routesRegexp', () => {
});
});
//TODO library route regexp
describe('library route regexp', () => {
it('match /library', async () => {
expect(Array.from('/library'.match(routesRegexp.library.regexp)))
.toEqual(['/library', undefined, undefined]);
});
it('match /library//', async () => {
expect(Array.from('/library//'.match(routesRegexp.library.regexp)))
.toEqual(['/library//', '', '']);
});
it('match /library/1/', async () => {
expect(Array.from('/library/1/'.match(routesRegexp.library.regexp)))
.toEqual(['/library/1/', '1', '']);
});
it('match /library//2', async () => {
expect(Array.from('/library//2'.match(routesRegexp.library.regexp)))
.toEqual(['/library//2', '', '2']);
});
it('match /library/1/2', async () => {
expect(Array.from('/library/1/2'.match(routesRegexp.library.regexp)))
.toEqual(['/library/1/2', '1', '2']);
});
it('not match /library/', async () => {
expect('/library/'.match(routesRegexp.library.regexp))
.toBe(null);
});
it('not match /library///', async () => {
expect('/library///'.match(routesRegexp.library.regexp))
.toBe(null);
});
it('not match /library/1', async () => {
expect('/library/1'.match(routesRegexp.library.regexp))
.toBe(null);
});
it('not match /library/1/2/', async () => {
expect('/library/1/2/'.match(routesRegexp.library.regexp))
.toBe(null);
});
});
describe('search route regexp', () => {
it('match /search', async () => {