Module:Webarchive/testcases
Appearance
![]() | This is the test cases page for the module Module:Webarchive. Results of the test cases. |
local p = require('Module:UnitTests')
function p:test_Usage_Examples()
self:preprocess_equals_many('{{#invoke:webarchive|webarchive', '}}', {
{'|url=https://web.archive.org/web/20160801000000/http://example.com |date=August 1, 2016', '[https://web.archive.org/web/20160801000000/http://example.com Archived] August 1, 2016, at the [[Wayback Machine]].[[Category:Webarchive template wayback links]]'},
{'|url=http://www.webcitation.org/5eWaHRbn4?url=http://www.example.com/ |date=12 February 2009', '[http://www.webcitation.org/5eWaHRbn4?url=http://www.example.com/ Archived] 12 February 2009 at [[WebCite]][[Category:Webarchive template webcite links]]'},
{'|url=http://www.webcitation.org/5eWaHRbn4?url=http://www.example.com/ |date=12 February 2009 |title=Page title', '[http://www.webcitation.org/5eWaHRbn4?url=http://www.example.com/ Page title] at [[WebCite]] (archived 12 February 2009)[[Category:Webarchive template webcite links]]'},
} )
end
function p:test_Template_Examples()
self:preprocess_equals_many('{{#invoke:webarchive|webarchive', '}}', {
{'|url=https://web.archive.org/web/20160801000000/http://example.com |date=August 1, 2016 |title=Page title',
'[https://web.archive.org/web/20160801000000/http://example.com Page title] at the [[Wayback Machine]] (archived August 1, 2016)[[Category:Webarchive template wayback links]]'},
{'|url=https://web.archive.org/web/20160801000000/http://example.com |date=August 1, 2016',
'[https://web.archive.org/web/20160801000000/http://example.com Archived] August 1, 2016, at the [[Wayback Machine]].[[Category:Webarchive template wayback links]]'},
{'|url=http://www.webcitation.org/5eWaHRbn4?url=http://www.example.com/',
'[http://www.webcitation.org/5eWaHRbn4?url=http://www.example.com/ Archived] 2009-02-12 at [[WebCite]][[Category:Webarchive template webcite links]]'},
{'|url=https://web.archive.org/web/20160801/http://example.com |title=Page title |date=August 1, 2016 |url2=https://web.archive.org/web/20160901/http://example.com |title2=Page2 title |date2=September 1, 2016',
'[https://web.archive.org/web/20160801/http://example.com Page title] at the [[Wayback Machine]] (archived August 1, 2016). Additional archives: [https://web.archive.org/web/20160901/http://example.com Page2 title].[[Category:Webarchive template wayback links]]'},
{'|url=https://web.archive.org/web/20160801/http://example.com |date=August 1, 2016 |url2=https://web.archive.org/web/20160901/http://example.com |date2=September 1, 2016',
'[https://web.archive.org/web/20160801/http://example.com Archived] August 1, 2016, at the [[Wayback Machine]]. Additional archives: [https://web.archive.org/web/20160901/http://example.com September 1, 2016].[[Category:Webarchive template wayback links]]'},
{'|url=https://web.archive.org/web/20160801/http://example.com |title=Page title |url2=https://web.archive.org/web/20160901/http://example.com |title2=Page2 title',
'[https://web.archive.org/web/20160801/http://example.com Page title] at the [[Wayback Machine]] (archived 2016-08-01). Additional archives: [https://web.archive.org/web/20160901/http://example.com Page2 title].[[Category:Webarchive template warnings]][[Category:Webarchive template wayback links]]'},
} )
end
function p:test_Permacc()
self:preprocess_equals_many('{{#invoke:webarchive|webarchive', '}}', {
{'|url=http://perma.cc/F9NT-22AK |date=2015-04-09', '[http://perma.cc/F9NT-22AK Archived] 2015-04-09 at [[Perma.cc]][[Category:Webarchive template other archives]]'},
{'|url=http://perma.cc/F9NT-22AK |date=2015-04-09 |title=Mike Pressler Biography', '[http://perma.cc/F9NT-22AK Mike Pressler Biography] at [[Perma.cc]] (archived 2015-04-09)[[Category:Webarchive template other archives]]'},
} )
end
function p:test_z1_notdate_archiveis()
self:preprocess_equals_preprocess(
'{{#invoke:Webarchive |webarchive |url=https://archive.is/e9AAZ}}',
'{{#invoke:Webarchive/sandbox |webarchive |url=https://archive.is/e9AAZ}}'
)
end
function p:test_z2_missingdate_archiveis1()
self:preprocess_equals_preprocess(
'{{#invoke:Webarchive |webarchive |url=https://archive.is/2016.08.08-112330/http://example.com/}}',
'{{#invoke:Webarchive/sandbox |webarchive |url=https://archive.is/2016.08.08-112330/http://example.com/}}'
)
end
function p:test_z2_missingdate_archiveis2()
self:preprocess_equals_preprocess(
'{{#invoke:Webarchive |webarchive |url=https://archive.is/20160808112330/http://example.com/}}',
'{{#invoke:Webarchive/sandbox |webarchive |url=https://archive.is/20160808112330/http://example.com/}}'
)
end
function p:test_z2_missingdate_wayback()
self:preprocess_equals_preprocess(
'{{#invoke:Webarchive |webarchive |url=https://web.archive.org/web/20160801000000/http://example.com/}}',
'{{#invoke:Webarchive/sandbox |webarchive |url=https://web.archive.org/web/20160801000000/http://example.com/}}'
)
end
function p:test_z2_missingdate_webarchiveloc()
self:preprocess_equals_preprocess(
'{{#invoke:Webarchive |webarchive |url=http://webarchive.loc.gov/all/20160801000000/http://example.com/}}',
'{{#invoke:Webarchive/sandbox |webarchive |url=http://webarchive.loc.gov/all/20160801000000/http://example.com/}}'
)
end
function p:test_z2_missingdate_webcite()
self:preprocess_equals_preprocess(
'{{#invoke:Webarchive |webarchive |url=https://www.webcitation.org/5eWaHRbn4?url=http://www.example.com/}}',
'{{#invoke:Webarchive/sandbox |webarchive |url=https://www.webcitation.org/5eWaHRbn4?url=http://www.example.com/}}'
)
end
function p:test_z3_wrongdate_archiveis1()
self:preprocess_equals_preprocess(
'{{#invoke:Webarchive |webarchive |url=https://archive.is/2016.08.08-112330/http://example.com/ |date=2017-08-21}}',
'{{#invoke:Webarchive/sandbox |webarchive |url=https://archive.is/2016.08.08-112330/http://example.com/ |date=2017-08-21}}'
)
end
function p:test_z3_wrongdate_archiveis2()
self:preprocess_equals_preprocess(
'{{#invoke:Webarchive |webarchive |url=https://archive.is/20160808112330/http://example.com/ |date=2017-08-21}}',
'{{#invoke:Webarchive/sandbox |webarchive |url=https://archive.is/20160808112330/http://example.com/ |date=2017-08-21}}'
)
end
function p:test_z3_wrongdate_wayback()
self:preprocess_equals_preprocess(
'{{#invoke:Webarchive |webarchive |url=https://web.archive.org/web/20160801000000/http://example.com/ |date=2017-08-21}}',
'{{#invoke:Webarchive/sandbox |webarchive |url=https://web.archive.org/web/20160801000000/http://example.com/ |date=2017-08-21}}'
)
end
function p:test_z3_wrongdate_webarchiveloc()
self:preprocess_equals_preprocess(
'{{#invoke:Webarchive |webarchive |url=http://webarchive.loc.gov/all/20160801000000/http://example.com/ |date=2017-08-21}}',
'{{#invoke:Webarchive/sandbox |webarchive |url=http://webarchive.loc.gov/all//20160801000000/http://example.com/ |date=2017-08-21}}'
)
end
function p:test_z3_wrongdate_webcite()
self:preprocess_equals_preprocess(
'{{#invoke:Webarchive |webarchive |url=https://www.webcitation.org/5eWaHRbn4?url=http://www.example.com/ |date=2017-08-21}}',
'{{#invoke:Webarchive/sandbox |webarchive |url=https://www.webcitation.org/5eWaHRbn4?url=http://www.example.com/ |date=2017-08-21}}'
)
end
function p:test_z4_index_wayback()
self:preprocess_equals_preprocess(
'{{#invoke:Webarchive |webarchive |url=https://web.archive.org/web/*/http://example.com/}}',
'{{#invoke:Webarchive/sandbox |webarchive |url=https://web.archive.org/web/*/http://example.com/}}'
)
end
function p:test_z4_index_webarchiveloc()
self:preprocess_equals_preprocess(
'{{#invoke:Webarchive |webarchive |url=http://webarchive.loc.gov/all/*/http://example.com/}}',
'{{#invoke:Webarchive/sandbox |webarchive |url=http://webarchive.loc.gov/all/*/http://example.com/}}'
)
end
return p