Modul:Citation/CS1/testcases/anchor
Utseende
Moduldokumentasjon
[opprett]
--[=[
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
0 0 1
1 1 0
1 0 1
0 1 1
1 1 1
4 0 0
5 0 0
0 3 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'}, -- no auto CITEREF without people
{'author=_A1_'}, -- CITEREF_A1_2020
{'contributor=C1'}, -- no auto CITEREF without contribution and/or
-- no auto CITEREF without author
{'contributor=C1 |contribution=CON'}, -- no auto CITEREF without author
{'editor=_E1_'}, -- CITEREF_E1_2020
{'author=_A1_ |contributor=_C1_'}, -- CITEREF_A1_2020
{'author=_A1_ |contributor=_C1_ |contribution=CON'}, -- CITEREF_A1_2020
{'author=_A1_ |editor=_E1_'}, -- CITEREF_A1_2020
{'editor=_E1_ |contributor=_C1_'}, -- CITEREF_E1_2020
{'editor=_E1_ |contributor=_C1_ |contribution=CON'}, -- CITEREF_E1_2020
{'author=_A1_ |contributor=_C1_ |editor=_E1_'},
{'author=_A1_ |contributor=_C1_ |editor=_E1_ |contribution=CON'},
{'author=_A1_ |author2=A2_ |author3=A3_ |author4=A4_'},
{'author=_A1_ |author2=A2_ |author3=A3_ |author4=A4_ |author5=A5_'},
{'contributor=_C1_ |contributor2=C2_ |contributor3=C3_'},
{'contributor=_C1_ |contributor2=C2_ |contributor3=C3_ |contribution=CON'},
{'author=_A1_ |contributor=_C1_ |contributor2=C2_ |contributor3=C3_ |contribution=CON'},
{'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