pull Svetla's test branch

This commit is contained in:
NikolaBorislavovHristov 2019-12-09 12:44:26 +02:00
commit 6d75b306fb
3 changed files with 1572 additions and 101 deletions

View file

@ -9,7 +9,8 @@
"scripts": {
"start": "webpack-dev-server --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",
@ -47,6 +48,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",

View 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);
});
});
});

1629
yarn.lock

File diff suppressed because it is too large Load diff