Hopp til innhold

Modul:Citation/CS1/testcases/anchor

Fra Wikipedia, den frie encyklopedi
Sideversjon per 30. jan. 2021 kl. 08:01 av en>Izno (start a module for testing this)
(diff) ← Eldre sideversjon | Nåværende sideversjon (diff) | Nyere sideversjon → (diff)
Moduldokumentasjon


--[=[
Unit tests for [[Module:Citation/CS1]] anchor and CITEREF creation.

Click talk page to run tests.
]=]

local p = require('Module:UnitTests')

--[[ test_counts
Tests what happens with various counts of contributors, authors, and editors
0 0 0
1 0 0
0 1 0 -- in the real world, same as 1 1 0
0 0 1
1 1 0
1 0 1
0 1 1
1 1 1
4 0 0
5 0 0
0 0 2
]]
function p:test_counts()
    self:preprocess_equals_preprocess_many(
    	'{{cite book/new |title=T |year=2020 |', '}}',
    	'{{cite book |title=T |year=2020 |', '}}',
		{
			{'chapter=CH'}, -- bogus for no date and no people
			{'author=A1'},
			{'book-author=BA1'},
			{'editor=E1'},
			{'author=A1 |book-author=BA1 |chapter=CH'},
			{'author=A1 |editor=E1'},
			{'book-author=BA1 |editor=E1'},
			{'author=A1 |book-author=BA1 |editor=E1'},
			{'author=A1 |author2=A2 |author3=A3 |author4=A4'},
			{'author=A1 |author2=A2 |author3=A3 |author4=A4 |author5=A5'},
			{'editor=E1 |editor2=E2'},
		},
		{nowiki=false, templatestyles=true}
	)
end
--[[ test_dates
Tests date resolution code, including anchor years.

]]
function p:test_dates()
    self:preprocess_equals_preprocess_many(
    	'{{cite book/new |title=T |author=A1 |', '}}',
    	'{{cite book |title=T |author=A1 |', '}}',
		{
			{'chapter=CH'}, -- bogus for no date
			{'year=2020'},
			{'date=1 January 2020'},
			{'date=1 January 2020 |year=2020'},
			{'date=1 January 2020 |year=2020a'},
			{'date=2020-01-01 |year=2020'},
			{'date=2020-01-01 |year=2020a'},
		},
		{nowiki=false, templatestyles=true}
	)
end

return p