-
Notifications
You must be signed in to change notification settings - Fork 0
/
item_test.go
65 lines (56 loc) · 1.31 KB
/
item_test.go
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
package sengkala
import (
"fmt"
"sengkala/data"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
)
type (
RandomizerMock struct {
mock.Mock
}
expected struct {
expectedYear int
expectedSengkala string
expectedMeaning map[string]string
}
)
var testItemData = map[int]expected{
1984: {
expectedYear: 1984,
expectedSengkala: "Udaka Tekèk Wilasita Pamasé",
expectedMeaning: map[string]string{
"Udaka": "air",
"Tekèk": "tokek",
"Wilasita": "liang, liang kumbang",
"Pamasé": "raja",
},
},
2020: {
expectedYear: 2020,
expectedSengkala: "Gegana Sikara Gegana Sikara",
expectedMeaning: map[string]string{
"Gegana": "angkasa, langit",
"Sikara": "pengacauan, tangan, campur tangan.",
},
},
}
func (m *RandomizerMock) GetRandom(maxNum int) int {
return 2
}
func TestItem(t *testing.T) {
d := dictionary{
watak: data.Watak,
meaning: data.Meaning,
Randomizer: new(RandomizerMock),
}
for year, expected := range testItemData {
t.Run(fmt.Sprintf("item_%d", year), func(t *testing.T) {
item := newItem(year, d)
assert.Equal(t, expected.expectedYear, item.GetYear())
assert.Equal(t, expected.expectedSengkala, item.GetSengkala())
assert.Equal(t, expected.expectedMeaning, item.GetMeaning())
})
}
}