🚚 (split): 从月读拆出独立仓库,沿用原书源 id
Release / release (push) Successful in 12s

This commit is contained in:
Garfield committed 2026-11-27 08:08:01 +08:00
commit 99d94c0d51
36 files changed
+4061

No files matched your search

+57
View File
@@ -0,0 +1,57 @@
--[[--
拷贝漫画书城浏览:榜单与题材共用一套 chip,题材节点走 /comics 且不高亮周期 / 受众。
@module tests.moonsource_copymanga.browse_spec
--]]
local Assert = require("support.assert")
local fake_client = {}
local calls = {}
local function stub(name, factory)
package.preload[name] = factory
package.loaded[name] = nil
end
stub("utils.settings", function()
return { getSource = function() return { token = "tok" } end, saveSource = function() end }
end)
stub("moonsource_copymanga.client", function()
return { new = function() return fake_client end, headers = function() return {} end,
normalizeBaseUrl = function(url) return url end }
end)
local function page(name)
return { results = { list = { { path_word = name, name = name } } } }
end
fake_client.rankAsync = function(_, period, audience, offset, cb)
calls[#calls + 1] = "rank:" .. period .. ":" .. tostring(audience) .. ":" .. offset
cb(page("r"))
return { cancel = function() end }
end
fake_client.themeAsync = function(_, theme, offset, cb)
calls[#calls + 1] = "theme:" .. theme .. ":" .. offset
cb(page("t"))
return { cancel = function() end }
end
package.loaded["moonsource_copymanga.source"] = nil
local src = require("moonsource_copymanga.source").new()
local res
src:browseAsync({ node = "theme:rexue", limit = 1 }, function(r) res = r end)
Assert.eq(calls[1], "theme:rexue:0")
Assert.eq(res.data[1].stable_id, "t")
Assert.len(res.groups, 2)
Assert.eq(res.groups[2].active, "theme:rexue")
Assert.is_nil(res.groups[1].active)
src:browseAsync({ limit = 1 }, function(r) res = r end)
Assert.eq(calls[2], "rank:day:nil:0")
Assert.eq(res.groups[1].active, "day:all")
Assert.eq(res.groups[2].active, "day:all")
src:browseAsync({ node = "web:ordering=-popular&theme=rexue", limit = 1 }, function(r) res = r end)
Assert.eq(calls[3], "rank:day:nil:0", "切回 App 后不能把官网节点当榜单周期")
Assert.eq(res.groups[1].active, "day:all")