Module:Icon/testcases: Difference between revisions
Appearance
Content deleted Content added
create |
only make the file link pattern once |
||
Line 4: | Line 4: | ||
local frame = mw.getCurrentFrame() |
local frame = mw.getCurrentFrame() |
||
local |
local fileLinkPattern |
||
do |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
local spaces = '[_ \t]*' |
local spaces = '[_ \t]*' |
||
local titleChar = '[^|<>%[%]{}]' |
local titleChar = '[^|<>%[%]{}]' |
||
local titleCharOrPipe = '[^<>%[%]{}]' |
local titleCharOrPipe = '[^<>%[%]{}]' |
||
fileLinkPattern = '^%[%[' .. spaces .. '(.-)' .. spaces .. ':' .. spaces .. |
|||
titleChar .. '-' .. titleCharOrPipe .. '-|' .. titleChar .. '-|' .. |
titleChar .. '-' .. titleCharOrPipe .. '-|' .. titleChar .. '-|' .. |
||
spaces .. 'link=' .. spaces .. '%]%]$' |
spaces .. 'link=' .. spaces .. '%]%]$' |
||
⚫ | |||
⚫ | |||
local function icon(args) |
|||
⚫ | |||
⚫ | |||
end |
|||
⚫ | |||
⚫ | |||
nsText = nsText and nsText:lower() |
nsText = nsText and nsText:lower() |
||
self:assertTrue(nsText == 'file' or nsText == 'image') |
self:assertTrue(nsText == 'file' or nsText == 'image') |
Revision as of 10:07, 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()
local fileLinkPattern
do
local spaces = '[_ \t]*'
local titleChar = '[^|<>%[%]{}]'
local titleCharOrPipe = '[^<>%[%]{}]'
fileLinkPattern = '^%[%[' .. spaces .. '(.-)' .. spaces .. ':' .. spaces ..
titleChar .. '-' .. titleCharOrPipe .. '-|' .. titleChar .. '-|' ..
spaces .. 'link=' .. spaces .. '%]%]$'
end
local function icon(args)
return frame:expandTemplate{title = 'icon/sandbox', args = args}
-- return mIcon._main(args)
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