<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://stockhub.co/index.php?action=history&amp;feed=atom&amp;title=Module%3AReply_to%2Ftestcases</id>
	<title>Module:Reply to/testcases - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://stockhub.co/index.php?action=history&amp;feed=atom&amp;title=Module%3AReply_to%2Ftestcases"/>
	<link rel="alternate" type="text/html" href="https://stockhub.co/index.php?title=Module:Reply_to/testcases&amp;action=history"/>
	<updated>2026-06-07T04:22:54Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.5</generator>
	<entry>
		<id>https://stockhub.co/index.php?title=Module:Reply_to/testcases&amp;diff=144643&amp;oldid=prev</id>
		<title>imported&gt;Ahecht: desired output doesn&#039;t have extra spaces</title>
		<link rel="alternate" type="text/html" href="https://stockhub.co/index.php?title=Module:Reply_to/testcases&amp;diff=144643&amp;oldid=prev"/>
		<updated>2022-03-30T18:14:50Z</updated>

		<summary type="html">&lt;p&gt;desired output doesn&amp;#039;t have extra spaces&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;local libName = &amp;#039;Module:Reply to&amp;#039;&lt;br /&gt;
local ScribuntoUnit = require(&amp;#039;Module:ScribuntoUnit&amp;#039;)&lt;br /&gt;
local suite = ScribuntoUnit:new()&lt;br /&gt;
local frame = mw.getCurrentFrame()&lt;br /&gt;
&lt;br /&gt;
-- Helper to run all tests using sandbox version of the library from the debug console. To run against main lib, use =p.run()&lt;br /&gt;
function suite.runSandbox()&lt;br /&gt;
	return suite.run(frame:newChild{&lt;br /&gt;
		title = libName .. &amp;#039;/testcases&amp;#039;,&lt;br /&gt;
		args = {&lt;br /&gt;
			module = libName .. &amp;#039;/sandbox&amp;#039;,&lt;br /&gt;
			displayMode = &amp;#039;log&amp;#039;&lt;br /&gt;
		},&lt;br /&gt;
	})&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Allow test runner to use both the main library and the sandbox of the library with the same testcases&lt;br /&gt;
function suite:module()&lt;br /&gt;
	return self.frame and self.frame.args.module or libName&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
-- Helper functions&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
local function makeFrameWithParentArgs(args)&lt;br /&gt;
	local parent = frame:newChild{title = &amp;#039;Template:Reply to&amp;#039;, args = args}&lt;br /&gt;
	local child = parent:newChild{title = &amp;#039;Module:Reply to&amp;#039;}&lt;br /&gt;
	return child&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function replyTo(args)&lt;br /&gt;
	return require(suite:module()).replyto(makeFrameWithParentArgs(args))&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Returns an array of n unique strings.&lt;br /&gt;
local function makeNUniqueStrings(n)&lt;br /&gt;
	local ret = {}&lt;br /&gt;
	for i = 1, n do&lt;br /&gt;
		ret[i] = tostring(i)&lt;br /&gt;
	end&lt;br /&gt;
	return ret&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function suite:assertHtmlError(pattern, output)&lt;br /&gt;
	pattern = &amp;#039;^&amp;lt;strong class=&amp;quot;error&amp;quot;&amp;gt;Error in %[%[Template:Reply to%]%]: &amp;#039; .. pattern .. &amp;#039;.&amp;lt;/strong&amp;gt;$&amp;#039;&lt;br /&gt;
	self:assertStringContains(pattern, output)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function suite:assertContentEquals(expected, actual)&lt;br /&gt;
	expected = &amp;#039;&amp;lt;span class=&amp;quot;template-ping&amp;quot;&amp;gt;&amp;#039; .. expected .. &amp;#039;&amp;lt;/span&amp;gt;&amp;#039;&lt;br /&gt;
	self:assertEquals(mw.text.trim(expected), mw.text.trim(actual))&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
-- Error tests&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
function suite:testNoUsernamesError()&lt;br /&gt;
	self:assertHtmlError(&amp;#039;Username not given&amp;#039;, replyTo{})&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function suite:testInvalidUsernameError()&lt;br /&gt;
	self:assertHtmlError(&amp;quot;Input contains forbidden characters&amp;quot;, replyTo{&amp;#039;Examp|le&amp;#039;})&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function suite:testTooManyUsernamesError()&lt;br /&gt;
	self:assertHtmlError(&lt;br /&gt;
		&amp;#039;More than %d+ names specified&amp;#039;,&lt;br /&gt;
		replyTo(makeNUniqueStrings(1000)) -- The limit is probably always going to be lower than 1000&lt;br /&gt;
	)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
-- Test defaults&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
function suite:testOneUsername()&lt;br /&gt;
	self:assertContentEquals(&lt;br /&gt;
		&amp;#039;@[[User:Example|Example]]:&amp;#039;,&lt;br /&gt;
		replyTo{&amp;#039;Example&amp;#039;}&lt;br /&gt;
	)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function suite:testTwoUsernames()&lt;br /&gt;
	self:assertContentEquals(&lt;br /&gt;
		&amp;#039;@[[User:Example|Example]] and [[User:Example2|Example2]]:&amp;#039;,&lt;br /&gt;
		replyTo{&amp;#039;Example&amp;#039;, &amp;#039;Example2&amp;#039;}&lt;br /&gt;
	)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function suite:testThreeUsernames()&lt;br /&gt;
	self:assertContentEquals(&lt;br /&gt;
		&amp;#039;@[[User:Example|Example]], [[User:Example2|Example2]], and [[User:Example3|Example3]]:&amp;#039;,&lt;br /&gt;
		replyTo{&amp;#039;Example&amp;#039;, &amp;#039;Example2&amp;#039;, &amp;#039;Example3&amp;#039;}&lt;br /&gt;
	)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function suite:testFourUsernames()&lt;br /&gt;
	self:assertContentEquals(&lt;br /&gt;
		&amp;#039;@[[User:Example|Example]], [[User:Example2|Example2]], [[User:Example3|Example3]], and [[User:Example4|Example4]]:&amp;#039;,&lt;br /&gt;
		replyTo{&amp;#039;Example&amp;#039;, &amp;#039;Example2&amp;#039;, &amp;#039;Example3&amp;#039;, &amp;#039;Example4&amp;#039;}&lt;br /&gt;
	)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
-- Test labels&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
function suite:testLabel()&lt;br /&gt;
	self:assertContentEquals(&lt;br /&gt;
		&amp;#039;@[[User:Example|Foo]]:&amp;#039;,&lt;br /&gt;
		replyTo{[1] = &amp;#039;Example&amp;#039;, label = &amp;#039;Foo&amp;#039;}&lt;br /&gt;
	)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function suite:testLabel1()&lt;br /&gt;
	self:assertContentEquals(&lt;br /&gt;
		&amp;#039;@[[User:Example|Foo]]:&amp;#039;,&lt;br /&gt;
		replyTo{[1] = &amp;#039;Example&amp;#039;, label1 = &amp;#039;Foo&amp;#039;}&lt;br /&gt;
	)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function suite:testTwoLabels()&lt;br /&gt;
	self:assertContentEquals(&lt;br /&gt;
		&amp;#039;@[[User:Example|Foo]] and [[User:Example2|Bar]]:&amp;#039;,&lt;br /&gt;
		replyTo{[1] = &amp;#039;Example&amp;#039;, label1 = &amp;#039;Foo&amp;#039;, [2] = &amp;#039;Example2&amp;#039;, label2 = &amp;#039;Bar&amp;#039;}&lt;br /&gt;
	)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function suite:testThreeLabels()&lt;br /&gt;
	self:assertContentEquals(&lt;br /&gt;
		&amp;#039;@[[User:Example|Foo]], [[User:Example2|Bar]], and [[User:Example3|Baz]]:&amp;#039;,&lt;br /&gt;
		replyTo{[1] = &amp;#039;Example&amp;#039;, label1 = &amp;#039;Foo&amp;#039;, [2] = &amp;#039;Example2&amp;#039;, label2 = &amp;#039;Bar&amp;#039;, [3] = &amp;#039;Example3&amp;#039;, label3 = &amp;#039;Baz&amp;#039;}&lt;br /&gt;
	)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
-- Test special formatting&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
function suite:testPrefix()&lt;br /&gt;
	self:assertContentEquals(&lt;br /&gt;
		&amp;#039;foo[[User:Example|Example]]:&amp;#039;,&lt;br /&gt;
		replyTo{&amp;#039;Example&amp;#039;, prefix = &amp;#039;foo&amp;#039;}&lt;br /&gt;
	)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function suite:testBlankPrefix()&lt;br /&gt;
	self:assertContentEquals(&lt;br /&gt;
		&amp;#039;[[User:Example|Example]]:&amp;#039;,&lt;br /&gt;
		replyTo{&amp;#039;Example&amp;#039;, prefix = &amp;#039;&amp;#039;}&lt;br /&gt;
	)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function suite:testConjunction()&lt;br /&gt;
	self:assertContentEquals(&lt;br /&gt;
		&amp;#039;@[[User:Example|Example]], [[User:Example2|Example2]], foo [[User:Example3|Example3]]:&amp;#039;,&lt;br /&gt;
		replyTo{&amp;#039;Example&amp;#039;, &amp;#039;Example2&amp;#039;, &amp;#039;Example3&amp;#039;, c = &amp;#039;foo&amp;#039;}&lt;br /&gt;
	)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function suite:testBlankConjunction()&lt;br /&gt;
	self:assertContentEquals(&lt;br /&gt;
		&amp;#039;@[[User:Example|Example]], [[User:Example2|Example2]], [[User:Example3|Example3]]:&amp;#039;,&lt;br /&gt;
		replyTo{&amp;#039;Example&amp;#039;, &amp;#039;Example2&amp;#039;, &amp;#039;Example3&amp;#039;, c = &amp;#039;&amp;#039;}&lt;br /&gt;
	)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function suite:testPunctuation()&lt;br /&gt;
	self:assertContentEquals(&lt;br /&gt;
		&amp;#039;@[[User:Example|Example]]foo&amp;#039;,&lt;br /&gt;
		replyTo{&amp;#039;Example&amp;#039;, p = &amp;#039;foo&amp;#039;}&lt;br /&gt;
	)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function suite:testBlankPunctuation()&lt;br /&gt;
	self:assertContentEquals(&lt;br /&gt;
		&amp;#039;@[[User:Example|Example]]&amp;#039;,&lt;br /&gt;
		replyTo{&amp;#039;Example&amp;#039;, p = &amp;#039;&amp;#039;}&lt;br /&gt;
	)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
-- Test non-standard parameter orders&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
function suite:testNoFirstParam()&lt;br /&gt;
	self:assertContentEquals(&lt;br /&gt;
		&amp;#039;@[[User:Example|Example]]:&amp;#039;,&lt;br /&gt;
		replyTo{[2] = &amp;#039;Example&amp;#039;}&lt;br /&gt;
	)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function suite:testNoFirstParamWithLabel()&lt;br /&gt;
	self:assertContentEquals(&lt;br /&gt;
		&amp;#039;@[[User:Example|Example]]:&amp;#039;,&lt;br /&gt;
		replyTo{[2] = &amp;#039;Example&amp;#039;, label = &amp;#039;Foo&amp;#039;}&lt;br /&gt;
	)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function suite:testNoFirstParamWithLabel2()&lt;br /&gt;
	self:assertContentEquals(&lt;br /&gt;
		&amp;#039;@[[User:Example|Foo]]:&amp;#039;,&lt;br /&gt;
		replyTo{[2] = &amp;#039;Example&amp;#039;, label2 = &amp;#039;Foo&amp;#039;}&lt;br /&gt;
	)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return suite&lt;/div&gt;</summary>
		<author><name>imported&gt;Ahecht</name></author>
	</entry>
</feed>