Skip to content
This repository has been archived by the owner on Sep 4, 2024. It is now read-only.

Commit

Permalink
test: move tests inside format.test.js
Browse files Browse the repository at this point in the history
  • Loading branch information
probil committed Nov 3, 2018
1 parent 358f15b commit 35bf20d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 26 deletions.
24 changes: 0 additions & 24 deletions src/__tests__/clean.test.js

This file was deleted.

27 changes: 25 additions & 2 deletions src/__tests__/format.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import format from '../format';
import format, { clean } from '../format';

describe('format.js', () => {
describe('default export', () => {
it('should be a function', () => {
expect(format).toEqual(expect.any(Function));
});
Expand Down Expand Up @@ -80,3 +80,26 @@ describe('format.js', () => {
expect(format('365038704', '###-##-####')).toBe('365-03-8704');
});
});

describe('.clean()', () => {
it('should return the entry value without the mask', () => {
// time with seconds
expect(clean('11:15:15', '##:##:##')).toBe('111515');
// hours and minutes
expect(clean('20h15m', '##h##m')).toBe('2015');
// date-time
expect(clean('27/10/2016 23:15', '##/##/#### ##:##')).toBe('271020162315');
// credit card
expect(clean('4532 4782 5524 7634', '#### #### #### ####')).toBe('4532478255247634');
// phone number
expect(clean('(999) 999-9999', '(###) ###-####')).toBe('9999999999');
// phone number (US)
expect(clean('+1 (999) 999-9999', '+1 (###) ###-####')).toBe('9999999999');
// CPF
expect(clean('390.533.447-05', '###.###.###-##')).toBe('39053344705');
// CPNJ
expect(clean('53.288.196/0001-28', '##.###.###/####-##')).toBe('53288196000128');
// Social Security number
expect(clean('365-03-8704', '###-##-####')).toBe('365038704');
});
});

0 comments on commit 35bf20d

Please sign in to comment.