✨ 初始提交:月读第三方书源插件集合
每个书源一个独立插件目录,含微信读书公众号订阅、书架导入等完整功能。 Co-authored-by: Copilot <[email protected]>
This commit is contained in:
commit
77c37bc89a
27 files changed
+4305
No files matched your search
@@ -0,0 +1,42 @@
|
||||
--[[--
|
||||
豆瓣设置开关必须重绘当前桌面,不能只写配置后留着旧的开关状态。
|
||||
|
||||
@module tests.moonsource_douban.setting_spec
|
||||
--]]
|
||||
local Assert = require("support.assert")
|
||||
local cfg, saved, refreshed = {}, 0, 0
|
||||
package.preload["utils.settings"] = function()
|
||||
return {
|
||||
getSource = function() return cfg end,
|
||||
saveSource = function() saved = saved + 1 end,
|
||||
get = function() return {} end,
|
||||
}
|
||||
end
|
||||
package.preload["moonsource_douban.client"] = function() return { loggedIn = function() return false end } end
|
||||
package.preload["ui.themes.widgets.row"] = function() return { widget = function(opts) return opts end } end
|
||||
local Setting = require("moonsource_douban.setting")
|
||||
local plugin = { desktop = { updateView = function() refreshed = refreshed + 1 end } }
|
||||
local function find(title)
|
||||
for _idx, factory in ipairs(Setting.rows(plugin)) do
|
||||
local row = factory(540)
|
||||
if row.title == title then return row end
|
||||
end
|
||||
error("setting row missing: " .. title)
|
||||
end
|
||||
local row = find("显示段评")
|
||||
Assert.eq(row.status, "关")
|
||||
row.callback()
|
||||
Assert.is_true(cfg.show_paragraph_reviews)
|
||||
Assert.eq(refreshed, 1)
|
||||
row = find("显示段评")
|
||||
Assert.eq(row.status, "开")
|
||||
row.callback()
|
||||
Assert.eq(cfg.show_paragraph_reviews, false)
|
||||
Assert.eq(refreshed, 2)
|
||||
row = find("使用自定义分组代替分类")
|
||||
Assert.eq(row.status, "开")
|
||||
row.callback()
|
||||
Assert.eq(cfg.category_as_group, false)
|
||||
Assert.eq(refreshed, 3)
|
||||
Assert.eq(find("使用自定义分组代替分类").status, "关")
|
||||
Assert.eq(saved, 3)
|
||||
Reference in new issue
Block a user