2018-12-23 03:13:56 +03:00
|
|
|
import { assertion } from '../src/vanilla/mocha';
|
|
|
|
import { compare } from '../src/TestGenerator';
|
|
|
|
|
|
|
|
const computedStates = [
|
|
|
|
{ state: { o1: 0 } },
|
|
|
|
{ state: { o1: 0, o2: 1 } },
|
|
|
|
{ state: { o1: 0, o2: 'a' } },
|
|
|
|
{ state: { o1: [{ t: 1 }], o3: { t: 2 } } },
|
|
|
|
{ state: { o1: [{ t: 3 }], o3: { t: 2 } } },
|
|
|
|
{ state: [0, 1, 2, 3, 4] },
|
|
|
|
{ state: [0, 3] },
|
2020-08-08 23:26:39 +03:00
|
|
|
{ state: [0, 2, 3, 4] },
|
2018-12-23 03:13:56 +03:00
|
|
|
];
|
|
|
|
|
2019-01-10 21:51:14 +03:00
|
|
|
const test = (s1, s2) =>
|
|
|
|
compare(s1, s2, ({ path, curState }) =>
|
|
|
|
expect(`expect(store${path}).toEqual(${curState});`).toBe(
|
|
|
|
assertion({ path, curState })
|
|
|
|
)
|
|
|
|
);
|
2018-12-23 03:13:56 +03:00
|
|
|
|
|
|
|
describe('Assertions', () => {
|
|
|
|
it('should return initial state', () => {
|
2019-01-10 21:51:14 +03:00
|
|
|
test(undefined, computedStates[0]);
|
2018-12-23 03:13:56 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should add element', () => {
|
2019-01-10 21:51:14 +03:00
|
|
|
test(computedStates[0], computedStates[1]);
|
2018-12-23 03:13:56 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should remove element', () => {
|
2019-01-10 21:51:14 +03:00
|
|
|
test(computedStates[1], computedStates[0]);
|
2018-12-23 03:13:56 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should change element', () => {
|
2019-01-10 21:51:14 +03:00
|
|
|
test(computedStates[1], computedStates[2]);
|
2018-12-23 03:13:56 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should add, change and remove elements', () => {
|
2019-01-10 21:51:14 +03:00
|
|
|
test(computedStates[2], computedStates[3]);
|
2018-12-23 03:13:56 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should change in array', () => {
|
2019-01-10 21:51:14 +03:00
|
|
|
test(computedStates[3], computedStates[4]);
|
2018-12-23 03:13:56 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should remove elements in array', () => {
|
2019-01-10 21:51:14 +03:00
|
|
|
test(computedStates[5], computedStates[6]);
|
2018-12-23 03:13:56 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should add elements in array', () => {
|
2019-01-10 21:51:14 +03:00
|
|
|
test(computedStates[6], computedStates[5]);
|
2018-12-23 03:13:56 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should add and change elements in array', () => {
|
2019-01-10 21:51:14 +03:00
|
|
|
test(computedStates[5], computedStates[7]);
|
2018-12-23 03:13:56 +03:00
|
|
|
});
|
|
|
|
});
|