Module:Urltowiki/testcases
Appearance
![]() | This is the test cases page for the module Module:Urltowiki. Results of the test cases. |
-- 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
function p:test_random_sites()
self:preprocess_equals_many('{{#invoke:UrlToWiki|urlToWiki|', '}}', {
{'http://www.theguardian.com/tv-and-radio/2013/sep/22/the-simpsons-secret-formula-maths-simon-singh', 'http://www.theguardian.com/tv-and-radio/2013/sep/22/the-simpsons-secret-formula-maths-simon-singh'},
{'1=http://www.youtube.com/watch?v=AxTiaInrLW4', 'http://www.youtube.com/watch?v=AxTiaInrLW4'},
{'http://www.ietf.org/rfc/rfc3092.txt', 'http://www.ietf.org/rfc/rfc3092.txt'},
})
end
function p:test_actions()
self:preprocess_equals_many('{{#invoke:UrlToWiki|urlToWiki|', '}}', {
{'1=https://en.wikipedia.org/w/index.php?title=Wikipedia%3AArticles_for_deletion&action=history', '[[Wikipedia:Articles for deletion]]'},
{'1=https://en.wikipedia.org/w/index.php?title=Wikipedia:Articles_for_deletion&offset=20121106111840&action=history', '[[Wikipedia:Articles for deletion]]'},
{'1=https://en.wikipedia.org/w/index.php?title=Wikipedia:Articles_for_deletion&action=edit', '[[Wikipedia:Articles for deletion]]'},
})
end
function p:test_interwikis()
self:preprocess_equals_many('{{#invoke:UrlToWiki|urlToWiki|', '}}', {
{'https://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual', '[[mw:Extension:Scribunto/Lua reference manual]]'},
{'https://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#Lua_language', '[[mw:Extension:Scribunto/Lua reference manual#Lua language]]'},
{'1=https://www.mediawiki.org/w/index.php?title=Extension:Scribunto/Lua_reference_manual#Lua_language', '[[mw:Extension:Scribunto/Lua reference manual#Lua language]]'},
{'https://meta.wikimedia.org/wiki/Translation_requests/WMF', '[[m:Translation requests/WMF]]'},
})
end
function p:test_colon_trick()
self:preprocess_equals_many('{{#invoke:UrlToWiki|urlToWiki|', '}}', {
{'https://en.wikipedia.org/wiki/Category:Wikipedians', '[[:Category:Wikipedians]]'},
{'https://en.wikipedia.org/wiki/File:Example.png', '[[:File:Example.png]]'},
{'https://en.wikipedia.org/wiki/Image:Example.png', '[[:Image:Example.png]]'},
{'https://en.wikipedia.org/wiki/Wikipedia_talk:Articles_for_deletion', '[[Wikipedia talk:Articles for deletion]]'},
{'https://es.wikipedia.org/wiki/Milord_%28tratamiento%29', '[[:es:Milord (tratamiento)]]'},
{'https://es.wikipedia.org/wiki/Wikipedia:Cartelera_de_acontecimientos', '[[:es:Wikipedia:Cartelera de acontecimientos]]'},
})
end
return p