Koha Test Wiki MW Canasta on Koha Portainer
Test major Koha Wiki changes or bug fixes here without fear of breaking the production wiki.
For the current Koha Wiki, visit https://wiki.koha-community.org .Module:Anchor/testcases
Jump to navigation
Jump to search
Documentation for this module may be created at Module:Anchor/testcases/doc
-- Unit tests for [[Module:Anchor]]. Click talk page to run tests.
local anchor = require('Module:Anchor') -- the module to be tested
local ScribuntoUnit = require('Module:ScribuntoUnit')
local suite = ScribuntoUnit:new()
function suite:testmain()
self:assertResultEquals('<span id="foo"></span>', '{{#invoke:Anchor|main|foo}}')
self:assertResultEquals('<span id="foo"></span><span id="bar"></span>', '{{#invoke:Anchor|main|foo|bar}}')
self:assertResultEquals('<span id="foo"></span>', '{{#invoke:Anchor|main|3=foo}}')
self:assertResultEquals('<span id="foo"></span>', '{{#invoke:Anchor|main| foo }}')
self:assertResultEquals('<span id="foo"></span>', '{{#invoke:Anchor|main|25=foo}}')
end
function suite:test_main()
self:assertResultEquals('<span id="foo"></span>', anchor._main('foo'))
self:assertResultEquals('<span id="foo"></span><span id="bar"></span>', anchor._main('foo', 'bar'))
end
function suite:testAgainstTemplate()
self:assertSameResult('{{anchor|foo}}', '{{#invoke:Anchor|main|foo}}')
self:assertSameResult('{{anchor|foo|bar}}', '{{#invoke:Anchor|main|foo|bar}}')
self:assertSameResult('{{anchor|3=foo}}', '{{#invoke:Anchor|main|3=foo}}')
-- The below are not equal as the template only accepts up to 10 anchors.
self:assertFalse(self.frame:preprocess('{{anchor|25=foo}}') == self.frame:preprocess('{{#invoke:Anchor|main|25=foo}}'))
-- The below are not equal as the template doesn't trim whitespace from the anchor.
self:assertFalse(self.frame:preprocess('{{anchor| foo }}') == self.frame:preprocess('{{#invoke:Anchor|main| foo }}'))
end
return suite