モジュール:サンドボックス/Ef3/ExLink/testcases

local p = require('Module:UnitTests')

local ExLink = require('Module:サンドボックス/Ef3/ExLink')
local el = ExLink.new()

local function check(self, f, ...)
	local e, r = pcall(f, self, ...)
	return r
end

function p:test_001()
	self:preprocess_equals_many('', '', {
-- ExLink:propValue()
		{ "wikipedia",						check(el, el.propValue, "P2002", "Q52")},
		{ "https://twitter.com/$1",			check(el, el.propValue, "P1630", "P2002")},
		{ "(nil) no found in wiki data",	check(el, el.propValue) },
-- ExLink:id()
		{ "id and idProp no found",			check(el, el.id)},
-- ExLink:formatterURL()
		{ "(nil) no found in wiki data",	check(el, el.formatterURL)},
-- ExLink:url()
		{ "(nil) no found in wiki data",	check(el, el.url)},
-- ExLink:PAGENAME()
		{ "{{PAGENAME}}",					check(el, el.PAGENAME)},
-- ExLink:PAGENAMEBASE()
		{ "{{PAGENAMEBASE}}",				check(el, el.PAGENAMEBASE)},
		{ "{{PAGENAMEBASE|foo (bar)}}",		check(el, el.PAGENAMEBASE, "foo (bar)")},
},{nowiki=1})
end

return p