Mô đun:Webarchive/testcases

local p = require('Module:UnitTests')
function p:test_Usage_Examples()
	self:preprocess_equals_preprocess_many('webarchive', , 'webarchive', , {
		{'|url=https://web.archive.org/web/20160801000000/http://example.com |date=August 1, 2016'},
		{'|url=http://www.webcitation.org/5eWaHRbn4?url=http://www.example.com/ |date=12 February 2009'},
		{'|url=http://www.webcitation.org/5eWaHRbn4?url=http://www.example.com/ |date=12 February 2009 |title=Page title'}
	} )
end
function p:test_Template_Examples()
	self:preprocess_equals_preprocess_many('webarchive', , 'webarchive', , {
		{'|url=https://web.archive.org/web/20160801000000/http://example.com |date=August 1, 2016 |title=Page title'},
		{'|url=https://web.archive.org/web/20160801000000/http://example.com |date=August 1, 2016'},
		{'|url=http://www.webcitation.org/5eWaHRbn4?url=http://www.example.com/'},
		{'|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'},
		{'|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'},
		{'|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'},
		})
end
function p:test_Permacc()
	self:preprocess_equals_preprocess_many('webarchive', , 'webarchive', , {
		{'|url=http://perma.cc/F9NT-22AK |date=2015-04-09'},
		{'|url=http://perma.cc/F9NT-22AK |date=2015-04-09 |title=Mike Pressler Biography'},
	} )
end
function p:test_z1_notdate_archiveis()
	self:preprocess_equals_preprocess(
		'url=https://archive.is/e9AAZ',
		'url=https://archive.is/e9AAZ'
		)
end
function p:test_z2_missingdate_archiveis1()
	self:preprocess_equals_preprocess(
		'url=https://archive.is/2016.08.08-112330/http://example.com/',
		'url=https://archive.is/2016.08.08-112330/http://example.com/'
		)
end
function p:test_z2_missingdate_archiveis2()
	self:preprocess_equals_preprocess(
		'url=https://archive.is/20160808112330/http://example.com/',
		'url=https://archive.is/20160808112330/http://example.com/'
		)
end
function p:test_z2_missingdate_ukgwa()
	self:preprocess_equals_preprocess(
		'url=https://webarchive.nationalarchives.gov.uk/ukgwa/20160801000000/http://example.com/',
		'url=https://webarchive.nationalarchives.gov.uk/ukgwa/20160801000000/http://example.com/'
		)
end
function p:test_z2_missingdate_wayback()
	self:preprocess_equals_preprocess(
		'url=https://web.archive.org/web/20160801000000/http://example.com/',
		'url=https://web.archive.org/web/20160801000000/http://example.com/'
		)
end
function p:test_z2_missingdate_wayback_ukgwa()
	self:preprocess_equals_preprocess(
		'url=https://web.archive.org/web/20191201000000/http://webarchive.nationalarchives.gov.uk/ukgwa/20160801000000/http://example.com',
		'url=https://web.archive.org/web/20191201000000/http://webarchive.nationalarchives.gov.uk/ukgwa/20160801000000/http://example.com'
		)
end
function p:test_z2_missingdate_webarchiveloc()
	self:preprocess_equals_preprocess(
		'url=http://webarchive.loc.gov/all/20160801000000/http://example.com/',
		'url=http://webarchive.loc.gov/all/20160801000000/http://example.com/'
		)
end
function p:test_z2_missingdate_webcite()
	self:preprocess_equals_preprocess(
		'url=https://www.webcitation.org/5eWaHRbn4?url=http://www.example.com/',
		'url=https://www.webcitation.org/5eWaHRbn4?url=http://www.example.com/'
		)
end
function p:test_z2_missingdate_archiveit1()
	self:preprocess_equals_preprocess(
		'url=https://wayback.archive-it.org/all/20190621232545/http://example.com/',
		'url=https://wayback.archive-it.org/all/20190621232545/http://example.com/'
		)
end
function p:test_z2_missingdate_archiveit2()
	self:preprocess_equals_preprocess(
		'url=https://wayback.archive-it.org/org-467/20191016094633/http://quartos.org/',
		'url=https://wayback.archive-it.org/org-467/20191016094633/http://quartos.org/'
		)
end
function p:test_z2_missingdate_archiveit3()
	self:preprocess_equals_preprocess(
		'url=https://wayback.archive-it.org/3348/20151201214156/https://www.heritagepreservation.org/',
		'url=https://wayback.archive-it.org/3348/20151201214156/https://www.heritagepreservation.org/'
		)
end
function p:test_z3_wrongdate_archiveis1()
	self:preprocess_equals_preprocess(
		'date=2017-08-21',
		'date=2017-08-21'
		)
end
function p:test_z3_wrongdate_archiveis2()
	self:preprocess_equals_preprocess(
		'date=2017-08-21',
		'date=2017-08-21'
		)
end
function p:test_z3_wrongdate_ukgwa()
	self:preprocess_equals_preprocess(
		'date=2017-08-21',
		'date=2017-08-21'
		)
end
function p:test_z3_wrongdate_wayback()
	self:preprocess_equals_preprocess(
		'date=2017-08-21',
		'date=2017-08-21'
		)
end
function p:test_z3_wrongdate_wayback_ukgwa()
	self:preprocess_equals_preprocess(
		'date=2016-08-01',
		'date=2016-08-01'
		)
end
function p:test_z3_wrongdate_webarchiveloc()
	self:preprocess_equals_preprocess(
		'date=2017-08-21',
		'date=2017-08-21'
		)
end
function p:test_z3_wrongdate_webcite()
	self:preprocess_equals_preprocess(
		'date=2017-08-21',
		'date=2017-08-21'
		)
end
function p:test_z3_wrongdate_archiveit1()
	self:preprocess_equals_preprocess(
		'date=2019-06-22',
		'date=2019-06-22'
		)
end
function p:test_z3_wrongdate_archiveit2()
	self:preprocess_equals_preprocess(
		'date=2019-10-17',
		'date=2019-10-17'
		)
end
function p:test_z3_wrongdate_archiveit3()
	self:preprocess_equals_preprocess(
		'date=2015-12-02',
		'date=2015-12-02'
		)
end
function p:test_z4_index_ukgwa()
	self:preprocess_equals_preprocess(
		'url=https://webarchive.nationalarchives.gov.uk/ukgwa/*/http://example.com/',
		'url=https://webarchive.nationalarchives.gov.uk/ukgwa/*/http://example.com/'
		)
end
function p:test_z4_index_wayback()
	self:preprocess_equals_preprocess(
		'url=https://web.archive.org/web/*/http://example.com/',
		'url=https://web.archive.org/web/*/http://example.com/'
		)
end
function p:test_z4_index_webarchiveloc()
	self:preprocess_equals_preprocess(
		'url=http://webarchive.loc.gov/all/*/http://example.com/',
		'url=http://webarchive.loc.gov/all/*/http://example.com/'
		)
end
function p:test_z4_index_archiveit1()
	self:preprocess_equals_preprocess(
		'url=https://wayback.archive-it.org/all/*/http://example.com/',
		'url=https://wayback.archive-it.org/all/*/http://example.com/'
		)
end
function p:test_z4_index_archiveit2()
	self:preprocess_equals_preprocess(
		'url=https://wayback.archive-it.org/org-467/*/http://quartos.org/',
		'url=https://wayback.archive-it.org/org-467/*/http://quartos.org/'
		)
end
function p:test_z4_index_archiveit3()
	self:preprocess_equals_preprocess(
		'url=https://wayback.archive-it.org/3348/*/https://www.heritagepreservation.org/',
		'url=https://wayback.archive-it.org/3348/*/https://www.heritagepreservation.org/'
		)
end
function p:test_z5_mdy_archiveis1()
	self:preprocess_equals_preprocess(
		'date=mdy',
		'date=mdy'
		)
end
function p:test_z5_mdy_archiveis2()
	self:preprocess_equals_preprocess(
		'date=mdy',
		'date=mdy'
		)
end
function p:test_z5_mdy_ukgwa()
	self:preprocess_equals_preprocess(
		'date=mdy',
		'date=mdy'
		)
end
function p:test_z5_mdy_wayback()
	self:preprocess_equals_preprocess(
		'date=mdy',
		'date=mdy'
		)
end
function p:test_z5_mdy_wayback_ukgwa()
	self:preprocess_equals_preprocess(
		'date=mdy',
		'date=mdy'
		)
end
function p:test_z5_mdy_webarchiveloc()
	self:preprocess_equals_preprocess(
		'date=mdy',
		'date=mdy'
		)
end
function p:test_z5_mdy_webcite()
	self:preprocess_equals_preprocess(
		'date=mdy',
		'date=mdy'
		)
end
function p:test_z5_mdy_archiveit1()
	self:preprocess_equals_preprocess(
		'date=mdy',
		'date=mdy'
		)
end
function p:test_z5_mdy_archiveit2()
	self:preprocess_equals_preprocess(
		'date=mdy',
		'date=mdy'
		)
end
function p:test_z5_mdy_archiveit3()
	self:preprocess_equals_preprocess(
		'date=mdy',
		'date=mdy'
		)
end
function p:test_z6_dmy_archiveis1()
	self:preprocess_equals_preprocess(
		'date=dmy',
		'date=dmy'
		)
end
function p:test_z6_dmy_archiveis2()
	self:preprocess_equals_preprocess(
		'date=dmy',
		'date=dmy'
		)
end
function p:test_z6_dmy_ukgwa()
	self:preprocess_equals_preprocess(
		'date=dmy',
		'date=dmy'
		)
end
function p:test_z6_dmy_wayback()
	self:preprocess_equals_preprocess(
		'date=dmy',
		'date=dmy'
		)
end
function p:test_z6_dmy_wayback_ukgwa()
	self:preprocess_equals_preprocess(
		'date=dmy',
		'date=dmy'
		)
end
function p:test_z6_dmy_webarchiveloc()
	self:preprocess_equals_preprocess(
		'date=dmy',
		'date=dmy'
		)
end
function p:test_z6_dmy_webcite()
	self:preprocess_equals_preprocess(
		'date=dmy',
		'date=dmy'
		)
end
function p:test_z6_dmy_archiveit1()
	self:preprocess_equals_preprocess(
		'date=dmy',
		'date=dmy'
		)
end
function p:test_z6_dmy_archiveit2()
	self:preprocess_equals_preprocess(
		'date=dmy',
		'date=dmy'
		)
end
function p:test_z6_dmy_archiveit3()
	self:preprocess_equals_preprocess(
		'date=dmy',
		'date=dmy'
		)
end
function p:test_addlarchives_1()
	self:preprocess_equals_preprocess(
		'date2=25 February 2011',
		'date2=25 February 2011'
		)
end
function p:test_addlarchives_2()	-- has malformed |date2=
	self:preprocess_equals_preprocess(
		'date=2014-09-03',
		'date=2014-09-03'
		)
end
function p:test_addlarchives_3()
	self:preprocess_equals_preprocess(
		'title=Chapter 25',
		'title=Chapter 25'
		)
end
function p:test_addlpages_1() -- without title
	self:preprocess_equals_preprocess(
		'date2=2009-09-11',
		'date2=2009-09-11'
		)
end
function p:test_addlpages_2() -- uses title
	self:preprocess_equals_preprocess(
		'title2=Page 3',
		'title2=Page 3'
		)
end
function p:test_addlpages_3()	-- uses title (Title 1) and not title (page 2)
	self:preprocess_equals_preprocess(
		'date2=2009-09-11',
		'date2=2009-09-11'
		)
end
function p:test_addlpages_4()
	self:preprocess_equals_preprocess(
		'title4=Page 5',
		'title4=Page 5'
		)
end
function p:test_addlpages_5()
	self:preprocess_equals_preprocess(
		'date5=2004-08-31',
		'date5=2004-08-31'
		)
end
function p:test_sequencegap()
	self:preprocess_equals_preprocess(
		'date3=2016-08-02',
		'date3=2016-08-01'
		)
end
return p