From 3354f79cafc6834608b81fc4f2729322d27002d1 Mon Sep 17 00:00:00 2001 From: svetlagasheva Date: Tue, 17 Dec 2019 11:03:00 +0200 Subject: [PATCH] library regexp tests added --- tests/routesRegexp.spec.js | 47 +++++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/tests/routesRegexp.spec.js b/tests/routesRegexp.spec.js index 2d688f82b..4f6387f81 100644 --- a/tests/routesRegexp.spec.js +++ b/tests/routesRegexp.spec.js @@ -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 () => {