FANDOM


-- <nowiki>
local existsmod = require("Dev:Existsmod").module_exists
local ScribuntoUnit = require("Module:ScribuntoUnit")
local suite = ScribuntoUnit:new()
 
function suite:test_no_prefix()
    self:assertTrue(existsmod("If", true, false))
    self:assertFalse(existsmod("!If", true, false))
end
 
function suite:test_module_prefix()
    self:assertTrue(existsmod("Module:If", true, false))
    self:assertFalse(existsmod("Module:!If", true, false))
end
 
function suite:test_dev_prefix()
    self:assertTrue(existsmod("Dev:If", true, false))
    self:assertFalse(existsmod("Dev:!If", true, false))
end
 
function suite:test_ifexist_parity()
    self:assertSameResult("{{#ifexist:}}", "{{#invoke:Existsmod|main}}")
    self:assertSameResult("{{#ifexist:||missing}}", "{{#invoke:Existsmod|main|||missing}}")
    self:assertSameResult("{{#ifexist:|found}}", "{{#invoke:Existsmod|main||found}}")
    self:assertSameResult("{{#ifexist:|found|missing}}", "{{#invoke:Existsmod|main||found|missing}}")
    self:assertSameResult("{{#ifexist:Module:If}}", "{{#invoke:Existsmod|main|Module:If}}")
    self:assertSameResult("{{#ifexist:Module:If||missing}}", "{{#invoke:Existsmod|main|Module:If||missing}}")
    self:assertSameResult("{{#ifexist:Module:If|found}}", "{{#invoke:Existsmod|main|Module:If|found}}")
    self:assertSameResult("{{#ifexist:Module:If|found|missing}}", "{{#invoke:Existsmod|main|Module:If|found|missing}}")
    self:assertSameResult("{{#ifexist:Module:!If}}", "{{#invoke:Existsmod|main|Module:!If}}")
    self:assertSameResult("{{#ifexist:Module:!If||missing}}", "{{#invoke:Existsmod|main|Module:!If||missing}}")
    self:assertSameResult("{{#ifexist:Module:!If|found}}", "{{#invoke:Existsmod|main|Module:!If|found}}")
    self:assertSameResult("{{#ifexist:Module:!If|found|missing}}", "{{#invoke:Existsmod|main|Module:!If|found|missing}}")
end
 
function suite:test_path_normalization()
    self:assertTrue(existsmod("if", true, false))
    self:assertFalse(existsmod("iF", true, false))
    self:assertTrue(existsmod("If", true, false))
 
    self:assertTrue(existsmod("module:if", true, false))
    self:assertFalse(existsmod("module:iF", true, false))
    self:assertTrue(existsmod("module:If", true, false))
    self:assertTrue(existsmod("modulE:if", true, false))
    self:assertTrue(existsmod("Module:if", true, false))
 
    self:assertTrue(existsmod("dev:if", true, false))
    self:assertFalse(existsmod("dev:iF", true, false))
    self:assertTrue(existsmod("dev:If", true, false))
    self:assertTrue(existsmod("deV:if", true, false))
    self:assertTrue(existsmod("Dev:if", true, false))
end
 
function suite:test_spaces_in_name()
    self:assertTrue(existsmod("User error", true, false))
end
 
function suite:test_module_is_redirect()
    self:assertTrue(existsmod("Existsmod/redirect test", true, false))
end
 
function suite:test_module_is_subpage()
    self:assertTrue(existsmod("Sandbox/DarthKitty", true, false))
end
 
return suite

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.