mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-01-11 22:40:31 +00:00
routesRegexpTests(intro, board) implemented
This commit is contained in:
parent
387d72af61
commit
a49bc04d4c
3 changed files with 1546 additions and 19 deletions
|
|
@ -7,9 +7,10 @@
|
|||
"private": true,
|
||||
"license": "GPLv3",
|
||||
"scripts": {
|
||||
"start": "webpack-dev-server --mode development",
|
||||
"start": "webpack-dev-server --config ./webpack.config.js --mode development",
|
||||
"build": "webpack --mode production",
|
||||
"storybook": "start-storybook --ci --config-dir ./storybook --static-dir ./ --port 6060"
|
||||
"storybook": "start-storybook --ci --config-dir ./storybook --static-dir ./ --port 6060",
|
||||
"test": "jest"
|
||||
},
|
||||
"dependencies": {
|
||||
"a-color-picker": "1.2.1",
|
||||
|
|
@ -45,6 +46,7 @@
|
|||
"cssnano": "4.1.10",
|
||||
"cssnano-preset-advanced": "4.0.7",
|
||||
"html-webpack-plugin": "3.2.0",
|
||||
"jest": "^24.9.0",
|
||||
"less": "3.10.3",
|
||||
"less-loader": "5.0.0",
|
||||
"mini-css-extract-plugin": "0.8.0",
|
||||
|
|
|
|||
40
tests/routesRegexpTests.spec.js
Normal file
40
tests/routesRegexpTests.spec.js
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
const routesRegexp = require('../src/common/routesRegexp');
|
||||
|
||||
const urlParamsMatch = (result, urlParams) => {
|
||||
expect(Array.isArray(result)).toBe(true);
|
||||
expect(result.length).toBe(urlParams.length);
|
||||
urlParams.forEach((urlParam, index) => {
|
||||
expect(result[index]).toBe(urlParam);
|
||||
});
|
||||
};
|
||||
|
||||
describe('routes regex', () => {
|
||||
describe('intro regexp', () => {
|
||||
it('goes to /intro', async () => {
|
||||
const result = '/intro'.match(routesRegexp.intro.regexp);
|
||||
urlParamsMatch(result, ['/intro']);
|
||||
});
|
||||
|
||||
it('goes to /intro/', async () => {
|
||||
const result = '/intro/'.match(routesRegexp.intro.regexp);
|
||||
urlParamsMatch(result, ['/intro/']);
|
||||
});
|
||||
|
||||
it('goes to /intro/<random_input>', async () => {
|
||||
const result = '/intro/a'.match(routesRegexp.intro.regexp);
|
||||
expect(result).toBe(null);
|
||||
});
|
||||
});
|
||||
|
||||
describe('board regexp', () => {
|
||||
it('goes to /', async () => {
|
||||
const result = '/'.match(routesRegexp.board.regexp);
|
||||
urlParamsMatch(result, ['/']);
|
||||
});
|
||||
|
||||
it('goes to /<random_input>', async () => {
|
||||
const result = '/a'.match(routesRegexp.board.regexp);
|
||||
expect(result).toBe(null);
|
||||
});
|
||||
});
|
||||
});
|
||||
Loading…
Reference in a new issue