-- Unit tests for . Click talk page to run tests.local mapframeModule = require('Module:Mapframe/sandbox').test -- the module to be testedlocal ScribuntoUnit = require('Module:ScribuntoUnit')local suite = ScribuntoUnit:new
function suite:testGetParameterValue -- @params args, param_id, [{Number}suffix] -- @returns local args = self:assertEquals("foo", mapframeModule.getParameterValue(args, "display"), "arg without suffix") self:assertEquals("bar", mapframeModule.getParameterValue(args, "type"), "arg without suffix (where there is also a same-named arg with a suffix)") self:assertEquals("bar2", mapframeModule.getParameterValue(args, "type", 2), "arg with suffix") self:assertEquals(nil, mapframeModule.getParameterValue(args, "type", 3), "arg with suffix not present (same-named arg with different suffix is present)") self:assertEquals(nil, mapframeModule.getParameterValue(args, "display", 3), "arg with suffix not present (same-named arg without any suffix is present)") self:assertEquals(nil, mapframeModule.getParameterValue(args, "id"), "arg not present") self:assertEquals(nil, mapframeModule.getParameterValue(args, "id", 3), "-- arg with suffix not present (no same-named arg with or without any suffix)")end
function suite:testTrimArgs -- @param argsTable -- @returns local args = local expected = self:assertDeepEquals(expected, mapframeModule.trimArgs(args))end
function suite:testIsAffirmed -- @param val -- @returns local affirmWords = local otherWords = for _, word in pairs(affirmWords) do self:assertTrue(mapframeModule.isAffirmed(word)) end for _, word in pairs(otherWords) do self:assertFalse(mapframeModule.isAffirmed(word)) endend
function suite:testIsDeclined -- @param val -- @returns local declineWords = local otherWords = for _, word in pairs(declineWords) do self:assertTrue(mapframeModule.isDeclined(word)) end for _, word in pairs(otherWords) do self:assertFalse(mapframeModule.isDeclined(word)) endend
return suite