-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathTibiaHighscores_test.go
More file actions
90 lines (71 loc) · 3.01 KB
/
Copy pathTibiaHighscores_test.go
File metadata and controls
90 lines (71 loc) · 3.01 KB
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
package main
import (
"io"
"testing"
"github.com/stretchr/testify/assert"
"github.com/tibiadata/tibiadata-api-go/src/static"
"github.com/tibiadata/tibiadata-api-go/src/validation"
)
func TestHighscoresAll(t *testing.T) {
file, err := static.TestFiles.Open("testdata/highscores/all.html")
if err != nil {
t.Fatalf("file opening error: %s", err)
}
defer file.Close()
data, err := io.ReadAll(file)
if err != nil {
t.Fatalf("File reading error: %s", err)
}
highscoresJson, err := TibiaHighscoresImpl("", validation.HighScoreExperience, "all", 1, string(data), "https://www.tibia.com/community/?subtopic=highscores&world=&category=experience&profession=all¤tpage=1")
if err != nil {
t.Fatal(err)
}
assert := assert.New(t)
information := highscoresJson.Information
assert.Equal("https://www.tibia.com/community/?subtopic=highscores&world=&category=experience&profession=all¤tpage=1", information.TibiaURLs[0])
assert.Empty(highscoresJson.Highscores.World)
assert.Equal("experience", highscoresJson.Highscores.Category)
assert.Equal("all", highscoresJson.Highscores.Vocation)
assert.Equal(12, highscoresJson.Highscores.HighscoreAge)
assert.Equal(50, len(highscoresJson.Highscores.HighscoreList))
assert.Equal(1, highscoresJson.Highscores.HighscorePage.CurrentPage)
assert.Equal(20, highscoresJson.Highscores.HighscorePage.TotalPages)
assert.Equal(1000, highscoresJson.Highscores.HighscorePage.TotalHighscores)
firstHighscore := highscoresJson.Highscores.HighscoreList[0]
assert.Equal(1, firstHighscore.Rank)
assert.Equal("Goraca", firstHighscore.Name)
assert.Equal("Master Sorcerer", firstHighscore.Vocation)
assert.Equal("Bona", firstHighscore.World)
assert.Equal(2197, firstHighscore.Level)
assert.Equal(176271164607, firstHighscore.Value)
assert.Empty(firstHighscore.Title)
lastHighscore := highscoresJson.Highscores.HighscoreList[49]
assert.Equal(50, lastHighscore.Rank)
assert.Equal("Wujo Daro", lastHighscore.Name)
assert.Equal("Elite Knight", lastHighscore.Vocation)
assert.Equal("Refugia", lastHighscore.World)
assert.Equal(1701, lastHighscore.Level)
assert.Equal(81816135617, lastHighscore.Value)
assert.Empty(lastHighscore.Title)
}
func TestHighscoresLoyalty(t *testing.T) {
file, err := static.TestFiles.Open("testdata/highscores/loyalty.html")
if err != nil {
t.Fatalf("file opening error: %s", err)
}
defer file.Close()
data, err := io.ReadAll(file)
if err != nil {
t.Fatalf("File reading error: %s", err)
}
highscoresJson, err := TibiaHighscoresImpl("Vunira", validation.HighScoreLoyaltypoints, "druids", 4, string(data), "")
if err != nil {
t.Fatal(err)
}
assert := assert.New(t)
assert.Equal("Vunira", highscoresJson.Highscores.World)
assert.Equal("loyaltypoints", highscoresJson.Highscores.Category)
assert.Equal("druids", highscoresJson.Highscores.Vocation)
assert.Equal(12, highscoresJson.Highscores.HighscoreAge)
assert.Equal(50, len(highscoresJson.Highscores.HighscoreList))
}