dev

This module contains testcases for its parent module, Section link.

See also


-- Unit tests for [[Module:Section link]] to be executed by [[Module:Testharness]].
-- Test results are available on [[Module talk:Section link/testcases]].

return {
	['_main'] = {
		options = {
			mode = 'method',
			nowiki = true,
			unpk = true,
		},
		tests = {
			{
				{},
				'[[#Notes|Module talk:Section link/testcases § Notes]]',
			},
			{
				{0},
				"bad argument #1 to '_main' (string expected, got number)",
				{ err = true }
			},
			{
				{'Foo'},
				'[[Foo#Notes|Foo § Notes]]',
			},
			{
				{'Foo', {}},
				'[[Foo#Notes|Foo § Notes]]',
			},
			{
				{'Foo', nil, 0},
				"bad argument #3 to '_main' (table expected, got number)",
				{ err = true }
			},
			{
				{'Foo', nil, { nopage = true }},
				'[[Foo#Notes|§ Notes]]',
			},
			{
				{'Foo', 'Bar'},
				'[[Foo#Bar|Foo § Bar]]',
			},
			{
				{'Foo', {'Bar'}},
				'[[Foo#Bar|Foo § Bar]]',
			},
			{
				{'Foo', {'Bar', 'Baz'}},
				'Foo §§ [[Foo#Bar|Bar]]​ and [[Foo#Baz|Baz]]',
			},
			{
				{'Foo', {'Bar'}, { display = "''Foo''" }},
				"[[Foo#Bar|''Foo'' § Bar]]",
			},
			{
				{'Foo', 'Baz', nil, mw.title.new('Bar')},
				'[[Foo#Baz|Foo § Baz]]',
			},
			{
				{nil, 'Baz', nil, mw.title.new('Bar')},
				'[[#Baz|Bar § Baz]]',
			},
		}
	},
	['main'] = {
		options = {
			mode = 'invocation',
			nowiki = true
		},
		tests = {
			{
				'',
				'[[#Notes|Module talk:Section link/testcases § Notes]]',
			},
			{
				'Foo',
				'[[Foo#Notes|Foo § Notes]]',
			},
			{
				'Foo|nopage=0',
				'[[Foo#Notes|Foo § Notes]]',
			},
			{
				'Foo|nopage=1',
				'[[Foo#Notes|§ Notes]]',
			},
			{
				'Foo|nopage=yes',
				'[[Foo#Notes|§ Notes]]',
			},
			{
				'Foo|nopage=no',
				'[[Foo#Notes|Foo § Notes]]',
			},
			{
				'Foo|nopage=true',
				'[[Foo#Notes|§ Notes]]',
			},
			{
				'Foo|nopage=false',
				'[[Foo#Notes|Foo § Notes]]',
			},
			{
				'Foo|Bar',
				'[[Foo#Bar|Foo § Bar]]',
			},
			{
				'Foo#Bar',
				'[[Foo#Bar|Foo § Bar]]',
			},
			{
				'Foo|Bar Baz',
				'[[Foo#Bar Baz|Foo § Bar Baz]]',
			},
			{
				'Foo|Bar_Baz',
				'[[Foo#Bar Baz|Foo § Bar Baz]]',
			},
			{
				'Foo_Bar|Baz_Qux',
				'[[Foo Bar#Baz Qux|Foo Bar § Baz Qux]]',
			},
			{
				'Foo_Bar|Baz_Qux|keep-underscores=1',
				'[[Foo_Bar#Baz_Qux|Foo_Bar § Baz_Qux]]',
			},
			{
				'Foo_Bar|Baz_Qux|keep-underscores=0',
				'[[Foo Bar#Baz Qux|Foo Bar § Baz Qux]]',
			},
			{
				'Foo_Bar|Baz_Qux|keep-underscores=yes',
				'[[Foo_Bar#Baz_Qux|Foo_Bar § Baz_Qux]]',
			},
			{
				'Foo_Bar|Baz_Qux|keep-underscores=no',
				'[[Foo Bar#Baz Qux|Foo Bar § Baz Qux]]',
			},
			{
				'Foo_Bar|Baz_Qux|keep-underscores=true',
				'[[Foo_Bar#Baz_Qux|Foo_Bar § Baz_Qux]]',
			},
			{
				'Foo_Bar|Baz_Qux|keep-underscores=false',
				'[[Foo Bar#Baz Qux|Foo Bar § Baz Qux]]',
			},
			{
				'Foo|Bar|Baz',
				'Foo §§ [[Foo#Bar|Bar]]​ and [[Foo#Baz|Baz]]',
			},
			{
				'Foo|Bar|Baz',
				'Foo §§ [[Foo#Bar|Bar]]​ and [[Foo#Baz|Baz]]',
			},
			{
				'Foo|Bar|Baz|Qux',
				'Foo §§ [[Foo#Bar|Bar]], [[Foo#Baz|Baz]], and [[Foo#Qux|Qux]]',
			},
			{
				"Foo|Bar|display=''Foo''",
				"[[Foo#Bar|''Foo'' § Bar]]",
			},
			{
				'Foo|Bar|display=Baz',
				'Display title "Baz" was ignored since it is not equivalent to the page\'s actual title',
				{ err = true },
			}
		}
	}
}