Total Lines | 28 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | package tests |
||
2 | |||
3 | import ( |
||
4 | "testing" |
||
5 | "time" |
||
6 | |||
7 | "github.com/SerhiiCho/timeago/v3" |
||
8 | "github.com/SerhiiCho/timeago/v3/config" |
||
9 | ) |
||
10 | |||
11 | func TestLocationChanges(t *testing.T) { |
||
12 | cases := []struct { |
||
13 | loc string |
||
14 | subHours time.Duration |
||
15 | expect string |
||
16 | }{ |
||
17 | {"Europe/Kiev", 2, "2 hours ago"}, |
||
18 | {"America/New_York", 2, "5 hours"}, |
||
19 | } |
||
20 | |||
21 | for _, tc := range cases { |
||
22 | t.Run(tc.loc, func(test *testing.T) { |
||
23 | timeago.Configure(&config.Config{Location: tc.loc}) |
||
24 | |||
25 | d := subHours(tc.subHours) |
||
26 | |||
27 | if res := timeago.Parse(d); res != tc.expect { |
||
28 | test.Errorf("Result must be %q, but got %q instead", tc.expect, res) |
||
29 | } |
||
33 |