You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
trezor-wallet/src/reducers/utils/__tests__/index.test.js

100 lines
2.9 KiB

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();
});
});
});