Skip to content

Commit

Permalink
chore: add units tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nsbarsukov committed Feb 6, 2024
1 parent 97dc5a1 commit 4a5107b
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
2 changes: 1 addition & 1 deletion projects/kit/src/lib/masks/date-range/date-range-mask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
} from '../../processors';
import {MaskitoDateMode, MaskitoDateSegments} from '../../types';
import {createMinMaxRangeLengthPostprocessor} from './processors/min-max-range-length-postprocessor';
import {createPseudoRangeSeparatorPreprocessor} from './processors/preudo-range-separator-preprocessor';
import {createPseudoRangeSeparatorPreprocessor} from './processors/pseudo-range-separator-preprocessor';
import {createSwapDatesPostprocessor} from './processors/swap-dates-postprocessor';

export function maskitoDateRangeOptionsGenerator({
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import {MASKITO_DEFAULT_OPTIONS, MaskitoOptions, maskitoTransform} from '@maskito/core';
import {maskitoDateRangeOptionsGenerator} from '@maskito/kit';

import {CHAR_EM_DASH, CHAR_EN_DASH, CHAR_HYPHEN, CHAR_MINUS} from '../../../constants';

describe('DateRange (maskitoTransform) | Pseudo range separators', () => {
let options: MaskitoOptions = MASKITO_DEFAULT_OPTIONS;

beforeEach(() => {
options = maskitoDateRangeOptionsGenerator({
mode: 'dd/mm/yyyy',
dateSeparator: '.',
rangeSeparator: CHAR_EN_DASH,
});
});

it('works with already valid range separator', () => {
expect(maskitoTransform(`01012000${CHAR_EN_DASH}10102000`, options)).toBe(
`01.01.2000${CHAR_EN_DASH}10.10.2000`,
);
});

it('replaces hyphen with valid range separator', () => {
expect(maskitoTransform(`01012000${CHAR_HYPHEN}10102000`, options)).toBe(
`01.01.2000${CHAR_EN_DASH}10.10.2000`,
);
});

it('replaces em-dash with valid range separator', () => {
expect(maskitoTransform(`01012000${CHAR_EM_DASH}10102000`, options)).toBe(
`01.01.2000${CHAR_EN_DASH}10.10.2000`,
);
});

it('replaces minus with valid range separator', () => {
expect(maskitoTransform(`01012000${CHAR_MINUS}10102000`, options)).toBe(
`01.01.2000${CHAR_EN_DASH}10.10.2000`,
);
});
});

0 comments on commit 4a5107b

Please sign in to comment.