mirror of
https://github.com/trezor/trezor-wallet
synced 2024-11-28 03:08:30 +00:00
Added basic tests
This commit is contained in:
parent
8e33c24875
commit
147cf400a4
@ -12,6 +12,7 @@ module.exports = {
|
|||||||
],
|
],
|
||||||
collectCoverageFrom: [
|
collectCoverageFrom: [
|
||||||
'utils/**.js',
|
'utils/**.js',
|
||||||
|
'reducers/utils/**.js',
|
||||||
],
|
],
|
||||||
setupFiles: [
|
setupFiles: [
|
||||||
'./support/setupJest.js',
|
'./support/setupJest.js',
|
||||||
|
@ -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`;
|
99
src/reducers/utils/__tests__/index.test.js
Normal file
99
src/reducers/utils/__tests__/index.test.js
Normal 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();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
Loading…
Reference in New Issue
Block a user