forked from Expensify/App
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCardUtilsTest.js
42 lines (35 loc) · 1.94 KB
/
CardUtilsTest.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
const cardUtils = require('../../src/libs/CardUtils');
const shortDate = '0924';
const shortDateSlashed = '09/24';
const shortDateHyphen = '09-24';
const longDate = '092024';
const longDateSlashed = '09/2024';
const longDateHyphen = '09-2024';
const expectedMonth = '09';
const expectedYear = '2024';
describe('CardUtils', () => {
it('Test MM/YYYY format for getting expirationDate month and year', () => {
expect(cardUtils.getMonthFromExpirationDateString(longDateSlashed)).toBe(expectedMonth);
expect(cardUtils.getYearFromExpirationDateString(longDateSlashed)).toBe(expectedYear);
});
it('Test MM-YYYY format for getting expirationDate month and year', () => {
expect(cardUtils.getMonthFromExpirationDateString(longDateHyphen)).toBe(expectedMonth);
expect(cardUtils.getYearFromExpirationDateString(longDateHyphen)).toBe(expectedYear);
});
it('Test MMYYYY format for getting expirationDate month and year', () => {
expect(cardUtils.getMonthFromExpirationDateString(longDate)).toBe(expectedMonth);
expect(cardUtils.getYearFromExpirationDateString(longDate)).toBe(expectedYear);
});
it('Test MM/YY format for getting expirationDate month and year', () => {
expect(cardUtils.getMonthFromExpirationDateString(shortDateSlashed)).toBe(expectedMonth);
expect(cardUtils.getYearFromExpirationDateString(shortDateSlashed)).toBe(expectedYear);
});
it('Test MM-YY format for getting expirationDate month and year', () => {
expect(cardUtils.getMonthFromExpirationDateString(shortDateHyphen)).toBe(expectedMonth);
expect(cardUtils.getYearFromExpirationDateString(shortDateHyphen)).toBe(expectedYear);
});
it('Test MMYY format for getting expirationDate month and year', () => {
expect(cardUtils.getMonthFromExpirationDateString(shortDate)).toBe(expectedMonth);
expect(cardUtils.getYearFromExpirationDateString(shortDate)).toBe(expectedYear);
});
});