mirror of
https://github.com/trezor/trezor-wallet
synced 2024-11-24 09:18:09 +00:00
Removed unnecesary case, add more tests
This commit is contained in:
parent
a03a8287e8
commit
8be738bf2e
@ -50,6 +50,6 @@ exports[`reducers utils observeChanges shoul NOT be the same - returns true 14`]
|
|||||||
|
|
||||||
exports[`reducers utils observeChanges shoul NOT be the same - returns true 15`] = `true`;
|
exports[`reducers utils observeChanges shoul NOT be the same - returns true 15`] = `true`;
|
||||||
|
|
||||||
exports[`reducers utils observeChanges test filter 1`] = `true`;
|
exports[`reducers utils observeChanges test filter 1`] = `false`;
|
||||||
|
|
||||||
exports[`reducers utils observeChanges test filter 2`] = `false`;
|
exports[`reducers utils observeChanges test filter 2`] = `true`;
|
||||||
|
@ -65,7 +65,7 @@ describe('reducers utils', () => {
|
|||||||
current: {},
|
current: {},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
previous: { one: 1 },
|
previous: { one: 1, three: 3 },
|
||||||
current: { one: 1, two: 2 },
|
current: { one: 1, two: 2 },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -80,6 +80,10 @@ describe('reducers utils', () => {
|
|||||||
previous: 'a',
|
previous: 'a',
|
||||||
current: 'b',
|
current: 'b',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
previous: ['a'],
|
||||||
|
current: ['b'],
|
||||||
|
},
|
||||||
{
|
{
|
||||||
previous: 1,
|
previous: 1,
|
||||||
current: '1',
|
current: '1',
|
||||||
@ -125,12 +129,12 @@ describe('reducers utils', () => {
|
|||||||
const data = [
|
const data = [
|
||||||
{
|
{
|
||||||
previous: { one: { two: 2, three: 3 } },
|
previous: { one: { two: 2, three: 3 } },
|
||||||
current: { one: { two: 2 } },
|
current: { one: { two: 2, three: 4 } },
|
||||||
filter: { one: ['two'] },
|
filter: { one: ['two'] },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
previous: { one: { two: 2, three: 3 } },
|
previous: { one: { two: 2, three: 3 } },
|
||||||
current: { one: { two: 1 } },
|
current: { one: { two: 1, three: 3 } },
|
||||||
filter: { one: ['two'] },
|
filter: { one: ['two'] },
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
@ -144,10 +144,6 @@ export const observeChanges = (prev: ?Object, current: ?Object, filter?: {[k: st
|
|||||||
const prevDifference = prevKeys.find(k => currentKeys.indexOf(k) < 0);
|
const prevDifference = prevKeys.find(k => currentKeys.indexOf(k) < 0);
|
||||||
if (prevDifference) return true;
|
if (prevDifference) return true;
|
||||||
|
|
||||||
// 7. "current" has keys which "prev" doesn't have
|
|
||||||
const currentDifference = currentKeys.find(k => prevKeys.indexOf(k) < 0);
|
|
||||||
if (currentDifference) return true;
|
|
||||||
|
|
||||||
// 8. observe every key recursive
|
// 8. observe every key recursive
|
||||||
for (let i = 0; i < currentKeys.length; i++) {
|
for (let i = 0; i < currentKeys.length; i++) {
|
||||||
const key = currentKeys[i];
|
const key = currentKeys[i];
|
||||||
|
Loading…
Reference in New Issue
Block a user