From afc2355580e85866df0f299f0d5c42344a55c37a Mon Sep 17 00:00:00 2001 From: svetlagasheva Date: Fri, 13 Dec 2019 15:18:05 +0200 Subject: [PATCH] routes regexp tests added --- tests/routesRegexp.spec.js | 457 ++++++++++++++++++++++++++++++++++++- 1 file changed, 448 insertions(+), 9 deletions(-) diff --git a/tests/routesRegexp.spec.js b/tests/routesRegexp.spec.js index ebf236a30..2d688f82b 100644 --- a/tests/routesRegexp.spec.js +++ b/tests/routesRegexp.spec.js @@ -7,13 +7,8 @@ describe('routesRegexp', () => { .toEqual(['/intro']); }); - it('match /intro/', async () => { - expect(Array.from('/intro/'.match(routesRegexp.intro.regexp))) - .toEqual(['/intro/']); - }); - - it('not match /intro/$', async () => { - expect('/intro/$'.match(routesRegexp.intro.regexp)) + it('not match /intro/', async () => { + expect('/intro/'.match(routesRegexp.intro.regexp)) .toBe(null); }); }); @@ -24,8 +19,452 @@ describe('routesRegexp', () => { .toEqual(['/']); }); - it('not match /$', async () => { - expect('/$'.match(routesRegexp.board.regexp)) + it('not match /1', async () => { + expect('/1'.match(routesRegexp.board.regexp)) + .toBe(null); + }); + }); + + describe('discover route regexp', () => { + it('match /discover', async () => { + expect(Array.from('/discover'.match(routesRegexp.discover.regexp))) + .toEqual(['/discover', undefined, undefined, undefined]); + }); + + it('match /discover///', async () => { + expect(Array.from('/discover///'.match(routesRegexp.discover.regexp))) + .toEqual(['/discover///', '', '', '']); + }); + + it('match /discover/1//', async () => { + expect(Array.from('/discover/1//'.match(routesRegexp.discover.regexp))) + .toEqual(['/discover/1//', '1', '', '']); + }); + + it('match /discover//2/', async () => { + expect(Array.from('/discover//2/'.match(routesRegexp.discover.regexp))) + .toEqual(['/discover//2/', '', '2', '']); + }); + + it('match /discover///3', async () => { + expect(Array.from('/discover///3'.match(routesRegexp.discover.regexp))) + .toEqual(['/discover///3', '', '', '3']); + }); + + it('match /discover/1/2/', async () => { + expect(Array.from('/discover/1/2/'.match(routesRegexp.discover.regexp))) + .toEqual(['/discover/1/2/', '1', '2', '']); + }); + + it('match /discover/1//3', async () => { + expect(Array.from('/discover/1//3'.match(routesRegexp.discover.regexp))) + .toEqual(['/discover/1//3', '1', '', '3']); + }); + + it('match /discover//2/3', async () => { + expect(Array.from('/discover//2/3'.match(routesRegexp.discover.regexp))) + .toEqual(['/discover//2/3', '', '2', '3']); + }); + + it('match /discover/1/2/3', async () => { + expect(Array.from('/discover/1/2/3'.match(routesRegexp.discover.regexp))) + .toEqual(['/discover/1/2/3', '1', '2', '3']); + }); + + it('not match /discover/', async () => { + expect('/discover/'.match(routesRegexp.discover.regexp)) + .toBe(null); + }); + + it('not match /discover//', async () => { + expect('/discover//'.match(routesRegexp.discover.regexp)) + .toBe(null); + }); + + it('not match /discover////', async () => { + expect('/discover////'.match(routesRegexp.discover.regexp)) + .toBe(null); + }); + + it('not match /discover/1', async () => { + expect('/discover/1'.match(routesRegexp.discover.regexp)) + .toBe(null); + }); + + it('not match /discover/1/', async () => { + expect('/discover/1/'.match(routesRegexp.discover.regexp)) + .toBe(null); + }); + + it('not match /discover//2', async () => { + expect('/discover//2'.match(routesRegexp.discover.regexp)) + .toBe(null); + }); + + it('not match /discover/1/2', async () => { + expect('/discover/1/2'.match(routesRegexp.discover.regexp)) + .toBe(null); + }); + + it('not match /discover/1/2/3/', async () => { + expect('/discover/1/2/3/'.match(routesRegexp.discover.regexp)) + .toBe(null); + }); + }); + + //TODO library route regexp + + describe('search route regexp', () => { + it('match /search', async () => { + expect(Array.from('/search'.match(routesRegexp.search.regexp))) + .toEqual(['/search']); + }); + + it('not match /search/', async () => { + expect('/search/'.match(routesRegexp.search.regexp)) + .toBe(null); + }); + }); + + describe('metadetails route regexp', () => { + it('match /metadetails//', async () => { + expect(Array.from('/metadetails//'.match(routesRegexp.metadetails.regexp))) + .toEqual(['/metadetails//', '', '', undefined]); + }); + + it('match /metadetails///', async () => { + expect(Array.from('/metadetails///'.match(routesRegexp.metadetails.regexp))) + .toEqual(['/metadetails///', '', '', '']); + }); + + it('match /metadetails/1/', async () => { + expect(Array.from('/metadetails/1/'.match(routesRegexp.metadetails.regexp))) + .toEqual(['/metadetails/1/', '1', '', undefined]); + }); + + it('match /metadetails/1//', async () => { + expect(Array.from('/metadetails/1//'.match(routesRegexp.metadetails.regexp))) + .toEqual(['/metadetails/1//', '1', '', '']); + }); + + it('match /metadetails//2/', async () => { + expect(Array.from('/metadetails//2/'.match(routesRegexp.metadetails.regexp))) + .toEqual(['/metadetails//2/', '', '2', '']); + }); + + it('match /metadetails///3', async () => { + expect(Array.from('/metadetails///3'.match(routesRegexp.metadetails.regexp))) + .toEqual(['/metadetails///3', '', '', '3']); + }); + + it('match /metadetails/1/2', async () => { + expect(Array.from('/metadetails/1/2'.match(routesRegexp.metadetails.regexp))) + .toEqual(['/metadetails/1/2', '1', '2', undefined]); + }); + + it('match /metadetails/1/2/', async () => { + expect(Array.from('/metadetails/1/2/'.match(routesRegexp.metadetails.regexp))) + .toEqual(['/metadetails/1/2/', '1', '2', '']); + }); + + it('match /metadetails/1//3', async () => { + expect(Array.from('/metadetails/1//3'.match(routesRegexp.metadetails.regexp))) + .toEqual(['/metadetails/1//3', '1', '', '3']); + }); + + it('match /metadetails//2/3', async () => { + expect(Array.from('/metadetails//2/3'.match(routesRegexp.metadetails.regexp))) + .toEqual(['/metadetails//2/3', '', '2', '3']); + }); + + it('match /metadetails/1/2/3', async () => { + expect(Array.from('/metadetails/1/2/3'.match(routesRegexp.metadetails.regexp))) + .toEqual(['/metadetails/1/2/3', '1', '2', '3']); + }); + + it('not match /metadetails', async () => { + expect('/metadetails'.match(routesRegexp.metadetails.regexp)) + .toBe(null); + }); + + it('not match /metadetails/', async () => { + expect('/metadetails/'.match(routesRegexp.metadetails.regexp)) + .toBe(null); + }); + + it('not match /metadetails////', async () => { + expect('/metadetails////'.match(routesRegexp.metadetails.regexp)) + .toBe(null); + }); + + it('not match /metadetails/1', async () => { + expect('/metadetails/1'.match(routesRegexp.metadetails.regexp)) + .toBe(null); + }); + + it('not match /metadetails/1/2/3/', async () => { + expect('/metadetails/1/2/3/'.match(routesRegexp.metadetails.regexp)) + .toBe(null); + }); + }); + + describe('addons route regexp', () => { + it('match /addons', async () => { + expect(Array.from('/addons'.match(routesRegexp.addons.regexp))) + .toEqual(['/addons', undefined, undefined, undefined]); + }); + + it('match /addons///', async () => { + expect(Array.from('/addons///'.match(routesRegexp.addons.regexp))) + .toEqual(['/addons///', '', '', '']); + }); + + it('match /addons/1//', async () => { + expect(Array.from('/addons/1//'.match(routesRegexp.addons.regexp))) + .toEqual(['/addons/1//', '1', '', '']); + }); + + it('match /addons//2/', async () => { + expect(Array.from('/addons//2/'.match(routesRegexp.addons.regexp))) + .toEqual(['/addons//2/', '', '2', '']); + }); + + it('match /addons///3', async () => { + expect(Array.from('/addons///3'.match(routesRegexp.addons.regexp))) + .toEqual(['/addons///3', '', '', '3']); + }); + + it('match /addons/1/2/', async () => { + expect(Array.from('/addons/1/2/'.match(routesRegexp.addons.regexp))) + .toEqual(['/addons/1/2/', '1', '2', '']); + }); + + it('match /addons/1//3', async () => { + expect(Array.from('/addons/1//3'.match(routesRegexp.addons.regexp))) + .toEqual(['/addons/1//3', '1', '', '3']); + }); + + it('match /addons//2/3', async () => { + expect(Array.from('/addons//2/3'.match(routesRegexp.addons.regexp))) + .toEqual(['/addons//2/3', '', '2', '3']); + }); + + it('match /addons/1/2/3', async () => { + expect(Array.from('/addons/1/2/3'.match(routesRegexp.addons.regexp))) + .toEqual(['/addons/1/2/3', '1', '2', '3']); + }); + + it('not match /addons/', async () => { + expect('/addons/'.match(routesRegexp.addons.regexp)) + .toBe(null); + }); + + it('not match /addons//', async () => { + expect('/addons//'.match(routesRegexp.addons.regexp)) + .toBe(null); + }); + + it('not match /addons////', async () => { + expect('/addons////'.match(routesRegexp.addons.regexp)) + .toBe(null); + }); + + it('not match /addons/1', async () => { + expect('/addons/1'.match(routesRegexp.addons.regexp)) + .toBe(null); + }); + + it('not match /addons/1/', async () => { + expect('/addons/1/'.match(routesRegexp.addons.regexp)) + .toBe(null); + }); + + it('not match /addons//2', async () => { + expect('/addons//2'.match(routesRegexp.addons.regexp)) + .toBe(null); + }); + + it('not match /addons/1/2', async () => { + expect('/addons/1/2'.match(routesRegexp.addons.regexp)) + .toBe(null); + }); + + it('not match /addons/1/2/3/', async () => { + expect('/addons/1/2/3/'.match(routesRegexp.addons.regexp)) + .toBe(null); + }); + }); + + describe('settings route regexp', () => { + it('match /settings', async () => { + expect(Array.from('/settings'.match(routesRegexp.settings.regexp))) + .toEqual(['/settings']); + }); + + it('not match /settings/', async () => { + expect('/settings/'.match(routesRegexp.settings.regexp)) + .toBe(null); + }); + }); + + describe('player route regexp', () => { + it('match /player////', async () => { + expect(Array.from('/player////'.match(routesRegexp.player.regexp))) + .toEqual(['/player////', '', '', '', '']); + }); + + it('match /player/1///', async () => { + expect(Array.from('/player/1///'.match(routesRegexp.player.regexp))) + .toEqual(['/player/1///', '1', '', '', '']); + }); + + it('match /player//2//', async () => { + expect(Array.from('/player//2//'.match(routesRegexp.player.regexp))) + .toEqual(['/player//2//', '', '2', '', '']); + }); + + it('match /player///3/', async () => { + expect(Array.from('/player///3/'.match(routesRegexp.player.regexp))) + .toEqual(['/player///3/', '', '', '3', '']); + }); + + it('match /player////4', async () => { + expect(Array.from('/player////4'.match(routesRegexp.player.regexp))) + .toEqual(['/player////4', '', '', '', '4']); + }); + + it('match /player/1/2//', async () => { + expect(Array.from('/player/1/2//'.match(routesRegexp.player.regexp))) + .toEqual(['/player/1/2//', '1', '2', '', '']); + }); + + it('match /player/1//3/', async () => { + expect(Array.from('/player/1//3/'.match(routesRegexp.player.regexp))) + .toEqual(['/player/1//3/', '1', '', '3', '']); + }); + + it('match /player/1///4', async () => { + expect(Array.from('/player/1///4'.match(routesRegexp.player.regexp))) + .toEqual(['/player/1///4', '1', '', '', '4']); + }); + + it('match /player//2/3/', async () => { + expect(Array.from('/player//2/3/'.match(routesRegexp.player.regexp))) + .toEqual(['/player//2/3/', '', '2', '3', '']); + }); + + it('match /player//2//4', async () => { + expect(Array.from('/player//2//4'.match(routesRegexp.player.regexp))) + .toEqual(['/player//2//4', '', '2', '', '4']); + }); + + it('match /player///3/4', async () => { + expect(Array.from('/player///3/4'.match(routesRegexp.player.regexp))) + .toEqual(['/player///3/4', '', '', '3', '4']); + }); + + it('match /player/1/2/3/', async () => { + expect(Array.from('/player/1/2/3/'.match(routesRegexp.player.regexp))) + .toEqual(['/player/1/2/3/', '1', '2', '3', '']); + }); + + it('match /player/1/2//4', async () => { + expect(Array.from('/player/1/2//4'.match(routesRegexp.player.regexp))) + .toEqual(['/player/1/2//4', '1', '2', '', '4']); + }); + + it('match /player/1//3/4', async () => { + expect(Array.from('/player/1//3/4'.match(routesRegexp.player.regexp))) + .toEqual(['/player/1//3/4', '1', '', '3', '4']); + }); + + it('match /player//2/3/4', async () => { + expect(Array.from('/player//2/3/4'.match(routesRegexp.player.regexp))) + .toEqual(['/player//2/3/4', '', '2', '3', '4']); + }); + + it('match /player/1/2/3/4', async () => { + expect(Array.from('/player/1/2/3/4'.match(routesRegexp.player.regexp))) + .toEqual(['/player/1/2/3/4', '1', '2', '3', '4']); + }); + + it('not match /player', async () => { + expect('/player'.match(routesRegexp.player.regexp)) + .toBe(null); + }); + + it('not match /player/', async () => { + expect('/player/'.match(routesRegexp.player.regexp)) + .toBe(null); + }); + + it('not match /player//', async () => { + expect('/player//'.match(routesRegexp.player.regexp)) + .toBe(null); + }); + + it('not match /player///', async () => { + expect('/player///'.match(routesRegexp.player.regexp)) + .toBe(null); + }); + + it('not match /player/////', async () => { + expect('/player/////'.match(routesRegexp.player.regexp)) + .toBe(null); + }); + + it('not match /player/1', async () => { + expect('/player/1'.match(routesRegexp.player.regexp)) + .toBe(null); + }); + + it('not match /player/1/', async () => { + expect('/player/1/'.match(routesRegexp.player.regexp)) + .toBe(null); + }); + + it('not match /player/1//', async () => { + expect('/player/1//'.match(routesRegexp.player.regexp)) + .toBe(null); + }); + + it('not match /player//2/', async () => { + expect('/player//2/'.match(routesRegexp.player.regexp)) + .toBe(null); + }); + + it('not match /player///3', async () => { + expect('/player///3'.match(routesRegexp.player.regexp)) + .toBe(null); + }); + + it('not match /player////4/', async () => { + expect('/player////4/'.match(routesRegexp.player.regexp)) + .toBe(null); + }); + + it('not match /player/1/2', async () => { + expect('/player/1/2'.match(routesRegexp.player.regexp)) + .toBe(null); + }); + + it('not match /player/1/2/', async () => { + expect('/player/1/2/'.match(routesRegexp.player.regexp)) + .toBe(null); + }); + + it('not match /player/1//3', async () => { + expect('/player/1//3'.match(routesRegexp.player.regexp)) + .toBe(null); + }); + + it('not match /player/1/2/3', async () => { + expect('/player/1/2/3'.match(routesRegexp.player.regexp)) + .toBe(null); + }); + + it('not match /player/1/2/3/4/', async () => { + expect('/player/1/2/3/4/'.match(routesRegexp.player.regexp)) .toBe(null); }); });