Modul:families/testcases

4 of 8 tests failed. (refresh)

TextExpectedActual
test_getCanonicalName:
PassedmapAustronesiaAustronesia
FailedgemJermanikGermanic
TextExpectedActual
test_getWikidataItem:
PassedroaQ19814Q19814
PassedgemQ21200Q21200
TextExpectedActual
test_makeWikipediaLink:
Passedmap[[w:Bahasa-bahasa Austronesia|Austronesia]][[w:Bahasa-bahasa Austronesia|Austronesia]]
Failedgem[[w:Bahasa-bahasa Jermanik|Jermanik]][[w:Bahasa-bahasa Jerman|Germanic]]
Failedsgn-jsl[[w:Keluarga Bahasa Isyarat Jepun|Bahasa Isyarat Jepun]][[w:Bahasa-bahasa Japanese Sign Languages|Japanese Sign Languages]]
TextExpectedActual
test_toJSON:
Failedroa-JSON{"type" : "family", "wikidataItem" : "Q19814", "code" : "roa", "canonicalName" : "Romance", "otherNames" : ["Romanic", "Latin", "Neolatin", "Neo-Latin"], "categoryName" : "Romance languages", "family" : "itc"}{"type" : [ "family", "full", "regular" ], "code" : "roa", "canonicalName" : "Romance", "aliases" : [ "Romanic", "Latin", "Neolatin", "Neo-Latin" ], "wikidataItem" : "Q19814", "varieties" : [], "protoLanguage" : "la", "family" : "itc", "otherNames" : [], "categoryName" : "Bahasa-bahasa Romance"}

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 = {
		{"map", "Austronesia"},
		{"gem", "Jermanik"},
	}

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

function tests:test_makeWikipediaLink()
	local examples = {
		{"map", "[[w:Bahasa-bahasa Austronesia|Austronesia]]"},
		{"gem", "[[w:Bahasa-bahasa Jermanik|Jermanik]]"},
		{"sgn-jsl", "[[w:Keluarga Bahasa Isyarat Jepun|Bahasa Isyarat Jepun]]"},
	}
	
	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