Module:Book link/testcases

From Wikisource
Jump to navigation Jump to search
local p = require('Module:UnitTests')
local BookLink = require('Module:Book link')
local Creator = require('Module:Creator')

function p:test_edition()
	local testCaseName = 'An edition'
	local params = {
		title = 'My Title',
		authors = {
			Creator.newCreator( 'Q37160' ) -- David Hume
		},
		year = 1234
	}
	local expected = '<span class="wst-worklink"><span class="wst-worklink-title">[[My Title|My Title]]</span> by <span class="wst-worklink-authors"><span class="wst-worklink-creator">[[Author:David Hume|David Hume]]</span></span> (<span class="wst-worklink-date">1234</span>)</span>'
	
	local link = BookLink.renderLink( params )
	
	self:equals( testCaseName, tostring( link ), expected, { nowiki = true } )
end

return p