forked from hustcc/timeago.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pt_BR.spec.ts
103 lines (74 loc) · 3.02 KB
/
pt_BR.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 { advanceBy, advanceTo, clear } from 'jest-date-mock';
import { format, register } from '../../src';
import pt_BR from '../../src/lang/pt_BR';
register('pt_BR', pt_BR);
let date = new Date();
beforeEach(() => {
advanceTo(0);
date = new Date();
});
afterEach(() => {
clear();
});
describe('Brazilian Portuguese', () => {
test('time ago', () => {
advanceTo(9 * 1000);
expect(format(date, 'pt_BR')).toEqual('agora mesmo');
advanceTo(30 * 1000);
expect(format(date, 'pt_BR')).toEqual('há 30 segundos');
advanceTo(1000 * 60);
expect(format(date, 'pt_BR')).toEqual('há um minuto');
advanceTo(1000 * 60 * 30);
expect(format(date, 'pt_BR')).toEqual('há 30 minutos');
advanceTo(1000 * 60 * 60);
expect(format(date, 'pt_BR')).toEqual('há uma hora');
advanceTo(1000 * 60 * 60 * 8);
expect(format(date, 'pt_BR')).toEqual('há 8 horas');
advanceTo(1000 * 60 * 60 * 24);
expect(format(date, 'pt_BR')).toEqual('há um dia');
advanceTo(1000 * 60 * 60 * 24 * 3);
expect(format(date, 'pt_BR')).toEqual('há 3 dias');
advanceTo(1000 * 60 * 60 * 24 * 7);
expect(format(date, 'pt_BR')).toEqual('há uma semana');
advanceTo(1000 * 60 * 60 * 24 * 7 * 3);
expect(format(date, 'pt_BR')).toEqual('há 3 semanas');
advanceTo(1000 * 60 * 60 * 24 * 31);
expect(format(date, 'pt_BR')).toEqual('há um mês');
advanceTo(1000 * 60 * 60 * 24 * 31 * 4);
expect(format(date, 'pt_BR')).toEqual('há 4 meses');
advanceTo(1000 * 60 * 60 * 24 * 366);
expect(format(date, 'pt_BR')).toEqual('há um ano');
advanceTo(1000 * 60 * 60 * 24 * 366 * 10);
expect(format(date, 'pt_BR')).toEqual('há 10 anos');
});
test('time in', () => {
advanceTo(-9 * 1000);
expect(format(date, 'pt_BR')).toEqual('agora');
advanceTo(-30 * 1000);
expect(format(date, 'pt_BR')).toEqual('em 30 segundos');
advanceTo(-1000 * 60);
expect(format(date, 'pt_BR')).toEqual('em um minuto');
advanceTo(-1000 * 60 * 30);
expect(format(date, 'pt_BR')).toEqual('em 30 minutos');
advanceTo(-1000 * 60 * 60);
expect(format(date, 'pt_BR')).toEqual('em uma hora');
advanceTo(-1000 * 60 * 60 * 8);
expect(format(date, 'pt_BR')).toEqual('em 8 horas');
advanceTo(-1000 * 60 * 60 * 24);
expect(format(date, 'pt_BR')).toEqual('em um dia');
advanceTo(-1000 * 60 * 60 * 24 * 3);
expect(format(date, 'pt_BR')).toEqual('em 3 dias');
advanceTo(-1000 * 60 * 60 * 24 * 7);
expect(format(date, 'pt_BR')).toEqual('em uma semana');
advanceTo(-1000 * 60 * 60 * 24 * 7 * 3);
expect(format(date, 'pt_BR')).toEqual('em 3 semanas');
advanceTo(-1000 * 60 * 60 * 24 * 31);
expect(format(date, 'pt_BR')).toEqual('em um mês');
advanceTo(-1000 * 60 * 60 * 24 * 31 * 4);
expect(format(date, 'pt_BR')).toEqual('em 4 meses');
advanceTo(-1000 * 60 * 60 * 24 * 366);
expect(format(date, 'pt_BR')).toEqual('em um ano');
advanceTo(-1000 * 60 * 60 * 24 * 366 * 10);
expect(format(date, 'pt_BR')).toEqual('em 10 anos');
});
});