-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Expand file tree
/
Copy pathuseRelativeTimeFormatter.js
More file actions
40 lines (35 loc) · 1.09 KB
/
useRelativeTimeFormatter.js
File metadata and controls
40 lines (35 loc) · 1.09 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
import { timeouts } from '../constants.json';
// selenium-webdriver API doc:
// https://seleniumhq.github.io/selenium/docs/api/javascript/module/selenium-webdriver/index_exports_WebDriver.html
jest.setTimeout(timeouts.test);
test('should return relative time for "yue"', async () => {
const { pageObjects } = await setupWebDriver({
props: {
locale: 'yue'
}
});
const actual = await pageObjects.runHook('useRelativeTimeFormatter', [], formatRelativeTime => [
formatRelativeTime(Date.now()),
formatRelativeTime(new Date()),
formatRelativeTime(new Date().toISOString()),
formatRelativeTime(Date.now() - 60000),
formatRelativeTime(Date.now() - 120000),
formatRelativeTime(Date.now() - 3600000),
formatRelativeTime(Date.now() - 7200000),
formatRelativeTime(Date.now() - 86400000),
formatRelativeTime(Date.now() - 172800000)
]);
expect(actual).toMatchInlineSnapshot(`
[
"啱啱",
"啱啱",
"啱啱",
"一分鐘前",
"2 分鐘前",
"一個鐘前",
"2 小時前",
"今日",
"尋日",
]
`);
});