-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAnime_test.go
68 lines (51 loc) · 1.54 KB
/
Anime_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
package shoboi
import (
"strings"
"testing"
"github.com/akyoto/assert"
)
func TestEpisodesWithTitles(t *testing.T) {
anime, err := GetAnime("663")
assert.Nil(t, err)
episodes := anime.Episodes()
assert.Equal(t, len(episodes), 24)
for _, episode := range episodes {
assert.NotEqual(t, episode.Number, 0)
assert.NotEqual(t, episode.TitleJapanese, "")
airingDate := episode.AiringDate
assert.NotEqual(t, airingDate.Start, "")
assert.True(t, strings.HasPrefix(airingDate.Start, "2006"))
assert.NotEqual(t, airingDate.End, "")
assert.True(t, strings.HasPrefix(airingDate.End, "2006"))
}
}
func TestEpisodesWithoutTitles(t *testing.T) {
anime, err := GetAnime("4689")
assert.Nil(t, err)
episodes := anime.Episodes()
assert.Equal(t, len(episodes), 12)
for _, episode := range episodes {
assert.NotEqual(t, episode.Number, 0)
airingDate := episode.AiringDate
assert.NotEqual(t, airingDate.Start, "")
assert.True(t, strings.HasPrefix(airingDate.Start, "2017"))
assert.NotEqual(t, airingDate.End, "")
assert.True(t, strings.HasPrefix(airingDate.End, "2017"))
}
}
func TestEpisodesStartingWithZero(t *testing.T) {
anime, err := GetAnime("3500")
assert.Nil(t, err)
episodes := anime.Episodes()
assert.Equal(t, len(episodes), 13)
assert.Equal(t, episodes[0].Number, 0)
for _, episode := range episodes {
assert.True(t, episode.Number <= 12)
assert.NotEqual(t, episode.TitleJapanese, "")
}
}
func TestNonExistingAnime(t *testing.T) {
anime, err := GetAnime("999999999999")
assert.Nil(t, anime)
assert.NotNil(t, err)
}