Module:Sandbox/Vinifera7/test2/testcases: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 23: | Line 23: | ||
} | } | ||
function suite: | function suite:testFormattedValue01() | ||
options = { | options = { | ||
color = nil, | color = nil, | ||
Line 33: | Line 33: | ||
end | end | ||
function suite: | function suite:testFormattedValue02() | ||
options = { | options = { | ||
color = false, | color = false, | ||
Line 43: | Line 43: | ||
end | end | ||
function suite: | function suite:testFormattedValue03() | ||
options = { | options = { | ||
color = 'fire', | color = 'fire', | ||
Line 53: | Line 53: | ||
end | end | ||
function suite: | function suite:testFormattedValue04() | ||
options = { | options = { | ||
color = nil, | color = nil, | ||
Line 63: | Line 63: | ||
end | end | ||
function suite: | function suite:testFormattedValue05() | ||
options = { | options = { | ||
color = nil, | color = nil, | ||
Line 73: | Line 73: | ||
end | end | ||
function suite: | function suite:testFormattedValue06() | ||
options = { | options = { | ||
color = nil, | color = nil, | ||
Line 83: | Line 83: | ||
end | end | ||
function suite: | function suite:testFormattedValue07() | ||
options = { | options = { | ||
color = false, | color = false, | ||
Line 93: | Line 93: | ||
end | end | ||
function suite: | function suite:testFormattedValue08() | ||
options = { | options = { | ||
color = false, | color = false, | ||
Line 103: | Line 103: | ||
end | end | ||
function suite: | function suite:testFormattedValue09() | ||
options = { | options = { | ||
color = false, | color = false, |
Latest revision as of 19:34, 4 January 2024
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