--[[--
番茄网页榜单解析离线用例:内嵌状态(含裸 undefined)、PUA 书名解码、封面。
@module tests.moonsource_fanqie.rank_spec
--]]
---@diagnostic disable: undefined-field, missing-fields, redundant-parameter, missing-parameter, inject-field, assign-type-mismatch, param-type-mismatch, cast-type-mismatch, return-type-mismatch, cast-local-type
local Assert = require("support.assert")
local JSONStub = require("support.json_stub")
package.preload["json"] = function()
return { decode = JSONStub.decode, encode = JSONStub.encode }
end
package.loaded["moonsource_fanqie.rank"] = nil
local Rank = require("moonsource_fanqie.rank")
local html = ''
do
local rank = Rank.state(html)
Assert.eq(rank.rankCategoryTypeList.male[1].name, "西方奇幻")
local books = Rank.books(rank, "fanqie")
Assert.len(books, 1)
Assert.eq(books[1].stable_id, "7654593151348247614")
Assert.matches(books[1].title, "在诡异$")
Assert.eq(books[1].intro, "在简介")
Assert.matches(books[1].cover, "novel%-pic/abc")
Assert.is_nil(Rank.state("人机验证"))
end