Difference between revisions of "Module:About/testcases"
Jump to navigation
Jump to search
blackwiki>Andrybak (try fixing tests) |
blackwiki>Andrybak (fix tests) |
||
| Line 17: | Line 17: | ||
function suite:testBasicUse1() | function suite:testBasicUse1() | ||
--Article namespace | --Article namespace | ||
| − | |||
local result = about({ | local result = about({ | ||
[1] = 'USE1' | [1] = 'USE1' | ||
| − | }, {namespace = 0, PageType = | + | }, {namespace = 0, PageType = 'article'}) |
self:assertStringContains('This article is about USE1. For other uses, see [[:About/testcases (disambiguation)]].', result, true) | self:assertStringContains('This article is about USE1. For other uses, see [[:About/testcases (disambiguation)]].', result, true) | ||
--Category namespace | --Category namespace | ||
result = about({ | result = about({ | ||
[1] = 'USE1' | [1] = 'USE1' | ||
| − | }, {namespace = 14}) | + | }, {namespace = 14, PageType = 'category'}) |
self:assertStringContains('This category is about USE1. For other uses, see [[:About/testcases (disambiguation)]].', result, true) | self:assertStringContains('This category is about USE1. For other uses, see [[:About/testcases (disambiguation)]].', result, true) | ||
--All other namespaces | --All other namespaces | ||
result = about({ | result = about({ | ||
[1] = 'USE1' | [1] = 'USE1' | ||
| − | }, {namespace = 123456789}) | + | }, {namespace = 123456789, PageType = 'page'}) |
self:assertStringContains('This page is about USE1. For other uses, see [[:About/testcases (disambiguation)]].', result, true) | self:assertStringContains('This page is about USE1. For other uses, see [[:About/testcases (disambiguation)]].', result, true) | ||
end | end | ||
| Line 38: | Line 37: | ||
[1] = 'USE1', | [1] = 'USE1', | ||
[2] = 'USE2' | [2] = 'USE2' | ||
| − | }, {namespace = 0}) | + | }, {namespace = 0, PageType = 'article'}) |
self:assertStringContains('This article is about USE1. For USE2, see [[:About/testcases (disambiguation)]].', result, true) | self:assertStringContains('This article is about USE1. For USE2, see [[:About/testcases (disambiguation)]].', result, true) | ||
end | end | ||
| Line 47: | Line 46: | ||
[2] = 'USE2', | [2] = 'USE2', | ||
[3] = 'PAGE1' | [3] = 'PAGE1' | ||
| − | }, {namespace = 0}) | + | }, {namespace = 0, PageType = 'article'}) |
self:assertStringContains('This article is about USE1. For USE2, see [[:PAGE1]].', result, true) | self:assertStringContains('This article is about USE1. For USE2, see [[:PAGE1]].', result, true) | ||
end | end | ||
| Line 57: | Line 56: | ||
[3] = 'PAGE1', | [3] = 'PAGE1', | ||
[4] = 'USE3' | [4] = 'USE3' | ||
| − | }, {namespace = 0}) | + | }, {namespace = 0, PageType = 'article'}) |
self:assertStringContains('This article is about USE1. For USE2, see [[:PAGE1]]. For USE3, see [[:About/testcases (disambiguation)]]', result, true) | self:assertStringContains('This article is about USE1. For USE2, see [[:PAGE1]]. For USE3, see [[:About/testcases (disambiguation)]]', result, true) | ||
end | end | ||
| Line 68: | Line 67: | ||
[4] = 'USE3', | [4] = 'USE3', | ||
[5] = 'PAGE2' | [5] = 'PAGE2' | ||
| − | }, {namespace = 0}) | + | }, {namespace = 0, PageType = 'article'}) |
self:assertStringContains('This article is about USE1. For USE2, see [[:PAGE1]]. For USE3, see [[:PAGE2]]', result, true) | self:assertStringContains('This article is about USE1. For USE2, see [[:PAGE1]]. For USE3, see [[:PAGE2]]', result, true) | ||
end | end | ||
| Line 83: | Line 82: | ||
[4] = 'and', | [4] = 'and', | ||
[5] = 'PAGE2' | [5] = 'PAGE2' | ||
| − | }, {namespace = 0}) | + | }, {namespace = 0, PageType = 'article'}) |
self:assertStringContains('This article is about USE1. For USE2, see [[:PAGE1]] and [[:PAGE2]]', result, true) | self:assertStringContains('This article is about USE1. For USE2, see [[:PAGE1]] and [[:PAGE2]]', result, true) | ||
end | end | ||
| Line 96: | Line 95: | ||
[6] = 'and', | [6] = 'and', | ||
[7] = 'PAGE3' | [7] = 'PAGE3' | ||
| − | }, {namespace = 0}) | + | }, {namespace = 0, PageType = 'article'}) |
self:assertStringContains('This article is about USE1. For USE2, see [[:PAGE1]], [[:PAGE2]], and [[:PAGE3]]', result, true) | self:assertStringContains('This article is about USE1. For USE2, see [[:PAGE1]], [[:PAGE2]], and [[:PAGE3]]', result, true) | ||
end | end | ||
| Line 111: | Line 110: | ||
[8] = 'and', | [8] = 'and', | ||
[9] = 'PAGE4' | [9] = 'PAGE4' | ||
| − | }, {namespace = 0}) | + | }, {namespace = 0, PageType = 'article'}) |
self:assertStringContains('This article is about USE1. For USE2, see [[:PAGE1]], [[:PAGE2]], [[:PAGE3]], and [[:PAGE4]]', result, true) | self:assertStringContains('This article is about USE1. For USE2, see [[:PAGE1]], [[:PAGE2]], [[:PAGE3]], and [[:PAGE4]]', result, true) | ||
end | end | ||
| Line 124: | Line 123: | ||
[6] = 'USE3', | [6] = 'USE3', | ||
[7] = 'PAGE3' | [7] = 'PAGE3' | ||
| − | }, {namespace = 0}) | + | }, {namespace = 0, PageType = 'article'}) |
self:assertStringContains('This article is about USE1. For USE2, see [[:PAGE1]] and [[:PAGE2]]. For USE3, see [[:PAGE3]].', result, true) | self:assertStringContains('This article is about USE1. For USE2, see [[:PAGE1]] and [[:PAGE2]]. For USE3, see [[:PAGE3]].', result, true) | ||
end | end | ||
| Line 139: | Line 138: | ||
[8] = 'and', | [8] = 'and', | ||
[9] = 'PAGE4' | [9] = 'PAGE4' | ||
| − | }, {namespace = 0}) | + | }, {namespace = 0, PageType = 'article'}) |
self:assertStringContains('This article is about USE1. For USE2, see [[:PAGE1]] and [[:PAGE2]]. For USE3, see [[:PAGE3]] and [[:PAGE4]].', result, true) | self:assertStringContains('This article is about USE1. For USE2, see [[:PAGE1]] and [[:PAGE2]]. For USE3, see [[:PAGE3]] and [[:PAGE4]].', result, true) | ||
end | end | ||
| Line 153: | Line 152: | ||
}, { | }, { | ||
namespace = 0, | namespace = 0, | ||
| − | otherText = 'other values of otherText' | + | otherText = 'other values of otherText', |
| + | PageType = 'article' | ||
}) | }) | ||
self:assertStringContains('This article is about USE1. For other values of otherText, see [[:PAGE1]]', result, true) | self:assertStringContains('This article is about USE1. For other values of otherText, see [[:PAGE1]]', result, true) | ||
Revision as of 15:54, 4 July 2020
Documentation for this module may be created at Module:About/testcases/doc
local mAbout = require('Module:About/sandbox')
local about = mAbout._about
local ScribuntoUnit = require('Module:ScribuntoUnit')
local suite = ScribuntoUnit:new()
--------------------------------------------------------------------------------
-- Basic functionality
--------------------------------------------------------------------------------
function suite:testBasicBlank()
local result = about()
--Current functionality. Should probably throw an error if blank in future.
self:assertStringContains('For other uses, see [[:About/testcases (disambiguation)]].', result, true)
end
function suite:testBasicUse1()
--Article namespace
local result = about({
[1] = 'USE1'
}, {namespace = 0, PageType = 'article'})
self:assertStringContains('This article is about USE1. For other uses, see [[:About/testcases (disambiguation)]].', result, true)
--Category namespace
result = about({
[1] = 'USE1'
}, {namespace = 14, PageType = 'category'})
self:assertStringContains('This category is about USE1. For other uses, see [[:About/testcases (disambiguation)]].', result, true)
--All other namespaces
result = about({
[1] = 'USE1'
}, {namespace = 123456789, PageType = 'page'})
self:assertStringContains('This page is about USE1. For other uses, see [[:About/testcases (disambiguation)]].', result, true)
end
function suite:testBasicUse2()
local result = about({
[1] = 'USE1',
[2] = 'USE2'
}, {namespace = 0, PageType = 'article'})
self:assertStringContains('This article is about USE1. For USE2, see [[:About/testcases (disambiguation)]].', result, true)
end
function suite:testBasicPage1()
local result = about({
[1] = 'USE1',
[2] = 'USE2',
[3] = 'PAGE1'
}, {namespace = 0, PageType = 'article'})
self:assertStringContains('This article is about USE1. For USE2, see [[:PAGE1]].', result, true)
end
function suite:testBasicUse3()
local result = about({
[1] = 'USE1',
[2] = 'USE2',
[3] = 'PAGE1',
[4] = 'USE3'
}, {namespace = 0, PageType = 'article'})
self:assertStringContains('This article is about USE1. For USE2, see [[:PAGE1]]. For USE3, see [[:About/testcases (disambiguation)]]', result, true)
end
function suite:testBasicPage2()
local result = about({
[1] = 'USE1',
[2] = 'USE2',
[3] = 'PAGE1',
[4] = 'USE3',
[5] = 'PAGE2'
}, {namespace = 0, PageType = 'article'})
self:assertStringContains('This article is about USE1. For USE2, see [[:PAGE1]]. For USE3, see [[:PAGE2]]', result, true)
end
--------------------------------------------------------------------------------
-- "and" functionality
--------------------------------------------------------------------------------
function suite:testAnd1And()
local result = about({
[1] = 'USE1',
[2] = 'USE2',
[3] = 'PAGE1',
[4] = 'and',
[5] = 'PAGE2'
}, {namespace = 0, PageType = 'article'})
self:assertStringContains('This article is about USE1. For USE2, see [[:PAGE1]] and [[:PAGE2]]', result, true)
end
function suite:testAnd2Ands()
local result = about({
[1] = 'USE1',
[2] = 'USE2',
[3] = 'PAGE1',
[4] = 'and',
[5] = 'PAGE2',
[6] = 'and',
[7] = 'PAGE3'
}, {namespace = 0, PageType = 'article'})
self:assertStringContains('This article is about USE1. For USE2, see [[:PAGE1]], [[:PAGE2]], and [[:PAGE3]]', result, true)
end
function suite:testAnd3Ands()
local result = about({
[1] = 'USE1',
[2] = 'USE2',
[3] = 'PAGE1',
[4] = 'and',
[5] = 'PAGE2',
[6] = 'and',
[7] = 'PAGE3',
[8] = 'and',
[9] = 'PAGE4'
}, {namespace = 0, PageType = 'article'})
self:assertStringContains('This article is about USE1. For USE2, see [[:PAGE1]], [[:PAGE2]], [[:PAGE3]], and [[:PAGE4]]', result, true)
end
function suite:testAnd1And1BeforeFor()
local result = about({
[1] = 'USE1',
[2] = 'USE2',
[3] = 'PAGE1',
[4] = 'and',
[5] = 'PAGE2',
[6] = 'USE3',
[7] = 'PAGE3'
}, {namespace = 0, PageType = 'article'})
self:assertStringContains('This article is about USE1. For USE2, see [[:PAGE1]] and [[:PAGE2]]. For USE3, see [[:PAGE3]].', result, true)
end
function suite:testAnd1And1BeforeAnd1()
local result = about({
[1] = 'USE1',
[2] = 'USE2',
[3] = 'PAGE1',
[4] = 'and',
[5] = 'PAGE2',
[6] = 'USE3',
[7] = 'PAGE3',
[8] = 'and',
[9] = 'PAGE4'
}, {namespace = 0, PageType = 'article'})
self:assertStringContains('This article is about USE1. For USE2, see [[:PAGE1]] and [[:PAGE2]]. For USE3, see [[:PAGE3]] and [[:PAGE4]].', result, true)
end
--------------------------------------------------------------------------------
-- otherText functionality
--------------------------------------------------------------------------------
function suite:testOtherText()
local result = about({
[1] = 'USE1',
[3] = 'PAGE1'
}, {
namespace = 0,
otherText = 'other values of otherText',
PageType = 'article'
})
self:assertStringContains('This article is about USE1. For other values of otherText, see [[:PAGE1]]', result, true)
end
--------------------------------------------------------------------------------
-- otherText functionality
--------------------------------------------------------------------------------
function suite:testNoSelfref()
local result = about({
[1] = 'USE1',
[2] = 'PAGE1',
}, {namespace = 0})
self:assertNotStringContains('selfref', result, true)
end
function suite:testSelfref()
local result = about({
[1] = 'USE1',
[2] = 'PAGE1',
['selfref'] = 'true'
}, {namespace = 0})
self:assertStringContains('selfref', result, true)
end
--------------------------------------------------------------------------------
-- Defaulting functionality
--------------------------------------------------------------------------------
--TODO
--------------------------------------------------------------------------------
return suite