Module:Icon/testcases: Difference between revisions
Appearance
Content deleted Content added
make it clearer what we are running |
move declarations to the top |
||
Line 1: | Line 1: | ||
local mIcon = require('Module:Icon') |
local mIcon = require('Module:Icon') |
||
⚫ | |||
⚫ | |||
⚫ | |||
-- This function is used to run all the instances of Icon, so that we can easily |
-- This function is used to run all the instances of Icon, so that we can easily |
||
Line 7: | Line 10: | ||
return mIcon._main(args) |
return mIcon._main(args) |
||
end |
end |
||
⚫ | |||
⚫ | |||
⚫ | |||
local fileLinkPattern |
local fileLinkPattern |
Revision as of 10:28, 23 January 2015
![]() | This is the test cases page for the module Module:Icon. Results of the test cases. |
local mIcon = require('Module:Icon')
local ScribuntoUnit = require('Module:ScribuntoUnit')
local suite = ScribuntoUnit:new()
local frame = mw.getCurrentFrame()
-- This function is used to run all the instances of Icon, so that we can easily
-- switch between the module and the template.
local function icon(args)
-- return frame:expandTemplate{title = 'icon/sandbox', args = args}
return mIcon._main(args)
end
local fileLinkPattern
do
local spaces = '[_ \t]*'
local titleChar = '[^|<>%[%]{}]'
local titleCharOrPipe = '[^<>%[%]{}]'
fileLinkPattern = '^%[%[' .. spaces .. '(.-)' .. spaces .. ':' .. spaces ..
titleChar .. '-' .. titleCharOrPipe .. '-|' .. titleChar .. '-|' ..
spaces .. 'link=' .. spaces .. '%]%]$'
end
function suite:assertFileLink(s)
local nsText = s:match(fileLinkPattern)
nsText = nsText and nsText:lower()
self:assertTrue(nsText == 'file' or nsText == 'image')
end
function suite:testIsFileLink()
self:assertFileLink(icon{})
self:assertFileLink(icon{'fa'})
self:assertFileLink(icon{'qwertyuiop'})
end
function suite:testGA()
self:assertStringContains('Symbol support vote.svg', icon{'ga'}, true)
self:assertStringContains('Good article', icon{'ga'}, true)
end
function suite:testDefaultSize()
self:assertStringContains('16x16px', icon{})
end
function suite:testCustomSize()
self:assertStringContains('320px', icon{size = '320px'})
end
function suite:testAlias()
self:assertStringContains('Former featured article', icon{'dfa'})
end
function suite:testCodeWhitespace()
self:assertStringContains('Featured article', icon{' fa '})
end
function suite:testCodeCapitalization()
self:assertStringContains('Featured article', icon{'FA'})
end
function suite:testClassParameter()
self:assertStringContains('Featured article', icon{class = 'fa'})
end
function suite:testClassParameterOverride()
self:assertNotStringContains('Featured article', icon{'fa', class = 'ga'})
self:assertNotStringContains('Featured article', icon{'fa', class = ''})
end
return suite