Passed
Push — v3.0.0 ( 2ee17b...4b7c3c )
by Serhii
01:15
created

tests/just_now_test.go   A

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
cc 5
eloc 27
dl 0
loc 38
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B tests.TestJustNowOption 0 29 5
1
package tests
2
3
import (
4
	"testing"
5
	"time"
6
7
	"github.com/SerhiiCho/timeago/v3"
8
)
9
10
func TestJustNowOption(t *testing.T) {
11
	cases := []struct {
12
		date time.Time
13
	}{
14
		{subSeconds(0)},
15
		{subSeconds(1)},
16
		{subSeconds(2)},
17
		{subSeconds(9)},
18
		{subSeconds(10)},
19
		{subSeconds(11)},
20
		{subSeconds(20)},
21
		{subSeconds(21)},
22
		{subSeconds(22)},
23
		{subSeconds(30)},
24
		{subSeconds(58)},
25
	}
26
27
	for _, tc := range cases {
28
		t.Run("result for "+tc.date.String(), func(test *testing.T) {
29
			timeago.Configure(&timeago.Config{Language: langEn})
30
31
			res, err := timeago.Parse(tc.date, "justNow")
32
33
			if err != nil {
34
				test.Errorf("Error must be nil, but got %v instead", err)
35
			}
36
37
			if res != "Just now" {
38
				test.Errorf("Result must be %q, but got %s instead", "Just now", res)
39
			}
40
		})
41
	}
42
}
43