Difference between revisions of "Module:Page/testcases"

From blackwiki
Jump to navigation Jump to search
blackwiki>TheDJ
m (TheDJ moved page Module:Page/tests to Module:Page/testcases without leaving a redirect: Let's keep the same name we use in Template namespaces.)
m (25 revisions imported)
 
(20 intermediate revisions by 2 users not shown)
Line 1: Line 1:
-- Unit tests for [[Module:Redirect]]. Click talk page to run tests.
+
-- Unit tests for [[Module:Page]]. Click talk page to run tests.
 
local p = require('Module:UnitTests')
 
local p = require('Module:UnitTests')
 
   
 
   
 
function p:test_main()
 
function p:test_main()
 +
    self:preprocess_equals('{{#invoke:Page|id}}', '38871376')
 
     self:preprocess_equals('{{#invoke:Page|id|}}', '38871376')
 
     self:preprocess_equals('{{#invoke:Page|id|}}', '38871376')
 
     self:preprocess_equals('{{#invoke:Page|id|WP:AFC}}', '3376456')
 
     self:preprocess_equals('{{#invoke:Page|id|WP:AFC}}', '3376456')
 +
    self:preprocess_equals_preprocess('{{#invoke:Page|id|[}}', '{{Error|Error: mw.title.new("[", "") failed}}')
 +
    self:preprocess_equals('{{#invoke:Page|id|makeTitle=yes|namespace=WP|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}}', 'Wikipedia:AFC')
 +
    self:preprocess_equals_preprocess('{{#invoke:Page|inNamespace|p1=Nonsense|WP:AFC}}', "{{Error|Error: bad argument #1 to 'inNamespace' (unrecognized namespace name 'Nonsense')}}")
 
     self:preprocess_equals('{{#invoke:Page|interwiki|WP:AFC}}', '')
 
     self:preprocess_equals('{{#invoke:Page|interwiki|WP:AFC}}', '')
 
     self:preprocess_equals('{{#invoke:Page|namespace|WP:AFC}}', '4')
 
     self:preprocess_equals('{{#invoke:Page|namespace|WP:AFC}}', '4')
Line 18: Line 24:
 
     self:preprocess_equals('{{#invoke:Page|canTalk|WP:AFC}}', 'true')
 
     self:preprocess_equals('{{#invoke:Page|canTalk|WP:AFC}}', 'true')
 
     self:preprocess_equals('{{#invoke:Page|exists|WP:AFC}}', 'true')
 
     self:preprocess_equals('{{#invoke:Page|exists|WP:AFC}}', 'true')
     self:preprocess_equals('{{#invoke:Page|fileExists|WP:AFC}}', 'false')
+
     self:preprocess_equals('{{#invoke:Page|fileExists|WP:AFC}}', '')
     self:preprocess_equals('{{#invoke:Page|isContentPage|WP:AFC}}', 'false')
+
     self:preprocess_equals('{{#invoke:Page|isContentPage|WP:AFC}}', '')
 +
    self:preprocess_equals('{{#invoke:Page|nsText|id=3376456}}', 'Wikipedia')
 +
    self:preprocess_equals('{{#invoke:Page|getContent|WP:AFC}}', '<pre>#REDIRECT [[Wikipedia:Articles for creation]]\n\n{{Redirect category shell|\n{{R to Wikipedia namespace}}\n{{R from shortcut}}\n}}</pre>')
 +
    self:preprocess_equals('{{#invoke:Page|getContent|WP:AFC|as=pre}}', '<pre>#REDIRECT [[Wikipedia:Articles for creation]]\n\n{{Redirect category shell|\n{{R to Wikipedia namespace}}\n{{R from shortcut}}\n}}</pre>')
 +
    self:preprocess_equals('{{#invoke:Page|getContent|WP:AFC|as=nowiki}}', '&#35;REDIRECT &#91;&#91;Wikipedia:Articles for creation&#93;&#93;\n&#10;&#123;&#123;Redirect category shell&#124;\n&#123;&#123;R to Wikipedia namespace&#125;&#125;\n&#123;&#123;R from shortcut&#125;&#125;\n&#125;&#125;')
 +
    self:preprocess_equals_preprocess('{{#invoke:Page|getContent|WP:AFC|as=expand}}', '\n#REDIRECT [[Wikipedia:Articles for creation]]\n\n{{Redirect category shell|\n{{R to Wikipedia namespace}}\n{{R from shortcut}}\n}}')
 +
end
  
end
 
 
return p
 
return p

Latest revision as of 08:20, 27 September 2020

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|WP:AFC}}', '3376456')
    self:preprocess_equals_preprocess('{{#invoke:Page|id|[}}', '{{Error|Error: mw.title.new("[", "") failed}}')
    self:preprocess_equals('{{#invoke:Page|id|makeTitle=yes|namespace=WP|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}}', 'Wikipedia:AFC')
    self:preprocess_equals_preprocess('{{#invoke:Page|inNamespace|p1=Nonsense|WP:AFC}}', "{{Error|Error: bad argument #1 to 'inNamespace' (unrecognized namespace name 'Nonsense')}}")
    self:preprocess_equals('{{#invoke:Page|interwiki|WP:AFC}}', '')
    self:preprocess_equals('{{#invoke:Page|namespace|WP:AFC}}', '4')
    self:preprocess_equals('{{#invoke:Page|fragment|WP:AFC}}', '')
    self:preprocess_equals('{{#invoke:Page|nsText|WP:AFC}}', 'Wikipedia')
    self:preprocess_equals('{{#invoke:Page|subjectNsText|WP:AFC}}', 'Wikipedia')
    self:preprocess_equals('{{#invoke:Page|text|WP:AFC}}', 'AFC')
    self:preprocess_equals('{{#invoke:Page|prefixedText|WP:AFC}}', 'Wikipedia:AFC')
    self:preprocess_equals('{{#invoke:Page|fullText|WP:AFC}}', 'Wikipedia:AFC')
    self:preprocess_equals('{{#invoke:Page|rootText|WP:AFC}}', 'AFC')
    self:preprocess_equals('{{#invoke:Page|baseText|WP:AFC}}', 'AFC')
    self:preprocess_equals('{{#invoke:Page|subpageText|WP:AFC}}', 'AFC')
    self:preprocess_equals('{{#invoke:Page|canTalk|WP:AFC}}', 'true')
    self:preprocess_equals('{{#invoke:Page|exists|WP:AFC}}', 'true')
    self:preprocess_equals('{{#invoke:Page|fileExists|WP:AFC}}', '')
    self:preprocess_equals('{{#invoke:Page|isContentPage|WP:AFC}}', '')
    self:preprocess_equals('{{#invoke:Page|nsText|id=3376456}}', 'Wikipedia')
    self:preprocess_equals('{{#invoke:Page|getContent|WP:AFC}}', '<pre>#REDIRECT [[Wikipedia:Articles for creation]]\n\n{{Redirect category shell|\n{{R to Wikipedia namespace}}\n{{R from shortcut}}\n}}</pre>')
    self:preprocess_equals('{{#invoke:Page|getContent|WP:AFC|as=pre}}', '<pre>#REDIRECT [[Wikipedia:Articles for creation]]\n\n{{Redirect category shell|\n{{R to Wikipedia namespace}}\n{{R from shortcut}}\n}}</pre>')
    self:preprocess_equals('{{#invoke:Page|getContent|WP:AFC|as=nowiki}}', '&#35;REDIRECT &#91;&#91;Wikipedia:Articles for creation&#93;&#93;\n&#10;&#123;&#123;Redirect category shell&#124;\n&#123;&#123;R to Wikipedia namespace&#125;&#125;\n&#123;&#123;R from shortcut&#125;&#125;\n&#125;&#125;')
    self:preprocess_equals_preprocess('{{#invoke:Page|getContent|WP:AFC|as=expand}}', '\n#REDIRECT [[Wikipedia:Articles for creation]]\n\n{{Redirect category shell|\n{{R to Wikipedia namespace}}\n{{R from shortcut}}\n}}')
end

return p