2021-01-23 18:18:59 +02:00
|
|
|
import errorsHaveChanged from './errorsHaveChanged';
|
|
|
|
|
|
|
|
describe('errorsHaveChanged', () => {
|
|
|
|
|
|
|
|
test('should tell if an errors object has changed', () => {
|
|
|
|
const testCases = [
|
|
|
|
[
|
|
|
|
{
|
|
|
|
'one': '111',
|
|
|
|
'two': '222',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'two': '222',
|
|
|
|
'one': '111',
|
|
|
|
},
|
|
|
|
false,
|
|
|
|
],
|
|
|
|
[
|
|
|
|
{
|
|
|
|
'one': '111',
|
|
|
|
'two': '222',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'one': '111',
|
|
|
|
'two': '222',
|
|
|
|
},
|
|
|
|
false,
|
|
|
|
],
|
|
|
|
[
|
|
|
|
{
|
|
|
|
'one': '111',
|
|
|
|
'two': '222',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'one': '111',
|
|
|
|
},
|
|
|
|
true,
|
|
|
|
],
|
|
|
|
[
|
|
|
|
{
|
|
|
|
'one': '111',
|
|
|
|
'two': '222',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'one': '222',
|
|
|
|
'two': '111',
|
|
|
|
},
|
|
|
|
true,
|
|
|
|
],
|
|
|
|
[
|
|
|
|
{},
|
|
|
|
{},
|
|
|
|
false,
|
|
|
|
],
|
|
|
|
];
|
|
|
|
|
|
|
|
for (const t of testCases) {
|
2024-04-05 13:16:49 +02:00
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
|
2022-11-15 12:23:50 +02:00
|
|
|
const [oldErrors, newErrors, expected] = t as any;
|
2021-01-23 18:18:59 +02:00
|
|
|
|
|
|
|
const result = errorsHaveChanged(oldErrors, newErrors);
|
|
|
|
expect(result).toBe(expected);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|