Module:Plain sister/testcases

-- Unit tests for Module:Plain sister. Go to the talk page to view test results. local testSuit = require('Module:UnitTests')

local PS = require('Module:Plain sister')

-- test the core getLinks functions function testSuit:test_getLinks self:equals_deep(		'From Wikidata: Q1',		PS.getLinks({ wikidata = 'Q1', }),		{			w = 'Universe',			['c:Category'] = 'Universe',			q = 'Universe',			v = 'Universe',			d = 'Q1',		}	) self:equals_deep(		'From an edition (Stella Dallas)',		PS.getLinks({ wikidata = 'Q106388874', }),		{			w = 'Stella Dallas (novel)', -- from the work			['c:Category'] = 'Stella Dallas (1923 edition of novel)', -- from the edition			d = 'Q106388874',		}	) -- A topic self:equals_deep(		'A topic via P921',		PS.getLinks({ wikidata = 'Q19064858', }),		{			w = 'Banksia spinulosa',			wikispecies = 'Banksia spinulosa',			d = 'Q19064858',		}	) -- An author. self:equals_deep(		'Author',		PS.getLinks({ wikidata = 'Q15712330', }),		{			w = 'Alice Hay Wadsworth',			['c:Category'] = 'Alice Wadsworth', -- from the edition			d = 'Q15712330',		}	) -- A biographical article --		should NOT include the commons category via the P921 claim self:equals_deep(		'Biographical article',		PS.getLinks({ wikidata = 'Q84635865', }),		{			w = 'William Adams (pilot)',			d = 'Q84635865',		}	) end

function testSuit:test_inline local prefix = ' sister projects: '

-- Not a Wikisource item. self:preprocess_equals(		'',		prefix .. 'Wikipedia article, Commons category, quotes, course, Wikidata item.',		{nowiki=1}	)

-- Wikisource edition, via template. self:preprocess_equals(		,		mw.getCurrentFrame:extensionTag('templatestyles', , {src = 'Plain sister/styles.css'})		.. ''		.. prefix .. 'Wikipedia article, Commons category, Wikidata item.',		{nowiki=1}	) end

return testSuit