-- 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