5 of 7 tests failed. (refresh)

TextExpectedActual
test_getCanonicalName:
PassedroaRomanceRomance
FailedgemGermanicජර්මානු
TextExpectedActual
test_getWikidataItem:
PassedroaQ19814Q19814
PassedgemQ21200Q21200
TextExpectedActual
test_makeWikipediaLink:
Failedroa[[w:Romance languages|Romance]][[w:Romance භාෂා|Romance]]
Failedgem[[w:Germanic languages|Germanic]][[w:ජර්මානු භාෂා|ජර්මානු]]
Failedsgn-jsl[[w:Japanese Sign Language family|Japanese Sign Languages]][[w:Japanese Sign Languages භාෂා|Japanese Sign Languages]]
TextExpectedActual
test_toJSON:
Script error during testing: Module:families:434: attempt to call field 'toJSON' (a nil value)
stack traceback:
	[C]: in function 'toJSON'
	Module:families:434: in function 'toJSON'
	Module:families/testcases:49: in function <Module:families/testcases:48>
	(tail call): ?
	[C]: in function 'xpcall'
	Module:UnitTests:369: in function <Module:UnitTests:328>
	(tail call): ?
	mw.lua:527: in function <mw.lua:507>
	[C]: ?
	[C]: in function 'expandTemplate'
	mw.lua:333: in function 'expandTemplate'
	Module:documentation:895: in function 'chunk'
	mw.lua:527: in function <mw.lua:507>
	[C]: ?

local tests = require("Module:UnitTests")

local getByCode = require("Module:families").getByCode

local families = {}
setmetatable(families, { -- Auto-create family objects: families.roa -> family object for Romance.
	__index = function(self, key)
		local family = getByCode(key) or error("No language with code " .. key .. ".")
		self[key] = family
		return family
	end
})

function tests:test_getCanonicalName()
	local examples = {
		{"roa", "Romance"},
		{"gem", "Germanic"},
	}

	self:iterate(examples, function(self, code, expected)
		self:equals(code, families[code]:getCanonicalName(), expected)
	end)
end

function tests:test_makeWikipediaLink()
	local examples = {
		{"roa", "[[w:Romance languages|Romance]]"},
		{"gem", "[[w:Germanic languages|Germanic]]"},
		{"sgn-jsl", "[[w:Japanese Sign Language family|Japanese Sign Languages]]"},
	}
	
	self:iterate(examples, function(self, code, expected)
		self:equals(code, families[code]:makeWikipediaLink(), expected, {nowiki=1})
	end)
end

function tests:test_getWikidataItem()
	local examples = {
		{"roa", "Q19814"},
		{"gem", "Q21200"},
	}

	self:iterate(examples, function(self, code, expected)
		self:equals(code, families[code]:getWikidataItem(), expected)
	end)
end

function tests:test_toJSON()
	self:equals('roa-JSON', families.roa:toJSON(), [[{"type" : "family", "wikidataItem" : "Q19814", "code" : "roa", "canonicalName" : "Romance", "otherNames" : ["Romanic", "Latin", "Neolatin", "Neo-Latin"], "categoryName" : "Romance languages", "family" : "itc"}]])
end

return tests
"https://si.wiktionary.org/w/index.php?title=Module:families/testcases&oldid=32451" වෙතින් සම්ප්‍රවේශනය කෙරිණි