-
-
Notifications
You must be signed in to change notification settings - Fork 411
/
Copy pathoc.spec.ts
103 lines (74 loc) · 2.94 KB
/
oc.spec.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
import { advanceTo, clear } from 'jest-date-mock';
import { register, format } from '../../src';
import oc from '../../src/lang/oc';
register('oc', oc);
let date = new Date();
beforeEach(() => {
advanceTo(0);
date = new Date();
});
afterEach(() => {
clear();
});
describe('oc', () => {
test('time ago', () => {
advanceTo(9 * 1000);
expect(format(date, 'oc')).toEqual('fa un moment');
advanceTo(30 * 1000);
expect(format(date, 'oc')).toEqual('fa 30 segondas');
advanceTo(1000 * 60);
expect(format(date, 'oc')).toEqual('fa 1 minuta');
advanceTo(1000 * 60 * 30);
expect(format(date, 'oc')).toEqual('fa 30 minutas');
advanceTo(1000 * 60 * 60);
expect(format(date, 'oc')).toEqual('fa 1 ora');
advanceTo(1000 * 60 * 60 * 8);
expect(format(date, 'oc')).toEqual('fa 8 oras');
advanceTo(1000 * 60 * 60 * 24);
expect(format(date, 'oc')).toEqual('fa 1 jorn');
advanceTo(1000 * 60 * 60 * 24 * 3);
expect(format(date, 'oc')).toEqual('fa 3 jorns');
advanceTo(1000 * 60 * 60 * 24 * 7);
expect(format(date, 'oc')).toEqual('fa 1 setmana');
advanceTo(1000 * 60 * 60 * 24 * 7 * 3);
expect(format(date, 'oc')).toEqual('fa 3 setmanas');
advanceTo(1000 * 60 * 60 * 24 * 31);
expect(format(date, 'oc')).toEqual('fa 1 mes');
advanceTo(1000 * 60 * 60 * 24 * 31 * 4);
expect(format(date, 'oc')).toEqual('fa 4 meses');
advanceTo(1000 * 60 * 60 * 24 * 366);
expect(format(date, 'oc')).toEqual('fa 1 an');
advanceTo(1000 * 60 * 60 * 24 * 366 * 10);
expect(format(date, 'oc')).toEqual('fa 10 ans');
});
test('time in', () => {
advanceTo(-9 * 1000);
expect(format(date, 'oc')).toEqual("d'aquí un moment");
advanceTo(-30 * 1000);
expect(format(date, 'oc')).toEqual("d'aquí 30 segondas");
advanceTo(-1000 * 60);
expect(format(date, 'oc')).toEqual("d'aquí 1 minuta");
advanceTo(-1000 * 60 * 30);
expect(format(date, 'oc')).toEqual("d'aquí 30 minutas");
advanceTo(-1000 * 60 * 60);
expect(format(date, 'oc')).toEqual("d'aquí 1 ora");
advanceTo(-1000 * 60 * 60 * 8);
expect(format(date, 'oc')).toEqual("d'aquí 8 oras");
advanceTo(-1000 * 60 * 60 * 24);
expect(format(date, 'oc')).toEqual("d'aquí 1 jorn");
advanceTo(-1000 * 60 * 60 * 24 * 3);
expect(format(date, 'oc')).toEqual("d'aquí 3 jorns");
advanceTo(-1000 * 60 * 60 * 24 * 7);
expect(format(date, 'oc')).toEqual("d'aquí 1 setmana");
advanceTo(-1000 * 60 * 60 * 24 * 7 * 3);
expect(format(date, 'oc')).toEqual("d'aquí 3 setmanas");
advanceTo(-1000 * 60 * 60 * 24 * 31);
expect(format(date, 'oc')).toEqual("d'aquí 1 mes");
advanceTo(-1000 * 60 * 60 * 24 * 31 * 4);
expect(format(date, 'oc')).toEqual("d'aquí 4 meses");
advanceTo(-1000 * 60 * 60 * 24 * 366);
expect(format(date, 'oc')).toEqual("d'aquí 1 an");
advanceTo(-1000 * 60 * 60 * 24 * 366 * 10);
expect(format(date, 'oc')).toEqual("d'aquí 10 ans");
});
});