Modul:usex/templates/testcases

Failed 2 tests failed.

Name Expected Actual
Failed test_usex_t_example Lua error -- Modul:usex:129: attempt to index local 'lang' (a nil value)
Failed test_usex_t_quote Lua error -- Modul:usex:129: attempt to index local 'lang' (a nil value)

local ScribuntoUnit = require('Module:ScribuntoUnit')
local m_usex_templates = require('Module:usex/templates')
local suite = ScribuntoUnit:new()

local function usex_t(args)
    local frame = mw.getCurrentFrame():newChild{ title = 'test', args = args }
    return m_usex_templates.usex_t(frame:newChild{})
end

local function usex_t_quote(args)
    local frame = mw.getCurrentFrame():newChild{ title = 'test', args = args }
    return m_usex_templates.usex_t(frame:newChild{ args = { quote = '1' } })
end

function suite:test_usex_t_example()
    local result = usex_t { 'fr', 'Ceci est un exemple', 'This is an example' }
    suite:assertEquals('<div class="h-usage-example"><i class="Latn mention e-example" lang="fr">Ceci est un exemple</i> <dl><dd><span class="e-translation">This is an example</span></dd></dl></div>', result)
end

function suite:test_usex_t_quote()
    local result = usex_t_quote { 'fr', 'Ceci est un quote', 'This is a quotation' }
    suite:assertEquals('<div class="h-quotation"><span class="Latn e-quotation" lang="fr">Ceci est un quote</span> <dl><dd><span class="e-translation">This is a quotation</span></dd></dl></div>', result)
end

return suite