Module:Page/testcases

< Module:Page
Revision as of 12:43, 20 August 2018 by imported>Petr Matas (update)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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}}', '&#35;REDIRECT &#91;&#91;Stiles.casa Wiki:Articles for creation&#93;&#93;\n&#10;&#123;&#123;Redirect category shell&#124;\n&#123;&#123;R to Stiles.casa Wiki namespace&#125;&#125;\n&#123;&#123;R from shortcut&#125;&#125;\n&#125;&#125;')
    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