Module:Page/testcases
Jump to navigation
Jump to search
Documentation for this module may be created at Module:Page/testcases/doc
-- Unit tests for [[Module:Page]]. Click talk page to run tests.
local p = require('Module:UnitTests')
function p:test_main()
self:preprocess_equals('{{#invoke:Page|id}}', '38871376')
self:preprocess_equals('{{#invoke:Page|id|}}', '38871376')
self:preprocess_equals('{{#invoke:Page|id|SW:AFC}}', '3376456')
self:preprocess_equals_preprocess('{{#invoke:Page|id|[}}', '{{Error|Error: mw.title.new("[", "") failed}}')
self:preprocess_equals('{{#invoke:Page|id|makeTitle=yes|namespace=SW|AFC}}', '3376456')
self:preprocess_equals_preprocess('{{#invoke:Page|id|makeTitle=yes|namespace=Nonsense|AFC}}', "{{Error|Error: bad argument #1 to 'makeTitle' (unrecognized namespace name 'Nonsense')}}")
self:preprocess_equals('{{#invoke:Page|prefixedText|id=3376456}}', 'Stiles.casa Wiki:AFC')
self:preprocess_equals_preprocess('{{#invoke:Page|inNamespace|p1=Nonsense|SW:AFC}}', "{{Error|Error: bad argument #1 to 'inNamespace' (unrecognized namespace name 'Nonsense')}}")
self:preprocess_equals('{{#invoke:Page|interwiki|SW:AFC}}', '')
self:preprocess_equals('{{#invoke:Page|namespace|SW:AFC}}', '4')
self:preprocess_equals('{{#invoke:Page|fragment|SW:AFC}}', '')
self:preprocess_equals('{{#invoke:Page|nsText|SW:AFC}}', 'Stiles.casa Wiki')
self:preprocess_equals('{{#invoke:Page|subjectNsText|SW:AFC}}', 'Stiles.casa Wiki')
self:preprocess_equals('{{#invoke:Page|text|SW:AFC}}', 'AFC')
self:preprocess_equals('{{#invoke:Page|prefixedText|SW:AFC}}', 'Stiles.casa Wiki:AFC')
self:preprocess_equals('{{#invoke:Page|fullText|SW:AFC}}', 'Stiles.casa Wiki:AFC')
self:preprocess_equals('{{#invoke:Page|rootText|SW:AFC}}', 'AFC')
self:preprocess_equals('{{#invoke:Page|baseText|SW:AFC}}', 'AFC')
self:preprocess_equals('{{#invoke:Page|subpageText|SW:AFC}}', 'AFC')
self:preprocess_equals('{{#invoke:Page|canTalk|SW:AFC}}', 'true')
self:preprocess_equals('{{#invoke:Page|exists|SW:AFC}}', 'true')
self:preprocess_equals('{{#invoke:Page|fileExists|SW:AFC}}', '')
self:preprocess_equals('{{#invoke:Page|isContentPage|SW:AFC}}', '')
self:preprocess_equals('{{#invoke:Page|nsText|id=3376456}}', 'Stiles.casa Wiki')
self:preprocess_equals('{{#invoke:Page|getContent|SW:AFC}}', '<pre>#REDIRECT [[Stiles.casa Wiki:Articles for creation]]\n\n{{Redirect category shell|\n{{R to Stiles.casa Wiki namespace}}\n{{R from shortcut}}\n}}</pre>')
self:preprocess_equals('{{#invoke:Page|getContent|SW:AFC|as=pre}}', '<pre>#REDIRECT [[Stiles.casa Wiki:Articles for creation]]\n\n{{Redirect category shell|\n{{R to Stiles.casa Wiki namespace}}\n{{R from shortcut}}\n}}</pre>')
self:preprocess_equals('{{#invoke:Page|getContent|SW:AFC|as=nowiki}}', '#REDIRECT [[Stiles.casa Wiki:Articles for creation]]\n {{Redirect category shell|\n{{R to Stiles.casa Wiki namespace}}\n{{R from shortcut}}\n}}')
self:preprocess_equals_preprocess('{{#invoke:Page|getContent|SW:AFC|as=expand}}', '\n#REDIRECT [[Stiles.casa Wiki:Articles for creation]]\n\n{{Redirect category shell|\n{{R to Stiles.casa Wiki namespace}}\n{{R from shortcut}}\n}}')
end
return p