Module:About/testcases
| This is the test cases page for the module Module:About. Results of the test cases. |
local mAbout = require('Module:About')
local about = mAbout._about
local ScribuntoUnit = require('Module:ScribuntoUnit')
local suite = ScribuntoUnit:new()
--------------------------------------------------------------------------------
-- Sandbox run
--------------------------------------------------------------------------------
function suite.runSandbox(...)
mAbout = require('Module:About/sandbox')
about = mAbout._about
return suite.run(...)
end
--------------------------------------------------------------------------------
-- 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'
}, {PageType = 'article'})
self:assertStringContains('This article is about USE1. For other uses, see [[:About/testcases (disambiguation)]].', result, true)
--Category namespace
result = about({
[1] = 'USE1'
}, {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'
}, {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'
}, {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'
}, {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'
}, {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'
}, {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'
}, {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'
}, {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'
}, {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'
}, {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'
}, {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'
}, {
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',
})
self:assertNotStringContains('selfref', result, true)
end
function suite:testSelfref()
local result = about({
[1] = 'USE1',
[2] = 'PAGE1',
['selfref'] = 'true'
})
self:assertStringContains('selfref', result, true)
end
--------------------------------------------------------------------------------
-- Defaulting functionality
--------------------------------------------------------------------------------
--TODO
--------------------------------------------------------------------------------
return suite
Content Disclaimer
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.
- The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
- There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
- It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
- Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
- Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.