< Module:Storm categories
local ScribuntoUnit = require('Module:ScribuntoUnit')
local sc = require('Module:Storm categories/sandbox') -- the module to be tested
local 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('disturbance')))
self:assertFalse('c0c0c0' == string.lower(sc._color('depression')))
self:assertFalse('c0c0c0' == string.lower(sc._color('storm')))
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('cat1')))
self:assertFalse('c0c0c0' == string.lower(sc._color('cat2')))
self:assertFalse('c0c0c0' == string.lower(sc._color('cat3')))
self:assertFalse('c0c0c0' == string.lower(sc._color('cat4')))
self:assertFalse('c0c0c0' == string.lower(sc._color('cat5')))
-- nullIfMissing
self:assertEquals(nil, sc._color('not-an-actual-category', true))
self:assertFalse(nil == 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('disturbance'))
self:assertFalse('Unknown-strength storm' == sc._name('depression'))
self:assertFalse('Unknown-strength storm' == sc._name('storm'))
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('cat1'))
self:assertFalse('Unknown-strength storm' == sc._name('cat2'))
self:assertFalse('Unknown-strength storm' == sc._name('cat3'))
self:assertFalse('Unknown-strength storm' == sc._name('cat4'))
self:assertFalse('Unknown-strength storm' == sc._name('cat5'))
-- Basin differences
self:assertFalse(sc._name('cat1') == sc._name('cat1', 'atl'))
self:assertFalse(sc._name('cat1') == sc._name('cat1', 'wpac'))
-- Default fallback
self:assertEquals(sc._name('cat1', 'default'), sc._name('cat1', 'basin-that-does-not-exist'))
-- nullIfMissing
self:assertEquals(nil, sc._name('not-an-actual-category', nil, true))
self:assertFalse(nil == sc._name('cat1', nil, true))
self:assertFalse(nil == sc._name('cat1', 'atl', 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('disturbance'))
self:assertFalse(0 == sc._sortkey('depression'))
self:assertFalse(0 == sc._sortkey('storm'))
self:assertFalse(0 == sc._sortkey('sts'))
-- Ensure that none of the SSHWS scale colors are falling back to default.
self:assertFalse(0 == sc._sortkey('cat1'))
self:assertFalse(0 == sc._sortkey('cat2'))
self:assertFalse(0 == sc._sortkey('cat3'))
self:assertFalse(0 == sc._sortkey('cat4'))
self:assertFalse(0 == sc._sortkey('cat5'))
-- Ensure that sortkeys are following the proper order.
self:assertTrue(sc._sortkey('cat4') < sc._sortkey('cat5'))
self:assertTrue(sc._sortkey('cat3') < sc._sortkey('cat4'))
self:assertTrue(sc._sortkey('cat2') < sc._sortkey('cat3'))
self:assertTrue(sc._sortkey('cat1') < sc._sortkey('cat2'))
self:assertTrue(sc._sortkey('sts') < sc._sortkey('cat1'))
self:assertTrue(sc._sortkey('storm') < sc._sortkey('sts'))
self:assertTrue(sc._sortkey('depression') < sc._sortkey('storm'))
self:assertTrue(sc._sortkey('disturbance') < sc._sortkey('depression'))
self:assertTrue(sc._sortkey('unknown') < sc._sortkey('disturbance'))
-- nullIfMissing
self:assertEquals(nil, sc._sortkey('not-an-actual-category', true))
self:assertFalse(nil == 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('disturbance'))
self:assertFalse("'''?'''" == sc._icon('depression'))
self:assertFalse("'''?'''" == sc._icon('storm'))
self:assertFalse("'''?'''" == sc._icon('sts'))
-- Ensure that none of the SSHWS scale colors are falling back to default.
self:assertFalse("'''?'''" == sc._icon('cat1'))
self:assertFalse("'''?'''" == sc._icon('cat2'))
self:assertFalse("'''?'''" == sc._icon('cat3'))
self:assertFalse("'''?'''" == sc._icon('cat4'))
self:assertFalse("'''?'''" == sc._icon('cat5'))
-- nullIfMissing
self:assertEquals(nil, sc._icon('not-an-actual-category', true))
self:assertFalse(nil == 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"))
--== EDGE CASES
-- Only one category exists
self:assertFalse(sc._isEqual("depression", "not-an-actual-category"))
-- None of the categories exist
self:assertFalse(sc._isEqual("not-an-actual-category", "also-not-an-actual-category"))
-- None of the categories exist but the IDs are equal
self:assertTrue(sc._isEqual("not-an-actual-category", "not-an-actual-category"))
-- Nil argument 1
self:assertFalse(sc._isEqual(nil, "not-an-actual-category"))
-- Nil argument 2
self:assertFalse(sc._isEqual("not-an-actual-category", nil))
-- Nil arguments (but equal)
self:assertFalse(sc._isEqual(nil, nil))
-- Missing argument 2
self:assertFalse(sc._isEqual("not-an-actual-category"))
-- Missing arguments
self:assertFalse(sc._isEqual())
end
return suite
Category :
Text is available under the Creative Commons Attribution-ShareAlike License. Additional terms may apply.
**DISCLAIMER** We are not affiliated with Wikipedia, and Cloudflare.
The information presented on this site is for general informational purposes only and does not constitute medical advice.
You should always have a personal consultation with a healthcare professional before making changes to your diet, medication, or exercise routine.
AI helps with the correspondence in our chat.
We participate in an affiliate program. If you buy something through a link, we may earn a commission 💕
↑