Jump to content

Module:Sandbox/Mr. Stradivarius/Check ISO 639-1/testcases

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Mr. Stradivarius (talk | contribs) at 15:36, 13 December 2013 (remove the getAllCodeOutput function - this doesn't make much sense if the list of codes is stored in the module itself). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
-- Unit tests for [[Module:Check ISO 639-1]]. Click talk page to run tests.
local p = require('Module:UnitTests')

local isoModule = require('Module:Check ISO 639-1') -- the module to be tested
local checkISO = isoModule.main
local ScribuntoUnit = require('Module:ScribuntoUnit')
local suite = ScribuntoUnit:new()

function suite:testMain()
	self:assertEquals('en', checkISO{'en'})
	self:assertEquals('en', checkISO{'EN'})
	self:assertEquals('en', checkISO{' en '})
	self:assertEquals('en', checkISO{' EN '})
	self:assertEquals('en', checkISO{'en', nocat='true'})
	self:assertEquals('en', checkISO{'en', nocat='yes'})
	self:assertEquals('en', checkISO{'en', nocat='y'})
	self:assertEquals('en', checkISO{'en', nocat='1'})
	self:assertEquals('en', checkISO{'en', nocat='  yes  '})
	self:assertEquals('en', checkISO{'en', nocat=true})
	self:assertEquals('<strong class="error">Error: "eng" is not a valid [[List of ISO 639-1 codes|ISO 639-1 code]]</strong>[[Category:Pages with invalid ISO 639-1 language codes|eng]]', checkISO{'eng'})
	self:assertEquals('<strong class="error">Error: "eng" is not a valid [[List of ISO 639-1 codes|ISO 639-1 code]]</strong>[[Category:Pages with invalid ISO 639-1 language codes|eng]]', checkISO{'  eng  '})
	self:assertEquals('<strong class="error">Error: "English" is not a valid [[List of ISO 639-1 codes|ISO 639-1 code]]</strong>[[Category:Pages with invalid ISO 639-1 language codes|English]]', checkISO{'English'})
	self:assertEquals('<strong class="error">Error: "den" is not a valid [[List of ISO 639-1 codes|ISO 639-1 code]]</strong>[[Category:Pages with invalid ISO 639-1 language codes|den]]', checkISO{'den'})
	self:assertEquals('<strong class="error">Error: "fiu-vro" is not a valid [[List of ISO 639-1 codes|ISO 639-1 code]]</strong>[[Category:Pages with invalid ISO 639-1 language codes|fiu-vro]]', checkISO{'fiu-vro'})
	self:assertEquals('<strong class="error">Error: "English" is not a valid [[List of ISO 639-1 codes|ISO 639-1 code]]</strong>', checkISO{'English', nocat='true'})
	self:assertEquals('<strong class="error">Error: "English" is not a valid [[List of ISO 639-1 codes|ISO 639-1 code]]</strong>', checkISO{'English', nocat='yes'})
	self:assertEquals('<strong class="error">Error: "English" is not a valid [[List of ISO 639-1 codes|ISO 639-1 code]]</strong>', checkISO{'English', nocat='y'})
	self:assertEquals('<strong class="error">Error: "English" is not a valid [[List of ISO 639-1 codes|ISO 639-1 code]]</strong>', checkISO{'English', nocat='1'})
	self:assertEquals('<strong class="error">Error: "English" is not a valid [[List of ISO 639-1 codes|ISO 639-1 code]]</strong>', checkISO{'English', nocat='  yes  '})
	self:assertEquals('<strong class="error">Error: "English" is not a valid [[List of ISO 639-1 codes|ISO 639-1 code]]</strong>', checkISO{'English', nocat=true})
	self:assertEquals('<strong class="error">Error: "English" is not a valid [[List of ISO 639-1 codes|ISO 639-1 code]]</strong>[[Category:Pages with invalid ISO 639-1 language codes|English]]', checkISO{'English', nocat='false'})
	self:assertEquals('', checkISO{''})
	self:assertEquals('', checkISO{'  '})
	self:assertEquals('', checkISO{{}})
	self:assertEquals('', checkISO{true})
	self:assertEquals('', checkISO{nil})
end

return suite