1
0
mirror of https://github.com/trezor/trezor-wallet synced 2024-11-24 09:18:09 +00:00

Added basic tests

This commit is contained in:
Vladimir Volek 2018-10-02 19:55:22 +02:00 committed by Szymon Lesisz
parent 8e33c24875
commit 147cf400a4
3 changed files with 137 additions and 0 deletions

View File

@ -12,6 +12,7 @@ module.exports = {
], ],
collectCoverageFrom: [ collectCoverageFrom: [
'utils/**.js', 'utils/**.js',
'reducers/utils/**.js',
], ],
setupFiles: [ setupFiles: [
'./support/setupJest.js', './support/setupJest.js',

View File

@ -0,0 +1,37 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`reducers utils observeChanges shoud be the same - returns false 1`] = `false`;
exports[`reducers utils observeChanges shoud be the same - returns false 2`] = `false`;
exports[`reducers utils observeChanges shoud be the same - returns false 3`] = `false`;
exports[`reducers utils observeChanges shoud be the same - returns false 4`] = `false`;
exports[`reducers utils observeChanges shoud be the same - returns false 5`] = `false`;
exports[`reducers utils observeChanges shoud be the same - returns false 6`] = `false`;
exports[`reducers utils observeChanges shoud be the same - returns false 7`] = `false`;
exports[`reducers utils observeChanges shoud be the same - returns false 8`] = `false`;
exports[`reducers utils observeChanges shoud be the same - returns false 9`] = `false`;
exports[`reducers utils observeChanges shoul NOT be the same - returns true 1`] = `true`;
exports[`reducers utils observeChanges shoul NOT be the same - returns true 2`] = `true`;
exports[`reducers utils observeChanges shoul NOT be the same - returns true 3`] = `true`;
exports[`reducers utils observeChanges shoul NOT be the same - returns true 4`] = `true`;
exports[`reducers utils observeChanges shoul NOT be the same - returns true 5`] = `true`;
exports[`reducers utils observeChanges shoul NOT be the same - returns true 6`] = `true`;
exports[`reducers utils observeChanges shoul NOT be the same - returns true 7`] = `true`;
exports[`reducers utils observeChanges shoul NOT be the same - returns true 8`] = `true`;
exports[`reducers utils observeChanges shoul NOT be the same - returns true 9`] = `true`;

View File

@ -0,0 +1,99 @@
import * as reducerUtils from '../index';
describe('reducers utils', () => {
it('observeChanges shoud be the same - returns false', () => {
const data = [
// example of same data (false)
{
pervious: {},
current: {},
},
{
pervious: 1,
current: 1,
},
{
pervious: [],
current: [],
},
{
pervious: 'a',
current: 'a',
},
{
pervious: { test: 1 },
current: { test: 1 },
},
{
pervious: { test: { test: 1 } },
current: { test: { test: 1 } },
},
{
pervious: { test: { test: [1, 2, 3] } },
current: { test: { test: [1, 2, 3] } },
},
{
pervious: { test: { test: [1, { test: 1 }, 3] } },
current: { test: { test: [1, { test: 1 }, 3] } },
},
{
pervious: { test: { test: [1, { test: 1 }, { test: 3, test1: { test: 3 } }] } },
current: { test: { test: [1, { test: 1 }, { test: 3, test1: { test: 3 } }] } },
},
];
data.forEach((item) => {
expect(reducerUtils.observeChanges(
item.pervious, item.current,
)).toMatchSnapshot();
});
});
it('observeChanges shoul NOT be the same - returns true', () => {
const data = [
// example of different data (true)
{
pervious: { test: 1 },
current: {},
},
{
pervious: [{}],
current: [],
},
{
pervious: 'a',
current: 'b',
},
{
pervious: 1,
current: '1',
},
{
pervious: { test: 1 },
current: { test: 2 },
},
{
pervious: { test: { test: 1 } },
current: { test: { test: 2 } },
},
{
pervious: { test: { test: [1, 2, 3] } },
current: { test: { test: [1, 1, 3] } },
},
{
pervious: { test: { test: [1, { test: 1 }, 3] } },
current: { test: { test: [1, { test: 2 }, 3] } },
},
{
pervious: { test: { test: [1, { test: 1 }, { test: 3, test1: { test: 3 } }] } },
current: { test: { test: [1, { test: 1 }, { test: 3, test1: { test: 1 } }] } },
},
];
data.forEach((item) => {
expect(reducerUtils.observeChanges(
item.pervious, item.current,
)).toMatchSnapshot();
});
});
});