Module:Protect/testcases: Difference between revisions

Content deleted Content added
 
No edit summary
Line 3:
 
function p:test_protect()
self:equals(
self:equals('Default error', protect(error)('failed'), frame:preprocess('{{Error|Error: failed}}'))
'Success',
protect(mw.clone)('Foo'),
'Foo'
)
self:equals(
'Default error',
protect(error)('foo'),
self:equals('Default error', protect(error)('failed'), .frame:preprocess('{{Error|Error: failedfoo}}'))
)
self:equals(
'No caught message',
protect(error)(),
self.frame:preprocess('{{Error|Error: (no message)}}')
)
self:equals(
'Custom errFormat',
protect(error, 'Failure (%s)')('foo'),
self.frame:preprocess('{{Error|Failure (foo)}}')
)
self:equals(
'Raw errFormat',
protect(error, {raw = true})('foo'),
'Error: foo'
)
 
self:equals(
'Custom raw errFormat',
protect(error, 'Failure (%s)', {raw = true})('foo'),
'Failure (foo)'
)
self:equals(
'Remove ___location',
protect(error)('foo', 3),
self.frame:preprocess('{{Error|Error: foo}}')
)
 
self:equals(
'Keep ___location',
protect(error, {removeLocation = false})('foo', 3),
self.frame:preprocess('{{Error|Error: Module:Protect/testcases:49: foo}}')
)
end