diff --git a/projects/kit/src/lib/masks/date-range/date-range-mask.ts b/projects/kit/src/lib/masks/date-range/date-range-mask.ts index 8180259cb..cb6db3cbd 100644 --- a/projects/kit/src/lib/masks/date-range/date-range-mask.ts +++ b/projects/kit/src/lib/masks/date-range/date-range-mask.ts @@ -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({ diff --git a/projects/kit/src/lib/masks/date-range/processors/preudo-range-separator-preprocessor.ts b/projects/kit/src/lib/masks/date-range/processors/pseudo-range-separator-preprocessor.ts similarity index 100% rename from projects/kit/src/lib/masks/date-range/processors/preudo-range-separator-preprocessor.ts rename to projects/kit/src/lib/masks/date-range/processors/pseudo-range-separator-preprocessor.ts diff --git a/projects/kit/src/lib/masks/date-range/tests/pseudo-range-separators.spec.ts b/projects/kit/src/lib/masks/date-range/tests/pseudo-range-separators.spec.ts new file mode 100644 index 000000000..9ee713cd7 --- /dev/null +++ b/projects/kit/src/lib/masks/date-range/tests/pseudo-range-separators.spec.ts @@ -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`, + ); + }); +});