Jump to content

Module:Redirect/sandbox/testcases

From Wikipedia, the free encyclopedia
-- Unit tests for [[Module:Redirect]]. Click talk page to run tests.
local p = require('Module:UnitTests')
 
function p:test_main()
    self:preprocess_equals('{{#invoke:Redirect/sandbox|main|WP:AFC}}', 'Wikipedia:Articles for creation')
    self:preprocess_equals('{{#invoke:Redirect/sandbox|main|  WP:AFC  }}', 'Wikipedia:Articles for creation')
    self:preprocess_equals('{{#invoke:Redirect/sandbox|main|    }}', '')
    self:preprocess_equals('{{#invoke:Redirect/sandbox|main|[[WP:AFC]]|bracket=yes}}','[[Wikipedia:Articles for creation]]')
    self:preprocess_equals('{{#invoke:Redirect/sandbox|main|[[WP:AFC]]}}', 'Wikipedia:Articles for creation')
    self:preprocess_equals('{{#invoke:Redirect/sandbox|main|  [[WP:AFC]]  }}', 'Wikipedia:Articles for creation')
    self:preprocess_equals('{{#invoke:Redirect/sandbox|main|WP:AFC|bracket=yes}}', '[[Wikipedia:Articles for creation]]')
    self:preprocess_equals('{{#invoke:Redirect/sandbox|main|  WP:AFC  |bracket=yes}}', '[[Wikipedia:Articles for creation]]')
    
    self:preprocess_equals('{{#invoke:Redirect/sandbox|block|text=[[WP:AFC]] [[WP:AFD]]|nowiki=no}}', '[[Wikipedia:Articles for creation]] [[Wikipedia:Articles for deletion]]')
    self:preprocess_equals('{{#invoke:Redirect/sandbox|block|text=[[WP:AFC]] [[WP:AFD]]}}', '<pre><nowiki>[[Wikipedia:Articles for creation]] [[Wikipedia:Articles for deletion]]</nowiki></pre>')
    self:preprocess_equals('{{#invoke:Redirect/sandbox|block|Module talk:Redirect/sandbox/data}}', '<pre><nowiki>== Standard ==\n[[Wikipedia:Articles for creation]], [[Wikipedia:Deletion review]], and [[Wikipedia:Articles for deletion]]\n\n== Special characters that plague mw.ustring.gsub ==\n*[[Alien (franchise)]]\n*[[CO]]\n*[[Percent sign]]\n\n== Fun with pipes ==\n[[Wikipedia:Articles for deletion|spoil-funs]] [[wikt:test|test]]\n[[Space Cadet|  Going nowhere ]]\n[[Vacuum packing|   and redirected ]]</nowiki></pre>')
    self:preprocess_equals('{{#invoke:Redirect/sandbox|block|Module talk:Redirect/sandbox/data|WP:AFD}}', '<pre><nowiki>== Standard ==\n[[WP:AFC]], [[ WP:DRV ]], and [[Wikipedia:Articles for deletion]]\n\n== Special characters that plague mw.ustring.gsub ==\n*[[Alien (franchise)]]\n*[[CO]]\n*[[Percent sign]]\n\n== Fun with pipes ==\n[[Wikipedia:Articles for deletion|spoil-funs]] [[wikt:test|test]]\n[[Space Cadet|  Going nowhere ]]\n[[Vacuum packing|   and redirected ]]</nowiki></pre>')
    self:preprocess_equals('{{#invoke:Redirect/sandbox|block|  Module talk:Redirect/sandbox/data | WP:AFD }}', '<pre><nowiki>== Standard ==\n[[WP:AFC]], [[ WP:DRV ]], and [[Wikipedia:Articles for deletion]]\n\n== Special characters that plague mw.ustring.gsub ==\n*[[Alien (franchise)]]\n*[[CO]]\n*[[Percent sign]]\n\n== Fun with pipes ==\n[[Wikipedia:Articles for deletion|spoil-funs]] [[wikt:test|test]]\n[[Space Cadet|  Going nowhere ]]\n[[Vacuum packing|   and redirected ]]</nowiki></pre>')
    self:preprocess_equals('{{#invoke:Redirect/sandbox|block|  Module talk:Redirect/sandbox/data | WP:AFD | pipe=yes}}', '<pre><nowiki>== Standard ==\n[[WP:AFC]], [[ WP:DRV ]], and [[WP:AFD]]\n\n== Special characters that plague mw.ustring.gsub ==\n*[[Weyland-Yutani]]\n*[[Co.]]\n*[[%]]\n\n== Fun with pipes ==\n[[Wikipedia:Articles for deletion|spoil-funs]] [[wikt:test|test]]\n[[Space Cadet|  Going nowhere ]]\n[[Vacuum packing|   and redirected ]]</nowiki></pre>')
    self:preprocess_equals('{{#invoke:Redirect/sandbox|block|  Module talk:Redirect/sandbox/data | WP:AFD | pipe = no }}', '<pre><nowiki>== Standard ==\n[[WP:AFC]], [[ WP:DRV ]], and [[Wikipedia:Articles for deletion]]\n\n== Special characters that plague mw.ustring.gsub ==\n*[[Alien (franchise)]]\n*[[CO]]\n*[[Percent sign]]\n\n== Fun with pipes ==\n[[WP:AFD|spoil-funs]] [[wikt:test|test]]\n[[   Space cadet   |  Going nowhere ]]\n[[   Vacuum packed   |   and redirected ]]</nowiki></pre>')
    self:preprocess_equals('{{#invoke:Redirect/sandbox|block|  Module talk:Redirect/sandbox/data | WP:AFD | pipe = make }}', '<pre><nowiki>== Standard ==\n[[WP:AFC]], [[ WP:DRV ]], and [[Wikipedia:Articles for deletion|WP:AFD]]\n\n== Special characters that plague mw.ustring.gsub ==\n*[[Alien (franchise)|Weyland-Yutani]]\n*[[CO|Co.]]\n*[[Percent sign|%]]\n\n== Fun with pipes ==\n[[Wikipedia:Articles for deletion|spoil-funs]] [[wikt:test|test]]\n[[Space Cadet|  Going nowhere ]]\n[[Vacuum packing|   and redirected ]]</nowiki></pre>')
end
return p