Module:Header/attribution/testcases
Appearance
This is the test cases page for the module Module:Header/attribution. Results of the test cases. |
require('strict')
local mfMain = require('Module:Header/attribution').construct_microformat
local mfSandbox = require('Module:Header/attribution/sandbox').construct_microformat
local ScribuntoUnit = require('Module:ScribuntoUnit')
local suite = ScribuntoUnit:new()
local TableTools = require('Module:TableTools')
-- convenience function
function suite:checkArgs(argKey, translation)
local argTable = {
testEmptyArgs = {},
testMultiAuthor = {
['title'] = 'The Federalist',
['author1'] = 'Alexander Hamilton',
['author2'] = 'John Jay (1745-1829)',
['author3'] = 'James Madison',
['previous'] = '[[Constitution of the United States of America|United States Constitution]]',
['year'] = '1788',
['wikipedia'] = 'Federalist Papers',
['portal'] = 'United States',
['notes'] = '\'\'The Federalist\'\' is a collection of 85 articles arguing for the ratification of the [[Constitution of the United States of America|United States Constitution]]. They were first published serially in New York City newspapers in 1787 and 1788.<br />Many different editions of \'\'The Federalist\'\' exist, and among those editions there is some discrepancy in essay number and order. The numbering below reflects the commonly accepted modern numbering.<br />{{media|key = y |type = spoken}}'
},
testMultiTranslator = {
['title'] = 'Pantagruel',
['author'] = 'François Rabelais',
['translator1'] = 'Thomas Urquhart',
['translator2'] = 'Peter Antony Motteux',
['portal'] = 'United States'
},
testOverrides = {
['title'] = 'Einstein',
['override-author'] = 'Einstein\'s Father',
['override-translator'] = '[[Author:Robert Louis Stevenson|Robert Louis Stevenson]]',
['shortcut'] = '[[EB1911]]',
['wikipedia'] = 'Kinematics of Machinery',
['commonscat'] = 'Kinematics of Machinery',
['portal'] = 'United States/Science'
},
testSpecialCases = {
['title'] = 'Einstein',
['author'] = 'Einstein\'s Father',
['author-nolink'] = 'true',
['translator'] = 'Wikisource',
['editor'] = 'unknown',
['year'] = '1901'
},
testContributors = {
['title'] = 'A Nonexistent Work',
['author'] = 'anon',
['contributor'] = 'John Smith',
['contributing-translator'] = 'Charles Dickens',
['section'] = 'First line',
['attributed-to'] = 'Patrick',
['adapter'] = 'Cecil Frances Alexander'
},
testEO = {
['header_class'] = 'wst-potus-eo plainlinks',
['title'] = 'Executive Order 10028',
['author'] = '[[Portal:Presidents of the United States|President of the United States]]',
['author-nolink'] = 'true',
['section'] = 'Definition of Noncombatant Service and Noncombatant Training',
['previous'] = '[[Executive Order 10027]]',
['next'] = '[[Executive Order 10029]]'
}
}
local args = TableTools.shallowClone(argTable[argKey])
if translation then
args.template_name = 'Translation header'
end
self:assertEquals(mfMain(args), mfSandbox(args))
end
-- tests
function suite:testEmptyArgs()
suite:checkArgs('testEmptyArgs', false)
end
function suite:testEmptyArgsTrans()
suite:checkArgs('testEmptyArgs', true)
end
function suite:testMultiAuthor()
suite:checkArgs('testMultiAuthor', false)
end
function suite:testMultiAuthorTrans()
suite:checkArgs('testMultiAuthor', true)
end
function suite:testMultiTranslator()
suite:checkArgs('testMultiTranslator', false)
end
function suite:testMultiTranslatorTrans()
suite:checkArgs('testMultiTranslator', true)
end
function suite:testOverrides()
suite:checkArgs('testOverrides', false)
end
function suite:testOverridesTrans()
suite:checkArgs('testOverrides', true)
end
function suite:testSpecialCases()
suite:checkArgs('testSpecialCases', false)
end
function suite:testSpecialCasesTrans()
suite:checkArgs('testSpecialCases', true)
end
function suite:testContributors()
suite:checkArgs('testContributors', false)
end
function suite:testContributorsTrans()
suite:checkArgs('testContributors', true)
end
function suite:testEO()
suite:checkArgs('testEO', false)
end
function suite:testEOTrans()
suite:checkArgs('testEO', true)
end
return suite