vega-frontend-monorepo/libs/react-helpers/src/lib/grid/flash-cell.spec.tsx
Dexter Edwards 107171d46a
renaming test files (#351)
* renaming test files

* add eslint plugin jest

* enable linting rule and additional rules

* fix a metric ton of linting errors

* fix lint errors

* remove export
2022-05-12 13:32:14 +01:00

36 lines
948 B
TypeScript

import { findFirstDiffPos } from './flash-cell';
describe('findFirstDiffPos', () => {
it('Returns -1 for matching strings', () => {
const a = 'test';
const b = 'test';
expect(findFirstDiffPos(a, b)).toEqual(-1);
});
it('Returns -1 if a string is undefined (just in case)', () => {
const a = 'test';
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const b = undefined as any as string;
expect(findFirstDiffPos(a, b)).toEqual(-1);
expect(findFirstDiffPos(b, a)).toEqual(-1);
});
it('Returns -1 if one string is empty', () => {
const a = 'test';
const b = '';
expect(findFirstDiffPos(a, b)).toEqual(-1);
expect(findFirstDiffPos(b, a)).toEqual(-1);
});
it('Happy path', () => {
const a = 'test';
expect(findFirstDiffPos(a, 'test')).toEqual(-1);
expect(findFirstDiffPos(a, '!est')).toEqual(0);
expect(findFirstDiffPos(a, 't!st')).toEqual(1);
});
});