-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtest.ts
46 lines (35 loc) · 1.06 KB
/
test.ts
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
43
44
45
46
import test from 'ava';
import {isValidPesel, checkGender, getDateOfBirth} from './dist';
test('pesel too short', t => {
t.is(isValidPesel('1'), false);
});
test('pesel too long', t => {
t.is(isValidPesel('111111111111'), false);
});
test('invalid pesel', t => {
t.is(isValidPesel('371340514609'), false);
});
test('valid pesel', t => {
t.is(isValidPesel('54022856499'), true);
});
test('check gender (male)', t => {
t.is(checkGender('69021818876'), 'male');
});
test('check gender (female)', t => {
t.is(checkGender('58081476249'), 'female');
});
test('get date of birth (19th century)', t => {
t.is(getDateOfBirth('00840345828'), '1800/04/03');
});
test('get date of birth (20th century)', t => {
t.is(getDateOfBirth('75040373939'), '1975/04/03');
});
test('get date of birth (21st century)', t => {
t.is(getDateOfBirth('13240376213'), '2013/04/03');
});
test('get date of birth (22nd century)', t => {
t.is(getDateOfBirth('00440345653'), '2100/04/03');
});
test('get date of birth (23rd century)', t => {
t.is(getDateOfBirth('00640345653'), '2200/04/03');
});