Module:Icon/testcases: Difference between revisions
Appearance
Content deleted Content added
only make the file link pattern once |
make it clearer what we are running |
||
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 |
|||
-- switch between the module and the template. |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
local ScribuntoUnit = require('Module:ScribuntoUnit') |
local ScribuntoUnit = require('Module:ScribuntoUnit') |
||
local suite = ScribuntoUnit:new() |
local suite = ScribuntoUnit:new() |
||
Line 12: | Line 20: | ||
titleChar .. '-' .. titleCharOrPipe .. '-|' .. titleChar .. '-|' .. |
titleChar .. '-' .. titleCharOrPipe .. '-|' .. titleChar .. '-|' .. |
||
spaces .. 'link=' .. spaces .. '%]%]$' |
spaces .. 'link=' .. spaces .. '%]%]$' |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
end |
end |
||
Revision as of 10:09, 23 January 2015
![]() | This is the test cases page for the module Module:Icon. Results of the test cases. |
local mIcon = require('Module:Icon')
-- 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 ScribuntoUnit = require('Module:ScribuntoUnit')
local suite = ScribuntoUnit:new()
local frame = mw.getCurrentFrame()
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