Skip to content

Commit d7b942c

Browse files
committed
Add additional news unit tests
1 parent 704188a commit d7b942c

File tree

3 files changed

+1673
-0
lines changed

3 files changed

+1673
-0
lines changed

src/TibiaNewsV3_test.go

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,43 @@ func TestNewsById(t *testing.T) {
2626
assert.Equal("A number of issues related to the 25 years activities have been fixed, including the following: Dragon pinatas that were stuck in the inbox have been changed into dragon pinata kits. The wind-up loco can now be taken even after defeating Lord Retro. The baby seals can now be painted even when the quest The Ice Islands is active. The weight of wallpapers and fairy lights has been increased and their market category has been changed to decoration. A number of typos and map issues have been fixed as well.", newsArticleJson.News.Content)
2727
assert.Equal("A number of issues related to the 25 years activities have been fixed, including the following: Dragon pinatas that were stuck in the inbox have been changed into dragon pinata kits. The wind-up loco can now be taken even after defeating Lord Retro. The baby seals can now be painted even when the quest The Ice Islands is active. The weight of wallpapers and fairy lights has been increased and their market category has been changed to decoration. A number of typos and map issues have been fixed as well.", newsArticleJson.News.ContentHTML)
2828
}
29+
30+
func TestNews6512(t *testing.T) {
31+
data, err := ioutil.ReadFile("../testdata/news/archive/6512.html")
32+
if err != nil {
33+
t.Errorf("File reading error: %s", err)
34+
return
35+
}
36+
37+
newsArticleJson := TibiaNewsV3Impl(6512, "https://www.tibia.com/news/?subtopic=newsarchive&id=6512", string(data))
38+
assert := assert.New(t)
39+
40+
assert.Equal(6512, newsArticleJson.News.ID)
41+
assert.Equal("2022-01-04", newsArticleJson.News.Date)
42+
assert.Equal("", newsArticleJson.News.Title)
43+
assert.Equal("community", newsArticleJson.News.Category)
44+
assert.Equal("ticker", newsArticleJson.News.Type)
45+
assert.Equal("https://www.tibia.com/news/?subtopic=newsarchive&id=6512", newsArticleJson.News.TibiaURL)
46+
assert.Equal("TibiaData.com has some news to share! First of all, they invite you to participate in their Discord Server. Further, they are now present on GitHub. They are working on their v3, which is still in beta. If you are interested in such things, head on over there to see what is cooking.", newsArticleJson.News.Content)
47+
assert.Equal("<a href=\"https://tibiadata.com\" target=\"_blank\" rel=\"noopener noreferrer\" rel=\"noopener\">TibiaData.com</a> has some news to share! First of all, they invite you to participate in their <a href=\"https://tibiadata.com/2021/07/join-tibiadata-on-discord/\" target=\"_blank\" rel=\"noopener noreferrer\" rel=\"noopener\">Discord Server</a>. Further, they are now present on <a href=\"https://tibiadata.com/2021/12/tibiadata-has-gone-open-source/\" target=\"_blank\" rel=\"noopener noreferrer\" rel=\"noopener\">GitHub</a>. They are working on their <a href=\"https://tibiadata.com/doc-api-v3/v3-beta/\" target=\"_blank\" rel=\"noopener noreferrer\" rel=\"noopener\">v3</a>, which is still in beta. If you are interested in such things, head on over there to see what is cooking.", newsArticleJson.News.ContentHTML)
48+
}
49+
50+
func TestNews6481(t *testing.T) {
51+
data, err := ioutil.ReadFile("../testdata/news/archive/6481.html")
52+
if err != nil {
53+
t.Errorf("File reading error: %s", err)
54+
return
55+
}
56+
57+
newsArticleJson := TibiaNewsV3Impl(6481, "https://www.tibia.com/news/?subtopic=newsarchive&id=6481", string(data))
58+
assert := assert.New(t)
59+
60+
assert.Equal(6481, newsArticleJson.News.ID)
61+
assert.Equal("2021-12-22", newsArticleJson.News.Date)
62+
assert.Equal("New Mounts", newsArticleJson.News.Title)
63+
assert.Equal("development", newsArticleJson.News.Category)
64+
assert.Equal("", newsArticleJson.News.Type)
65+
assert.Equal("https://www.tibia.com/news/?subtopic=newsarchive&id=6481", newsArticleJson.News.TibiaURL)
66+
assert.Equal("New mounts have been added to the Store today!\nThe origins of the Emerald Raven, Mystic Raven, and Radiant Raven are shrouded in darkness, as no written record nor tale told by even the most knowing storytellers mentions but a trace of them. Superstition surrounds them, as some see these gigantic birds as an echo of a long forgotten past, while others believe them to herald hitherto unknown events. What is clear is that they are highly intelligent beings which make great companions if they deem somebody worthy.\n\nClick on image to enlarge.\n\nOnce bought, your character can use the mount ingame anytime, no matter if you are a free account or a Premium account.\nGet yourself a corvid companion!Your Community Managers ", newsArticleJson.News.Content)
67+
assert.Equal("<p>New mounts have been added to the Store today!</p>\n<p>The origins of the <strong>Emerald Raven</strong>, <strong>Mystic Raven</strong>, and <strong>Radiant Raven</strong> are shrouded in darkness, as no written record nor tale told by even the most knowing storytellers mentions but a trace of them. Superstition surrounds them, as some see these gigantic birds as an echo of a long forgotten past, while others believe them to herald hitherto unknown events. What is clear is that they are highly intelligent beings which make great companions if they deem somebody worthy.</p>\n<figure><center><img style=\"cursor: pointer;\" src=\"https://static.tibia.com/images/news/emeraldraven_small.jpg\" onclick=\"ImageInNewWindow(&#39;https://static.tibia.com/images/news/emeraldraven.jpg&#39;)\"/></center>\n<figcaption><center><em>Click on image to enlarge.</em></center></figcaption>\n</figure>\n<p>Once bought, your character can use the mount ingame anytime, no matter if you are a free account or a Premium account.</p>\n<p>Get yourself a corvid companion!<br/>Your Community Managers</p> ", newsArticleJson.News.ContentHTML)
68+
}

0 commit comments

Comments
 (0)