local ScribuntoUnit = require('Module:ScribuntoUnit')local sc = require('Module:Storm categories/sandbox') -- the module to be testedlocal suite = ScribuntoUnit:new
function suite:testColors self:assertEquals('c0c0c0', string.lower(sc._color)) self:assertEquals('c0c0c0', string.lower(sc._color(nil))) -- Ensure that none of the global scale colors are falling back to default. self:assertFalse('c0c0c0'
string.lower(sc._color('depression'))) self:assertFalse('c0c0c0'
string.lower(sc._color('sts'))) -- Ensure that none of the SSHWS scale colors are falling back to default. self:assertFalse('c0c0c0'
string.lower(sc._color('cat2'))) self:assertFalse('c0c0c0'
string.lower(sc._color('cat4'))) self:assertFalse('c0c0c0'
sc._color('cat1', true))end
function suite:testNames self:assertEquals('Unknown-strength storm', sc._name) self:assertEquals('Unknown-strength storm', sc._name(nil)) -- Ensure that none of the global scale colors are falling back to default. self:assertFalse('Unknown-strength storm'
sc._name('depression')) self:assertFalse('Unknown-strength storm'
sc._name('sts')) -- Ensure that none of the SSHWS scale colors are falling back to default. self:assertFalse('Unknown-strength storm'
sc._name('cat2')) self:assertFalse('Unknown-strength storm'
sc._name('cat4')) self:assertFalse('Unknown-strength storm'
sc._name('cat1', 'atl')) self:assertFalse(sc._name('cat1')
sc._name('cat1', nil, true)) self:assertFalse(nil
sc._name('cat1', 'wpac', true))end
function suite:testSortkey self:assertEquals(0, sc._sortkey) self:assertEquals(0, sc._sortkey(nil)) -- Ensure that none of the global scale colors are falling back to default. self:assertFalse(0
sc._sortkey('depression')) self:assertFalse(0
sc._sortkey('sts')) -- Ensure that none of the SSHWS scale colors are falling back to default. self:assertFalse(0
sc._sortkey('cat2')) self:assertFalse(0
sc._sortkey('cat4')) self:assertFalse(0
sc._sortkey('cat1', true))end
function suite:testIcons self:assertEquals("?", sc._icon) self:assertEquals("?", sc._icon(nil)) -- Ensure that none of the global scale colors are falling back to default. self:assertFalse("?"
sc._icon('depression')) self:assertFalse("?"
sc._icon('sts')) -- Ensure that none of the SSHWS scale colors are falling back to default. self:assertFalse("?"
sc._icon('cat2')) self:assertFalse("?"
sc._icon('cat4')) self:assertFalse("?"
sc._icon('cat1', true))end
function suite:testIsEqual -- Equal existing categories self:assertTrue(sc._isEqual("depression", "depression")) -- Equal aliases self:assertTrue(sc._isEqual("depression", "td")) self:assertTrue(sc._isEqual("severets", "severe")) self:assertTrue(sc._isEqual("shdepression", "depression")) -- Not equal existing categories self:assertFalse(sc._isEqual("depression", "unknown")) self:assertFalse(sc._isEqual("depression", "cat5")) self:assertFalse(sc._isEqual("unknown", "cat5")) -- '5' is a generic ID that only has a color and an self:assertFalse(sc._isEqual("5", "cat5")) self:assertFalse(sc._isEqual("a5", "aus5")) self:assertFalse(sc._isEqual("aus5", "cat5")) --
return suite