Module:Sandbox/Vinifera7/test2/testcases: Difference between revisions

From Path of Exile Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
Line 23: Line 23:
}
}


function suite:testFormattedValue1()
function suite:testFormattedValue01()
     options = {
     options = {
         color = nil,
         color = nil,
Line 33: Line 33:
end
end


function suite:testFormattedValue2()
function suite:testFormattedValue02()
     options = {
     options = {
         color = false,
         color = false,
Line 43: Line 43:
end
end


function suite:testFormattedValue3()
function suite:testFormattedValue03()
     options = {
     options = {
         color = 'fire',
         color = 'fire',
Line 53: Line 53:
end
end


function suite:testFormattedValue4()
function suite:testFormattedValue04()
     options = {
     options = {
         color = nil,
         color = nil,
Line 63: Line 63:
end
end


function suite:testFormattedValue5()
function suite:testFormattedValue05()
     options = {
     options = {
         color = nil,
         color = nil,
Line 73: Line 73:
end
end


function suite:testFormattedValue6()
function suite:testFormattedValue06()
     options = {
     options = {
         color = nil,
         color = nil,
Line 83: Line 83:
end
end


function suite:testFormattedValue7()
function suite:testFormattedValue07()
     options = {
     options = {
         color = false,
         color = false,
Line 93: Line 93:
end
end


function suite:testFormattedValue8()
function suite:testFormattedValue08()
     options = {
     options = {
         color = false,
         color = false,
Line 103: Line 103:
end
end


function suite:testFormattedValue9()
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.

YesY All tests passed.

Name Expected Actual
YesY testFormattedValue01
YesY testFormattedValue02
YesY testFormattedValue03
YesY testFormattedValue04
YesY testFormattedValue05
YesY testFormattedValue06
YesY testFormattedValue07
YesY testFormattedValue08
YesY testFormattedValue09
YesY testFormattedValue10
YesY testFormattedValue11
YesY 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