mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-26 21:19:43 -08:00
32 lines
940 B
TypeScript
32 lines
940 B
TypeScript
import { fuzzyCompare } from '../../utils/utilities';
|
|
|
|
//most test cases for fuzzyCompare are done in Compare Datasets node tests
|
|
describe('Test fuzzyCompare', () => {
|
|
it('should do strict comparison', () => {
|
|
const compareFunction = fuzzyCompare(false);
|
|
|
|
expect(compareFunction(1, '1')).toEqual(false);
|
|
});
|
|
|
|
it('should do fuzzy comparison', () => {
|
|
const compareFunction = fuzzyCompare(true);
|
|
|
|
expect(compareFunction(1, '1')).toEqual(true);
|
|
});
|
|
|
|
it('should treat null, 0 and "0" as equal', () => {
|
|
const compareFunction = fuzzyCompare(true, 2);
|
|
|
|
expect(compareFunction(null, null)).toEqual(true);
|
|
expect(compareFunction(null, 0)).toEqual(true);
|
|
expect(compareFunction(null, '0')).toEqual(true);
|
|
});
|
|
|
|
it('should not treat null, 0 and "0" as equal', () => {
|
|
const compareFunction = fuzzyCompare(true);
|
|
|
|
expect(compareFunction(null, 0)).toEqual(false);
|
|
expect(compareFunction(null, '0')).toEqual(false);
|
|
});
|
|
});
|