Module:Check DYK hook/testcases
Appearance
![]() | This is the test cases page for the module Module:Check DYK hook. Results of the test cases. |
-- Load necessary modules
local mCheckDYKHook = require('Module:Check DYK hook/sandbox')
local ScribuntoUnit = require('Module:ScribuntoUnit')
-- Initialise test suite
local suite = ScribuntoUnit:new()
local testData = {
{
testName = "testCheckHook_ReturnsTrue_ForHooksStartingWithThat",
dykText = "... that foo bar baz?",
shouldBeValid = true,
},
{
testName = "testCheckHook_ReturnsTrue_ForHooksStartingWithAbout",
dykText = "... about the foo bar baz?",
shouldBeValid = true,
},
{
testName = "testCheckHook_ReturnsFalse_ForHooksStartingWithOtherWords",
dykText = "... foo bar baz?",
shouldBeValid = false,
},
{
testName = "testCheckHook_ReturnsTrue_ForHooksEndingWithAQuestionMark",
dykText = "... that foo bar baz?",
shouldBeValid = true,
},
{
testName = "testCheckHook_ReturnsTrue_ForHooksEndingWithAQuestionMarkHTMLEncodedInsideALink",
dykText = '... that foo bar [[baz|<span class="something">baz?</span>]]',
shouldBeValid = true,
},
{
testName = "testCheckHook_ReturnsTrue_ForHooksEndingWithYouProbablyDid",
dykText = '... that foo bar baz? You probably did...',
shouldBeValid = true,
},
{
testName = "testCheckHook_ReturnsFalse_ForHooksNotEndingInAQuestionMark",
dykText = '... that foo bar baz',
shouldBeValid = false,
},
}
for _, individualTestData in ipairs(testData) do
suite[individualTestData.testName] = function(self)
local result = mCheckDYKHook._isValidHook(individualTestData.dykText)
if individualTestData.shouldBeValid then
self:assertTrue(result)
else
self:assertFalse(result)
end
end
end
return suite