-
-
Notifications
You must be signed in to change notification settings - Fork 406
Expand file tree
/
Copy pathan.spec.ts
More file actions
104 lines (74 loc) · 3.16 KB
/
Copy pathan.spec.ts
File metadata and controls
104 lines (74 loc) · 3.16 KB
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
104
import { register, format } from '../../src';
import an from '../../src/lang/an';
register('an', an);
let date = new Date();
beforeEach(() => {
vi.useFakeTimers();
vi.setSystemTime(0);
date = new Date();
});
afterEach(() => {
vi.useRealTimers();
});
describe('an', () => {
test('time ago', () => {
vi.setSystemTime(9 * 1000);
expect(format(date, 'an')).toEqual('fa un momento');
vi.setSystemTime(30 * 1000);
expect(format(date, 'an')).toEqual('fa 30 segundos');
vi.setSystemTime(1000 * 60);
expect(format(date, 'an')).toEqual('fa 1 minuto');
vi.setSystemTime(1000 * 60 * 30);
expect(format(date, 'an')).toEqual('fa 30 minutos');
vi.setSystemTime(1000 * 60 * 60);
expect(format(date, 'an')).toEqual('fa 1 hora');
vi.setSystemTime(1000 * 60 * 60 * 8);
expect(format(date, 'an')).toEqual('fa 8 horas');
vi.setSystemTime(1000 * 60 * 60 * 24);
expect(format(date, 'an')).toEqual('fa 1 día');
vi.setSystemTime(1000 * 60 * 60 * 24 * 3);
expect(format(date, 'an')).toEqual('fa 3 días');
vi.setSystemTime(1000 * 60 * 60 * 24 * 7);
expect(format(date, 'an')).toEqual('fa 1 semana');
vi.setSystemTime(1000 * 60 * 60 * 24 * 7 * 3);
expect(format(date, 'an')).toEqual('fa 3 semanas');
vi.setSystemTime(1000 * 60 * 60 * 24 * 31);
expect(format(date, 'an')).toEqual('fa 1 mes');
vi.setSystemTime(1000 * 60 * 60 * 24 * 31 * 4);
expect(format(date, 'an')).toEqual('fa 4 meses');
vi.setSystemTime(1000 * 60 * 60 * 24 * 366);
expect(format(date, 'an')).toEqual('fa 1 anyo');
vi.setSystemTime(1000 * 60 * 60 * 24 * 366 * 10);
expect(format(date, 'an')).toEqual('fa 10 anyos');
});
test('time in', () => {
vi.setSystemTime(-9 * 1000);
expect(format(date, 'an')).toEqual("d'aquí a un momento");
vi.setSystemTime(-30 * 1000);
expect(format(date, 'an')).toEqual("d'aquí a 30 segundos");
vi.setSystemTime(-1000 * 60);
expect(format(date, 'an')).toEqual("d'aquí a 1 minuto");
vi.setSystemTime(-1000 * 60 * 30);
expect(format(date, 'an')).toEqual("d'aquí a 30 minutos");
vi.setSystemTime(-1000 * 60 * 60);
expect(format(date, 'an')).toEqual("d'aquí a 1 hora");
vi.setSystemTime(-1000 * 60 * 60 * 8);
expect(format(date, 'an')).toEqual("d'aquí a 8 horas");
vi.setSystemTime(-1000 * 60 * 60 * 24);
expect(format(date, 'an')).toEqual("d'aquí a 1 día");
vi.setSystemTime(-1000 * 60 * 60 * 24 * 3);
expect(format(date, 'an')).toEqual("d'aquí a 3 días");
vi.setSystemTime(-1000 * 60 * 60 * 24 * 7);
expect(format(date, 'an')).toEqual("d'aquí a 1 semana");
vi.setSystemTime(-1000 * 60 * 60 * 24 * 7 * 3);
expect(format(date, 'an')).toEqual("d'aquí a 3 semanas");
vi.setSystemTime(-1000 * 60 * 60 * 24 * 31);
expect(format(date, 'an')).toEqual("d'aquí a 1 mes");
vi.setSystemTime(-1000 * 60 * 60 * 24 * 31 * 4);
expect(format(date, 'an')).toEqual("d'aquí a 4 meses");
vi.setSystemTime(-1000 * 60 * 60 * 24 * 366);
expect(format(date, 'an')).toEqual("d'aquí a 1 anyo");
vi.setSystemTime(-1000 * 60 * 60 * 24 * 366 * 10);
expect(format(date, 'an')).toEqual("d'aquí a 10 anyos");
});
});