-
Notifications
You must be signed in to change notification settings - Fork 2
/
move_test.go
73 lines (66 loc) · 1.72 KB
/
move_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
66
67
68
69
70
71
72
73
package pokemonbattlelib
import (
"encoding/json"
"fmt"
"math"
. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/extensions/table"
. "github.com/onsi/gomega"
)
var _ = Describe("Get move by ID", func() {
It("should get the correct move", func() {
m := GetMove(MovePound)
Expect(m.Name()).To(Equal("Pound"))
})
It("should panic when a move does not exist", func() {
Expect(func() {
GetMove(MoveId(math.MaxUint16))
}).To(Panic())
})
})
var _ = Describe("Move Marshalling and Unmarshalling", func() {
DescribeTable("should marshall and unmarshall moves",
func(m MoveId) {
move := GetMove(m)
b, err := json.Marshal(move)
Expect(err).To(Succeed())
var got Move
err = json.Unmarshal(b, &got)
Expect(err).To(Succeed())
Expect(got).To(BeEquivalentTo(*move))
},
Entry("Pound", MovePound),
Entry("Healing Wish", MoveHealingWish),
Entry("Water Gun", MoveWaterGun),
Entry("Whirlpool", MoveWhirlpool),
Entry("Aerial Ace", MoveAerialAce),
Entry("Ember", MoveEmber),
Entry("Lava Plume", MoveLavaPlume),
)
})
var _ = Describe("Move string representation", func() {
tests := []struct {
move Move
want string
}{
{
move: *GetMove(MoveShadowBall),
want: "Shadow Ball",
},
}
It("should show the correct string for moves", func() {
for _, tt := range tests {
Expect(fmt.Sprintf("%s", tt.move)).To(Equal(tt.want))
}
})
})
var _ = Describe("Move category", func() {
It("should show correct string for move category", func() {
Expect(MoveCategoryStatus.String()).To(Equal("Status"))
Expect(MoveCategoryPhysical.String()).To(Equal("Physical"))
Expect(MoveCategorySpecial.String()).To(Equal("Special"))
Expect(func() {
var _ = MoveCategory(99).String()
}).To(Panic())
})
})