Module:About/testcases: Difference between revisions

Content deleted Content added
Some starter tests. Definitely incomplete, but hopefully not buggy…
 
stop passing unused argument "namespace" to Module:About/sandbox
 
(9 intermediate revisions by 2 users not shown)
Line 1:
local mAbout = require('Module:About/sandbox')
local about = mAbout._about
local ScribuntoUnit = require('Module:ScribuntoUnit')
local suite = ScribuntoUnit:new()
Line 18 ⟶ 19:
local result = about({
[1] = 'USE1'
}, {namespacePageType = 0'article'})
self:assertStringContains('This article is about USE1. For other uses, see [[:About/testcases (disambiguation)]].', result, true)
--Category namespace
result = about({
[1] = 'USE1'
}, {namespacePageType = 14'category'})
self:assertStringContains('This articlecategory is about USE1. For other uses, see [[:About/testcases (disambiguation)]].', result, true)
--All other namespaces
result = about({
[1] = 'USE1'
}, {namespacePageType = 123456789'page'})
self:assertStringContains('This page is about USE1. For other uses, see [[:About/testcases (disambiguation)]].', result, true)
end
Line 36 ⟶ 37:
[1] = 'USE1',
[2] = 'USE2'
}, {namespacePageType = 0'article'})
self:assertStringContains('This article is about USE1. For USE2, see [[:About/testcases (disambiguation)]].', result, true)
end
Line 45 ⟶ 46:
[2] = 'USE2',
[3] = 'PAGE1'
}, {namespacePageType = 0'article'})
self:assertStringContains('This article is about USE1. For USE2, see [[:PAGE1]].', result, true)
end
Line 55 ⟶ 56:
[3] = 'PAGE1',
[4] = 'USE3'
}, {namespacePageType = 0'article'})
self:assertStringContains('This article is about USE1. For USE2, see [[:PAGE1]]. For USE3, see [[:About/testcases (disambiguation)]]', result, true)
end
Line 66 ⟶ 67:
[4] = 'USE3',
[5] = 'PAGE2'
}, {namespacePageType = 0'article'})
self:assertStringContains('This article is about USE1. For USE2, see [[:PAGE1]]. For USE3, see [[:PAGE2]]', result, true)
end
Line 81 ⟶ 82:
[4] = 'and',
[5] = 'PAGE2'
}, {namespacePageType = 0'article'})
self:assertStringContains('This article is about USE1. For USE2, see [[:PAGE1]] and [[:PAGE2]]', result, true)
end
Line 94 ⟶ 95:
[6] = 'and',
[7] = 'PAGE3'
}, {namespacePageType = 0'article'})
self:assertStringContains('This article is about USE1. For USE2, see [[:PAGE1]], [[:PAGE2]], and [[:PAGE3]]', result, true)
end
Line 109 ⟶ 110:
[8] = 'and',
[9] = 'PAGE4'
}, {namespacePageType = 0'article'})
self:assertStringContains('This article is about USE1. For USE2, see [[:PAGE1]], [[:PAGE2]], [[:PAGE3]], and [[:PAGE4]]', result, true)
end
Line 122 ⟶ 123:
[6] = 'USE3',
[7] = 'PAGE3'
}, {namespacePageType = 0'article'})
self:assertStringContains('This article is about USE1. For USE2, see [[:PAGE1]] and [[:PAGE2]]. For USE3, see [[:PAGE3]].', result, true)
end
Line 137 ⟶ 138:
[8] = 'and',
[9] = 'PAGE4'
}, {namespacePageType = 0'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