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

Fixed bug in function, add more tests

This commit is contained in:
Vladimir Volek 2018-10-02 20:06:59 +02:00 committed by Szymon Lesisz
parent 9771b21093
commit 802e8f8e32
3 changed files with 14 additions and 2 deletions

View File

@ -18,6 +18,8 @@ exports[`reducers utils observeChanges shoud be the same - returns false 8`] = `
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`;
@ -35,3 +37,5 @@ exports[`reducers utils observeChanges shoul NOT be the same - returns true 7`]
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`;

View File

@ -16,6 +16,10 @@ describe('reducers utils', () => {
pervious: [],
current: [],
},
{
pervious: [1, 1, 1],
current: [1, 1, 1],
},
{
pervious: 'a',
current: 'a',
@ -57,9 +61,13 @@ describe('reducers utils', () => {
current: {},
},
{
pervious: [{}],
pervious: [{}, {}],
current: [],
},
{
pervious: [1, 1, 1],
current: [1, 1],
},
{
pervious: 'a',
current: 'b',

View File

@ -122,7 +122,7 @@ export const observeChanges = (prev: ?Object, current: ?Object, filter?: {[k: st
// 2. one of the objects is null/undefined
if (!prev || !current) return true;
const prevType = Object.prototype.toString.call(current);
const prevType = Object.prototype.toString.call(prev);
const currentType = Object.prototype.toString.call(current);
// 3. one of the objects has different type then other
if (prevType !== currentType) return true;