spec/more_apps_spec.lua (1313 bytes)
1 local MoreApps = require("subread.more_apps") 2 3 describe("MoreApps", function() 4 it("gives each app a name, a line and an https address without parameters", function() 5 assert.is_true(#MoreApps.list > 1) 6 local seen = {} 7 for _, app in ipairs(MoreApps.list) do 8 assert.is_true(type(app.name) == "string" and app.name ~= "") 9 assert.is_true(type(app.line) == "string" and app.line ~= "") 10 -- No query and no fragment, so no tracking parameters. 11 assert.is_not_nil(app.url:match("^https://[^?#%s]+$")) 12 assert.is_nil(seen[app.url]) 13 seen[app.url] = true 14 end 15 end) 16 17 it("does not list the plugin itself", function() 18 for _, app in ipairs(MoreApps.list) do 19 assert.is_nil(app.url:find("subread.koplugin", 1, true)) 20 end 21 end) 22 23 it("ends with the list of all projects", function() 24 assert.equals("https://recentlywritten.com/projects.html", MoreApps.list[#MoreApps.list].url) 25 end) 26 27 it("shows the name, the line and the address of each app as text", function() 28 local text = MoreApps.text() 29 for _, app in ipairs(MoreApps.list) do 30 assert.is_not_nil(text:find(app.name .. "\n" .. app.line .. "\n" .. app.url, 1, true)) 31 end 32 end) 33 end)