1
0
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:
Vladimir Volek 2018-10-03 12:02:08 +02:00 committed by Szymon Lesisz
parent a03a8287e8
commit 8be738bf2e
3 changed files with 9 additions and 9 deletions

View File

@ -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 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`;

View File

@ -65,7 +65,7 @@ describe('reducers utils', () => {
current: {},
},
{
previous: { one: 1 },
previous: { one: 1, three: 3 },
current: { one: 1, two: 2 },
},
{
@ -80,6 +80,10 @@ describe('reducers utils', () => {
previous: 'a',
current: 'b',
},
{
previous: ['a'],
current: ['b'],
},
{
previous: 1,
current: '1',
@ -125,12 +129,12 @@ describe('reducers utils', () => {
const data = [
{
previous: { one: { two: 2, three: 3 } },
current: { one: { two: 2 } },
current: { one: { two: 2, three: 4 } },
filter: { one: ['two'] },
},
{
previous: { one: { two: 2, three: 3 } },
current: { one: { two: 1 } },
current: { one: { two: 1, three: 3 } },
filter: { one: ['two'] },
},
];

View File

@ -144,10 +144,6 @@ export const observeChanges = (prev: ?Object, current: ?Object, filter?: {[k: st
const prevDifference = prevKeys.find(k => currentKeys.indexOf(k) < 0);
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
for (let i = 0; i < currentKeys.length; i++) {
const key = currentKeys[i];