Jump to content

Module:Urltowiki/testcases

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Mr. Stradivarius (talk | contribs) at 00:59, 22 September 2013 (that should be 1=). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
-- Unit tests for [[Module:UrlToWiki]]. Click talk page to run tests.
local p = require('Module:UnitTests')

function p:test_simple()
    self:preprocess_equals_many('{{#invoke:UrlToWiki|urlToWiki|', '}}', {
        {'https://en.wikipedia.org/wiki/Banana', '[[Banana]]'},
        {'https://en.wikipedia.org/wiki/English_language', '[[English language]]'},
        {'https://en.wikipedia.org/wiki/Module:UnitTests', '[[Module:UnitTests]]'},
        {'https://en.wikipedia.org/wiki/Wikipedia_talk:Articles_for_deletion', '[[Wikipedia talk:Articles for deletion]]'},
    })
end

function p:test_index_php()
    self:preprocess_equals_many('{{#invoke:UrlToWiki|urlToWiki|', '}}', {
        {'1=https://en.wikipedia.org/w/index.php?title=Banana', '[[Banana]]'},
        {'1=https://en.wikipedia.org/w/index.php?title=English_language', '[[English language]]'},
        {'1=https://en.wikipedia.org/w/index.php?title=Module:UnitTests', '[[Module:UnitTests]]'},
        {'1=https://en.wikipedia.org/w/index.php?title=Wikipedia_talk:Articles_for_deletion', '[[Wikipedia talk:Articles for deletion]]'},
    })
end

function p:test_partial_urls()
    self:preprocess_equals_many('{{#invoke:UrlToWiki|urlToWiki|', '}}', {
        {'Banana', '[[Banana]]'},
        {'English_language', '[[English language]]'},
        {'Module:UnitTests', '[[Module:UnitTests]]'},
        {'Wikipedia_talk:Articles_for_deletion', '[[Wikipedia talk:Articles for deletion]]'},
    })
end

function p:test_fragments()
    self:preprocess_equals_many('{{#invoke:UrlToWiki|urlToWiki|', '}}', {
        {'https://en.wikipedia.org/wiki/Banana#Etymology', '[[Banana#Etymology]]'},
        {'https://en.wikipedia.org/wiki/English_language#Classification_and_related_languages', '[[English language#Classification and related languages]]'},
        {'https://en.wikipedia.org/wiki/Module:UnitTests#preprocess_equals_many', '[[Module:UnitTests#preprocess equals many]]'},
        {'https://en.wikipedia.org/wiki/Wikipedia_talk:Articles_for_deletion#Foo_bar', '[[Wikipedia talk:Articles for deletion#Foo bar]]'},
        {'https://en.wikipedia.org/wiki/Wikipedia_talk:Articles_for_deletion/Archive_1#Proposed_reorganization', '[[Wikipedia talk:Articles for deletion/Archive 1#Proposed reorganization]]'},
        {'1=https://en.wikipedia.org/w/index.php?title=Banana#Etymology', '[[Banana#Etymology]]'},
        {'1=https://en.wikipedia.org/w/index.php?title=English_language#Classification_and_related_languages', '[[English language#Classification and related languages]]'},
        {'1=https://en.wikipedia.org/w/index.php?title=Module:UnitTests#preprocess_equals_many', '[[Module:UnitTests#preprocess equals many]]'},
        {'1=https://en.wikipedia.org/w/index.php?title=Wikipedia_talk:Articles_for_deletion#Foo_bar', '[[Wikipedia talk:Articles for deletion#Foo bar]]'},
        {'1=https://en.wikipedia.org/w/index.php?title=Wikipedia_talk:Articles_for_deletion/Archive_1#Proposed_reorganization', '[[Wikipedia talk:Articles for deletion/Archive 1#Proposed reorganization]]'},
        {'Banana#Etymology', '[[Banana#Etymology]]'},
        {'English_language#Classification_and_related_languages', '[[English language#Classification and related languages]]'},
        {'Module:UnitTests#preprocess_equals_many', '[[Module:UnitTests#preprocess equals many]]'},
        {'Wikipedia_talk:Articles_for_deletion#Foo_bar', '[[Wikipedia talk:Articles for deletion#Foo bar]]'},
        {'Wikipedia_talk:Articles_for_deletion/Archive_1#Proposed_reorganization', '[[Wikipedia talk:Articles for deletion/Archive 1#Proposed reorganization]]'},
    })
end

return p