Jump to content

Module:Cite Q/testcases

From Wikipedia, the free encyclopedia
local p = require('Module:UnitTests')

--[=[----------------------------------------------------------------------------------------------------------

these tests adapted from Template:Cite Q/testcases ([[Special:Permalink/1383076558]])

in these tests, 'Expected' is the live template; 'Actual' is the sandbox template
]=]


--[[--------------------------< B A S I C S >------------------------------------------------------------------
]]

function p:test_basics()
	self:preprocess_equals_preprocess_many(
    	'{{Cite Q/sandbox |', '}}', '{{Cite Q |', '}}',
		{
			{'Q15625490'},														-- properly formatted qid
			{'15625490'},														-- improperly formatted qid
			{'https://www.wikidata.org/wiki/Q15625490'},						-- url instead of a qid
		},
		{nowiki=false, templatestyles=true}
	)
end


--[[--------------------------< T E S T _ J O U R N A L _ A R T I C L E S >------------------------------------
]]

function p:test_journal_articles()
	self:preprocess_equals_preprocess_many(
    	'{{Cite Q/sandbox |', '}}', '{{Cite Q |', '}}',
		{
			{'Q15625490|doi-access=free'},
			{'Q15625490|doi-access=free|access-date=18 May 2017'},
			{'Q15625490|doi-access=free|quote=lorem ipsum'},
			{'Q15625490|doi-access=free|page=42|access-date=18 May 2017|quote=lorem ipsum'},
			{'Q90413384'},														-- with volume, issue, pages and date as qualifiers
			{'Q30000000'},														-- with volume & issue in both locations
			{'Q56219959'},														-- with multiple URLs
			{'Q21128894|doi-access=free'},										-- with duplicate dates
			{'Q21030635|doi-access=free'},										-- high use
			{'Q90413885'},														-- paper published as part of a book
			{'Q27931257'},														-- multiple apostrophes in title
			{'Q58819281'},														-- complex DOI
			{'Q64384613'},														-- italics in journal
			{'Q15625490|doi-access=free|doi=unset'},							-- |doi=unset
			{'Q64384613'},
			{'Q100271075'},														-- URL in work available at URL (P953)
			{'Q100272276'},														-- has URL (P2699) and work available at URL (P953)
			{'Q90413885'},														-- page as a qualifier
			{'Q56796684'},														-- preprint article
			{'Q54552763'},														-- no Wikipedia article about journal
			{'Q30105981'},														-- article with over 1,000 authors
		},
		{nowiki=false, templatestyles=true}
	)
end


--[[--------------------------< T E S T _ S U B T I T L E >----------------------------------------------------
]]

function p:test_subtitle()
	self:preprocess_equals_preprocess_many(
    	'{{Cite Q/sandbox |', '}}', '{{Cite Q |', '}}',
		{
			{'Q58641916'},														-- display subtitle (P1680) value
		},
		{nowiki=false, templatestyles=true}
	)
end


--[[--------------------------< T E S T _ I D E N T I F I E R S >----------------------------------------------
]]

function p:test_identifiers()
	self:preprocess_equals_preprocess_many(
    	'{{Cite Q/sandbox |', '}}', '{{Cite Q |', '}}',
		{
			{'Q14558831'},														-- with arxiv; bibcode
			{'Q28798299'},														-- with osti
			{'Q23327424'},														-- with ssrn, "free to read" qualifier
			{'Q15625490|doi-access=free|doi=unset|issn=unset|pmc=unset|pmid=unset'},	-- lots unset
			{'Q68550452'},														-- "free to read" qualifier on bibcode
		},
		{nowiki=false, templatestyles=true}
	)
end


--[[--------------------------< T E S T _ R E T R A C T E D _ I N D I C A T O R S >----------------------------
]]

function p:test_retracted_indicators()
	self:preprocess_equals_preprocess_many(
    	'{{Cite Q/sandbox |', '}}', '{{Cite Q |', '}}',
		{
			{'Q29030043'},														-- retracted article
			{'Q61957492'},														-- retracted retraction notice
			{'Q57210388'},														-- final, corrected version
			{'Q56237061|retracted-intentional=yes'},							-- intentionally cite retracted article
		},
		{nowiki=false, templatestyles=true}
	)
end


--[[--------------------------< T E S T _ E X P R E S S I O N _ O F _ C O N C E R N _ N O T I C E S >----------
]]

function p:test_expression_of_concern_notices()
	self:preprocess_equals_preprocess_many(
    	'{{Cite Q/sandbox |', '}}', '{{Cite Q |', '}}',
		{
			{'Q38256144'},														-- 
			{'Q38256144|eoc-intentional=yes'},									-- 
			{'Q33372336'},														-- 
			{'Q36995056'},														-- 
		},
		{nowiki=false, templatestyles=true}
	)
end


--[[--------------------------< T E S T _ E R R A T A >--------------------------------------------------------
]]

function p:test_errata()
	self:preprocess_equals_preprocess_many(
    	'{{Cite Q/sandbox |', '}}', '{{Cite Q |', '}}',
		{
			{'Q28597702|doi-access=free'},										-- 
			{'Q21709583'},														-- 
			{'Q21709583|erratum-checked=yes'},									-- 
		},
		{nowiki=false, templatestyles=true}
	)
end


--[[--------------------------< T E S T _ R E P L A C E D _ I N D I C A T O R S >------------------------------
]]

function p:test_replaced_indicators()
	self:preprocess_equals_preprocess_many(
    	'{{Cite Q/sandbox |', '}}', '{{Cite Q |', '}}',
		{
			{'Q66311618'},														-- 1957 article, replaced 1987
			{'Q12912667'},														-- CAB 1900, replaced 2007
		},
		{nowiki=false, templatestyles=true}
	)
end


--[[--------------------------< T E S T _ P A G E _ N U M B E R S >--------------------------------------------
]]

function p:test_page_numbers()
	self:preprocess_equals_preprocess_many(
    	'{{Cite Q/sandbox |', '}}', '{{Cite Q |', '}}',
		{
			{'Q15625490|doi-access=free|page=42'},								-- 
			{'Q15625490|doi-access=free|pages=42-44'},							-- 
			{'Q73498590'},														-- with comma in page range
			{'Q43171199'},														-- with letter instead of page number
		},
		{nowiki=false, templatestyles=true}
	)
end


--[[--------------------------< T E S T _ L A N G U A G E _ R E L A T E D >------------------------------------
]]

function p:test_language_related()
	self:preprocess_equals_preprocess_many(
    	'{{Cite Q/sandbox |', '}}', '{{Cite Q |', '}}',
		{
			{'Q92682016'},														-- paper with no English label, at time of writing
			{'Q100272555'},														-- Portuguese language
			{'Q100272276'},														-- Portuguese language
			{'Q100282025'},														-- Academic journal in Portuguese, language in item
			{'Q100282025'},														-- Magazine in Portuguese, language in journal item, no article IDs ∴ show ISSN
			{'Q100367981'},														-- Magazine in Portuguese, language in journal item
			{'Q19231225'},														-- language of work
			{'Q51623924'},														-- language of work
		},
		{nowiki=false, templatestyles=true}
	)
end


--[[--------------------------< T E S T _ P E R S O N _ N A M E S >--------------------------------------------
]]

function p:test_person_names()
	self:preprocess_equals_preprocess_many(
    	'{{Cite Q/sandbox |', '}}', '{{Cite Q |', '}}',
		{
			{'Q59348150'},														-- display object of statement named as (P1932) value
			{'Q101094300'},														-- Mix of author (P50) and author name string (P2093), out of sequence
			{'Q3019579'},														-- unknown author Japanese, P50 = Q4233718
			{'Q1594000'},														-- unknown author Polish, P50 = Q4233718
			{'Q100279778'},														-- no en label, P50 = "unknown value"
			{'Q106379272'},														-- label=Bandita, P50 = "unknown value"
--			{'Q100279778'},														-- en label = P1476, P50 = "unknown value" -- what? Q100279778 can't have 'no en label' and 'en label'
		},
		{nowiki=false, templatestyles=true}
	)
end


--[[--------------------------E X P O R T S >------------------------------------------------------------------
]]

return p