Hopp til innhold

Bruker:Jeblad/Module:JSONstat/testtilfeller

Fra Wikipedia, den frie encyklopedi


-- Unit tests for [[Module:Wb]]. Click talk page to run tests.
-- Note that the test set at [[Bruker:Jeblad/SSB01222.json]] is not live and only for test purposes.
local p = require('Module:UnitTests')
local jsonstat = require('Module:JSONstat')

local categoryAsJson =
[[{
	"category": {
		"index": { "A": 0, "B": 1 },
		"label": { "A": "test a", "B": "test b" }
	}
}]]
local categoryAsTable = mw.text.jsonDecode( categoryAsJson )

local bundle = 
[[{"bar":{"class":"dataset"},"foo":{"class":"dataset"}}]]

function p:test_category()
	local instance = jsonstat.Category(categoryAsTable)
	self:equals('Recall signature from predefined small dataset', instance.signature(), 'JSONstatCategory')
	self:equals_deep('Compare data from predefined small dataset', instance.toTable(), categoryAsTable)
	self:equals_deep('Compare index from predefined small dataset', instance.index(), categoryAsTable.index)
end

return p