mirror of
https://github.com/trezor/trezor-wallet
synced 2025-02-10 07:02:38 +00:00
Observe changes removed snapshots
This commit is contained in:
parent
2ecf92214d
commit
ee2dd40b59
@ -6,6 +6,7 @@ module.exports = {
|
||||
testURL: 'http://localhost',
|
||||
modulePathIgnorePatterns: [
|
||||
'node_modules',
|
||||
'utils/build.js',
|
||||
'utils/windowUtils.js',
|
||||
'utils/promiseUtils.js',
|
||||
'utils/networkUtils.js',
|
||||
|
@ -1,55 +0,0 @@
|
||||
// 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 shoud be the same - returns false 10`] = `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`;
|
||||
|
||||
exports[`reducers utils observeChanges shoul NOT be the same - returns true 10`] = `true`;
|
||||
|
||||
exports[`reducers utils observeChanges shoul NOT be the same - returns true 11`] = `true`;
|
||||
|
||||
exports[`reducers utils observeChanges shoul NOT be the same - returns true 12`] = `true`;
|
||||
|
||||
exports[`reducers utils observeChanges shoul NOT be the same - returns true 13`] = `true`;
|
||||
|
||||
exports[`reducers utils observeChanges shoul NOT be the same - returns true 14`] = `true`;
|
||||
|
||||
exports[`reducers utils observeChanges shoul NOT be the same - returns true 15`] = `true`;
|
||||
|
||||
exports[`reducers utils observeChanges test filter 1`] = `false`;
|
||||
|
||||
exports[`reducers utils observeChanges test filter 2`] = `true`;
|
@ -1,148 +1,135 @@
|
||||
import * as reducerUtils from '../index';
|
||||
import * as utils from '../index';
|
||||
|
||||
describe('reducers utils', () => {
|
||||
it('observeChanges shoud be the same - returns false', () => {
|
||||
const data = [
|
||||
// example of same data (false)
|
||||
{
|
||||
previous: {},
|
||||
current: {},
|
||||
},
|
||||
{
|
||||
previous: 1,
|
||||
current: 1,
|
||||
},
|
||||
{
|
||||
previous: [],
|
||||
current: [],
|
||||
},
|
||||
{
|
||||
previous: [1, 1, 1],
|
||||
current: [1, 1, 1],
|
||||
},
|
||||
{
|
||||
previous: 'a',
|
||||
current: 'a',
|
||||
},
|
||||
{
|
||||
previous: { one: 1 },
|
||||
current: { one: 1 },
|
||||
},
|
||||
{
|
||||
previous: { one: { two: 1 } },
|
||||
current: { one: { two: 1 } },
|
||||
},
|
||||
{
|
||||
previous: { one: { two: [1, 2, 3] } },
|
||||
current: { one: { two: [1, 2, 3] } },
|
||||
},
|
||||
{
|
||||
previous: { one: { two: [1, { three: 1 }, 3] } },
|
||||
current: { one: { two: [1, { three: 1 }, 3] } },
|
||||
},
|
||||
{
|
||||
previous: { one: { two: [1, { three: 1 }, { four: 3, five: { six: 3 } }] } },
|
||||
current: { one: { two: [1, { three: 1 }, { four: 3, five: { six: 3 } }] } },
|
||||
},
|
||||
];
|
||||
it('observer changes should BE THE SAME - return false', () => {
|
||||
expect(utils.observeChanges(
|
||||
{},
|
||||
{},
|
||||
)).toBe(false);
|
||||
|
||||
data.forEach((item) => {
|
||||
expect(reducerUtils.observeChanges(
|
||||
item.previous, item.current,
|
||||
)).toMatchSnapshot();
|
||||
});
|
||||
expect(utils.observeChanges(
|
||||
[],
|
||||
[],
|
||||
)).toBe(false);
|
||||
|
||||
expect(utils.observeChanges(
|
||||
[1, 1, 1],
|
||||
[1, 1, 1],
|
||||
)).toBe(false);
|
||||
|
||||
expect(utils.observeChanges(
|
||||
'a',
|
||||
'a',
|
||||
)).toBe(false);
|
||||
|
||||
expect(utils.observeChanges(
|
||||
{ one: 1 },
|
||||
{ one: 1 },
|
||||
)).toBe(false);
|
||||
|
||||
expect(utils.observeChanges(
|
||||
{ one: { two: 1 } },
|
||||
{ one: { two: 1 } },
|
||||
)).toBe(false);
|
||||
|
||||
expect(utils.observeChanges(
|
||||
{ one: { two: [1, 2, 3] } },
|
||||
{ one: { two: [1, 2, 3] } },
|
||||
)).toBe(false);
|
||||
|
||||
expect(utils.observeChanges(
|
||||
{ one: { two: [1, { three: 1 }, 3] } },
|
||||
{ one: { two: [1, { three: 1 }, 3] } },
|
||||
)).toBe(false);
|
||||
|
||||
expect(utils.observeChanges(
|
||||
{ one: { two: [1, { three: 1 }, { four: 3, five: { six: 3 } }] } },
|
||||
{ one: { two: [1, { three: 1 }, { four: 3, five: { six: 3 } }] } },
|
||||
)).toBe(false);
|
||||
});
|
||||
|
||||
it('observeChanges shoul NOT be the same - returns true', () => {
|
||||
const data = [
|
||||
// example of different data (true)
|
||||
{
|
||||
previous: null,
|
||||
current: {},
|
||||
},
|
||||
{
|
||||
previous: { one: 1 },
|
||||
current: {},
|
||||
},
|
||||
{
|
||||
previous: { one: 1, three: 3 },
|
||||
current: { one: 1, two: 2 },
|
||||
},
|
||||
{
|
||||
previous: [{}, {}],
|
||||
current: [],
|
||||
},
|
||||
{
|
||||
previous: [1, 1, 1],
|
||||
current: [1, 1],
|
||||
},
|
||||
{
|
||||
previous: 'a',
|
||||
current: 'b',
|
||||
},
|
||||
{
|
||||
previous: ['a'],
|
||||
current: ['b'],
|
||||
},
|
||||
{
|
||||
previous: 1,
|
||||
current: '1',
|
||||
},
|
||||
{
|
||||
previous: { one: 1 },
|
||||
current: { one: 2 },
|
||||
},
|
||||
{
|
||||
previous: { one: { two: 1 } },
|
||||
current: { one: { two: 2 } },
|
||||
},
|
||||
{
|
||||
previous: { one: { two: 1 } },
|
||||
current: { one: { two: 2 } },
|
||||
},
|
||||
{
|
||||
previous: { one: { two: [1, 2, 3] } },
|
||||
current: { one: { two: [1, 1, 3] } },
|
||||
},
|
||||
{
|
||||
previous: { one: { two: [1, { three: 1 }, 3] } },
|
||||
current: { one: { two: [1, { three: 2 }, 3] } },
|
||||
},
|
||||
{
|
||||
previous: { one: { two: [1, { three: 1 }, { four: 3, five: { six: 3 } }] } },
|
||||
current: { one: { two: [1, { three: 1 }, { four: 3, five: { six: 1 } }] } },
|
||||
},
|
||||
{
|
||||
previous: { one: { two: [1, { three: 1 }, { four: 3, five: { sixxx: 3 } }] } },
|
||||
current: { one: { two: [1, { three: 1 }, { four: 3, five: { six: 1 } }] } },
|
||||
},
|
||||
];
|
||||
it('observer should NOT be the same - return true', () => {
|
||||
expect(utils.observeChanges(
|
||||
null,
|
||||
{},
|
||||
)).toBe(true);
|
||||
|
||||
data.forEach((item) => {
|
||||
expect(reducerUtils.observeChanges(
|
||||
item.previous, item.current,
|
||||
)).toMatchSnapshot();
|
||||
});
|
||||
expect(utils.observeChanges(
|
||||
{ one: 1 },
|
||||
{},
|
||||
)).toBe(true);
|
||||
|
||||
expect(utils.observeChanges(
|
||||
{ one: 1, three: 3 }, { one: 1, two: 2 },
|
||||
)).toBe(true);
|
||||
|
||||
expect(utils.observeChanges(
|
||||
[{}, {}],
|
||||
[],
|
||||
)).toBe(true);
|
||||
|
||||
expect(utils.observeChanges(
|
||||
[1, 1, 1],
|
||||
[1, 1],
|
||||
)).toBe(true);
|
||||
|
||||
expect(utils.observeChanges(
|
||||
'a',
|
||||
'b',
|
||||
)).toBe(true);
|
||||
|
||||
expect(utils.observeChanges(
|
||||
['a'],
|
||||
['b'],
|
||||
)).toBe(true);
|
||||
|
||||
expect(utils.observeChanges(
|
||||
1,
|
||||
'1',
|
||||
)).toBe(true);
|
||||
|
||||
expect(utils.observeChanges(
|
||||
{ one: 1 },
|
||||
{ one: 2 },
|
||||
)).toBe(true);
|
||||
|
||||
expect(utils.observeChanges(
|
||||
{ one: { two: 1 } },
|
||||
{ one: { two: 2 } },
|
||||
)).toBe(true);
|
||||
|
||||
expect(utils.observeChanges(
|
||||
{ one: { two: [1, 2, 3] } },
|
||||
{ one: { two: [1, 1, 3] } },
|
||||
)).toBe(true);
|
||||
|
||||
expect(utils.observeChanges(
|
||||
{ one: { two: [1, { three: 1 }, 3] } },
|
||||
{ one: { two: [1, { three: 2 }, 3] } },
|
||||
)).toBe(true);
|
||||
|
||||
expect(utils.observeChanges(
|
||||
{ one: { two: [1, { three: 1 }, { four: 3, five: { six: 3 } }] } },
|
||||
{ one: { two: [1, { three: 1 }, { four: 3, five: { six: 1 } }] } },
|
||||
)).toBe(true);
|
||||
|
||||
expect(utils.observeChanges(
|
||||
{ one: { two: [1, { three: 1 }, { four: 3, five: { sixxx: 3 } }] } },
|
||||
{ one: { two: [1, { three: 1 }, { four: 3, five: { six: 1 } }] } },
|
||||
)).toBe(true);
|
||||
});
|
||||
|
||||
it('observeChanges test filter', () => {
|
||||
const data = [
|
||||
{
|
||||
previous: { one: { two: 2, three: 3 } },
|
||||
current: { one: { two: 2, three: 4 } },
|
||||
filter: { one: ['two'] },
|
||||
},
|
||||
{
|
||||
previous: { one: { two: 2, three: 3 } },
|
||||
current: { one: { two: 1, three: 3 } },
|
||||
filter: { one: ['two'] },
|
||||
},
|
||||
];
|
||||
expect(utils.observeChanges(
|
||||
{ one: { two: 2, three: 3 } },
|
||||
{ one: { two: 2, three: 4 } },
|
||||
{ one: ['two'] },
|
||||
)).toBe(false);
|
||||
|
||||
data.forEach((item) => {
|
||||
expect(reducerUtils.observeChanges(
|
||||
item.previous, item.current, item.filter,
|
||||
)).toMatchSnapshot();
|
||||
});
|
||||
expect(utils.observeChanges(
|
||||
{ one: { two: 2, three: 3 } },
|
||||
{ one: { two: 1, three: 3 } },
|
||||
{ one: ['two'] },
|
||||
)).toBe(true);
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user