Module:Sandbox/Vinifera7/test2/testcases
Jump to navigation
Jump to search
This module implements the test cases for Module:Sandbox/Vinifera7/test2.
All tests passed.
Name | Expected | Actual | |
---|---|---|---|
testFormattedValue01 | |||
testFormattedValue02 | |||
testFormattedValue03 | |||
testFormattedValue04 | |||
testFormattedValue05 | |||
testFormattedValue06 | |||
testFormattedValue07 | |||
testFormattedValue08 | |||
testFormattedValue09 | |||
testFormattedValue10 | |||
testFormattedValue11 | |||
testFormattedValue12 |
local util = require('Module:Util/sandbox')
local ScribuntoUnit = require('Module:ScribuntoUnit')
local suite = ScribuntoUnit:new()
--------------------------------------------------------------------------------------------
-- Test util.html.format_value
--------------------------------------------------------------------------------------------
function suite:assertFormattedValueEquals(expected, value, options)
local out = util.html.format_value(nil, value, options)
self:assertEquals(expected, out)
end
local static_value = {
base = 10,
min = 10,
max = 10,
}
local range_value = {
base = 10,
min = 15,
max = 25,
}
function suite:testFormattedValue01()
options = {
color = nil,
inline = nil,
inline_color = nil,
}
self:assertFormattedValueEquals('<em class="tc -value ">10</em>', static_value, options)
self:assertFormattedValueEquals('<em class="tc -mod ">(15-25)</em>', range_value, options)
end
function suite:testFormattedValue02()
options = {
color = false,
inline = nil,
inline_color = nil,
}
self:assertFormattedValueEquals('10', static_value, options)
self:assertFormattedValueEquals('(15-25)', range_value, options)
end
function suite:testFormattedValue03()
options = {
color = 'fire',
inline = nil,
inline_color = nil,
}
self:assertFormattedValueEquals('<em class="tc -fire ">10</em>', static_value, options)
self:assertFormattedValueEquals('<em class="tc -fire ">(15-25)</em>', range_value, options)
end
function suite:testFormattedValue04()
options = {
color = nil,
inline = '+%s%%',
inline_color = nil,
}
self:assertFormattedValueEquals('<em class="tc -value ">+10%</em>', static_value, options)
self:assertFormattedValueEquals('<em class="tc -mod ">+(15-25)%</em>', range_value, options)
end
function suite:testFormattedValue05()
options = {
color = nil,
inline = '+%s%%',
inline_color = false,
}
self:assertFormattedValueEquals('+<em class="tc -value ">10</em>%', static_value, options)
self:assertFormattedValueEquals('+<em class="tc -mod ">(15-25)</em>%', range_value, options)
end
function suite:testFormattedValue06()
options = {
color = nil,
inline = '+%s%%',
inline_color = 'default',
}
self:assertFormattedValueEquals('<em class="tc -default ">+<em class="tc -value ">10</em>%</em>', static_value, options)
self:assertFormattedValueEquals('<em class="tc -default ">+<em class="tc -mod ">(15-25)</em>%</em>', range_value, options)
end
function suite:testFormattedValue07()
options = {
color = false,
inline = '+%s%%',
inline_color = nil,
}
self:assertFormattedValueEquals('+10%', static_value, options)
self:assertFormattedValueEquals('+(15-25)%', range_value, options)
end
function suite:testFormattedValue08()
options = {
color = false,
inline = '+%s%%',
inline_color = false,
}
self:assertFormattedValueEquals('+10%', static_value, options)
self:assertFormattedValueEquals('+(15-25)%', range_value, options)
end
function suite:testFormattedValue09()
options = {
color = false,
inline = '+%s%%',
inline_color = 'default',
}
self:assertFormattedValueEquals('<em class="tc -default ">+10%</em>', static_value, options)
self:assertFormattedValueEquals('<em class="tc -default ">+(15-25)%</em>', range_value, options)
end
function suite:testFormattedValue10()
options = {
color = 'fire',
inline = '+%s%%',
inline_color = nil,
}
self:assertFormattedValueEquals('<em class="tc -fire ">+10%</em>', static_value, options)
self:assertFormattedValueEquals('<em class="tc -fire ">+(15-25)%</em>', range_value, options)
end
function suite:testFormattedValue11()
options = {
color = 'fire',
inline = '+%s%%',
inline_color = false,
}
self:assertFormattedValueEquals('+<em class="tc -fire ">10</em>%', static_value, options)
self:assertFormattedValueEquals('+<em class="tc -fire ">(15-25)</em>%', range_value, options)
end
function suite:testFormattedValue12()
options = {
color = 'fire',
inline = '+%s%%',
inline_color = 'default',
}
self:assertFormattedValueEquals('<em class="tc -default ">+<em class="tc -fire ">10</em>%</em>', static_value, options)
self:assertFormattedValueEquals('<em class="tc -default ">+<em class="tc -fire ">(15-25)</em>%</em>', range_value, options)
end
return suite