Modul:Functions/testcases

Z Wikipedie, otevřené encyklopedie
Skočit na navigaci Skočit na vyhledávání
local Module = require('Modul:Functions')
local ScribuntoUnit = require('Modul:ScribuntoUnit')

local suite = ScribuntoUnit:new()

function suite:testFirstToUpper()
	self:assertTrue(Module.firstToUpper(''))
	self:assertEquals(Module.firstToUpper('foo'), 'Foo')
end

function suite:testCleanArgs()
	local args = {}
	self:assertTrue(Module.cleanArgs(args))
	args = {
		a = '',
		b = ' ',
		c = 2,
		d = ' foo ',
		e = {
			foo = 'xyz'
		}
	}
	self:assertDeepEquals(Module.cleanArgs(args), { c = 2, d = 'foo', e = { foo = 'xyz' }})
	args = {
		foo = {
			bar = {},
			baz = {}
		}
	}
	self:assertDeepEquals(Module.cleanArgs(args), {})
end

function suite:testIsTableEmpty()
	local test_table = { {} }
	self:assertTrue(Module.isTableEmpty(test_table))
	test_table = { a = '', b = ' ' }
	self:assertTrue(Module.isTableEmpty(test_table))
	test_table = { 'a' }
	self:assertFalse(Module.isTableEmpty(test_table))
end

return suite