Module:Urltowiki/testcases: Difference between revisions

Content deleted Content added
m Wugapodes moved page Module:UrlToWiki/testcases to Module:Urltowiki/testcases without leaving a redirect: Per requested move Template_talk:Urltowiki#Requested_move_30_October_2019
Clean up for module rename
 
Line 1:
-- Unit tests for [[Module:UrlToWikiUrltowiki]]. Click talk page to run tests.
local p = require('Module:UnitTests')
 
function p:test_simple()
self:preprocess_equals_many('{{#invoke:UrlToWikiUrltowiki/sandbox|urlToWiki|', '}}', {
{'https://en.wikipedia.org/wiki/Banana', '[[Banana]]'},
{'https://en.wikipedia.org/wiki/English_language', '[[English language]]'},
Line 12:
 
function p:test_index_php()
self:preprocess_equals_many('{{#invoke:UrlToWikiUrltowiki/sandbox|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]]'},
Line 21:
 
function p:test_url_parameter()
self:preprocess_equals_many('{{#invoke:UrlToWikiUrltowiki/sandbox|urlToWiki|', '}}', {
{'url=https://en.wikipedia.org/w/index.php?title=Banana', '[[Banana]]'},
{'url=https://en.wikipedia.org/w/index.php?title=English_language', '[[English language]]'},
Line 30:
 
function p:test_partial_urls()
self:preprocess_equals_many('{{#invoke:UrlToWikiUrltowiki/sandbox|urlToWiki|', '}}', {
{'Banana', '[[Banana]]'},
{'English_language', '[[English language]]'},
Line 39:
 
function p:test_fragments()
self:preprocess_equals_many('{{#invoke:UrlToWikiUrltowiki/sandbox|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]]'},
Line 59:
 
function p:test_random_sites()
self:preprocess_equals_many('{{#invoke:UrlToWikiUrltowiki/sandbox|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'},
Line 67:
 
function p:test_actions()
self:preprocess_equals_many('{{#invoke:UrlToWikiUrltowiki/sandbox|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]]'},
Line 75:
 
function p:test_interwikis()
self:preprocess_equals_many('{{#invoke:UrlToWikiUrltowiki/sandbox|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]]'},
Line 84:
 
function p:test_colon_trick()
self:preprocess_equals_many('{{#invoke:UrlToWikiUrltowiki/sandbox|urlToWiki|', '}}', {
{'https://en.wikipedia.org/wiki/Category:Wikipedians', '[[:Category:Wikipedians]]'},
{'https://en.wikipedia.org/wiki/File:Example.png', '[[:File:Example.png]]'},
Line 95:
 
function p:test_no_link()
self:preprocess_equals_many('{{#invoke:UrlToWikiUrltowiki/sandbox|urlToWiki|', '}}', {
{'https://en.wikipedia.org/wiki/Banana|link=no', 'Banana'},
{'https://en.wikipedia.org/wiki/English_language|link=no', 'English language'},
Line 122:
 
function p:test_no_colon_trick()
self:preprocess_equals_many('{{#invoke:UrlToWikiUrltowiki/sandbox|urlToWiki|', '}}', {
{'https://en.wikipedia.org/wiki/Category:Wikipedians|colontrick=no', '[[Category:Wikipedians]]'},
{'https://en.wikipedia.org/wiki/File:Example.png|colontrick=no', '[[File:Example.png]]'},
Line 133:
 
function p:test_display()
self:preprocess_equals_many('{{#invoke:UrlToWikiUrltowiki/sandbox|urlToWiki|', '}}', {
{'https://en.wikipedia.org/wiki/Banana|display=Foo', '[[Banana|Foo]]'},
{'https://en.wikipedia.org/wiki/English_language|display=Foo', '[[English language|Foo]]'},
Line 165:
 
function p:test_display_no_colon_trick()
self:preprocess_equals_many('{{#invoke:UrlToWikiUrltowiki/sandbox|urlToWiki|', '}}', {
{'https://en.wikipedia.org/wiki/Category:Wikipedians|colontrick=no|display=Foo', '[[Category:Wikipedians|Foo]]'},
{'https://en.wikipedia.org/wiki/File:Example.png|colontrick=no|display=Foo', '[[File:Example.png|Foo]]'},
Line 176:
 
function p:test_no_section()
self:preprocess_equals_many('{{#invoke:UrlToWikiUrltowiki/sandbox|urlToWiki|', '}}', {
{'https://en.wikipedia.org/wiki/Banana|section=no', '[[Banana]]'},
{'https://en.wikipedia.org/wiki/English_language|section=no', '[[English language]]'},
Line 208:
 
function p:test_funky_characters()
self:preprocess_equals_many('{{#invoke:UrlToWikiUrltowiki/sandbox|urlToWiki|', '}}', {
{'https://en.wikipedia.org/wiki/Wikipedia:Village_pump_%28policy%29/Archive_102#Using_.7B.7BComment.7D.7D_on_articles', '[[Wikipedia:Village pump (policy)/Archive 102#Using %7B%7BComment%7D%7D on articles]]'},
{'https://es.wikivoyage.org/wiki/Bogot%C3%A1#En_avi.C3.B3n', '[[voy:es:Bogotá#En avión]]'},
Line 216:
 
function p:test_identical_page_and_display()
self:preprocess_equals_many('{{#invoke:UrlToWikiUrltowiki/sandbox|urlToWiki|', '}}', {
{'https://en.wikipedia.org/wiki/Banana|Banana', '[[Banana]]'},
{'https://en.wikipedia.org/wiki/Banana|banana', '[[banana]]'},