Module:BethNaught/RHH/testcases
Appearance
This is the test cases page for the module Module:BethNaught/RHH. Results of the test cases. |
-- Unit tests for [[Module:BethNaught/RHH]]. Null edit talk page to run tests.
-- © 2018 BethNaught, CC BY-SA 3.0
local p = require('Module:UnitTests')
function p:test_three_supported()
self:preprocess_equals_many('{{#invoke:BethNaught/RHH|three|', '}}', {
-- pagenum provided, empty or non-provided center
{'pagenum=5|center=', '{{RunningHeader|||5}}'},
{'pagenum=6000', '{{RunningHeader|6000||}}'},
-- pagenum provided, center provided, others not provided
{'pagenum=5|center=CENTER', '{{RunningHeader||CENTER|5}}'},
{'pagenum=6000|center=CENTER', '{{RunningHeader|6000|CENTER|}}'},
-- pagenum provided, center_even and center_odd provided
{'pagenum=88|center_even=EVEN|center_odd=ODD', '{{RunningHeader|88|EVEN|}}'},
{'pagenum=101|center_odd=ODD|center_even=EVEN', '{{RunningHeader||ODD|101}}'},
-- pagenum provided, center_even only provided
{'pagenum=88|center_even=EVEN', '{{RunningHeader|88|EVEN|}}'},
{'pagenum=101|center_even=EVEN', '{{RunningHeader|||101}}'},
-- pagenum provided, center_odd only provided
{'pagenum=88|center_odd=ODD', '{{RunningHeader|88||}}'},
{'pagenum=101|center_odd=ODD', '{{RunningHeader||ODD|101}}'},
}, {nowiki=1})
end
function p:test_three_unsupported_overrides()
self:preprocess_equals_many('{{#invoke:BethNaught/RHH|three|', '}}', {
-- pagenum provided, center provided as well as center_odd and/or
-- center_even: the _odd and _even should be overridden
{'pagenum=91|center=CENTER|center_even=E', '{{RunningHeader||CENTER|91}}'},
{'pagenum=91|center=CENTER|center_odd=O', '{{RunningHeader||CENTER|91}}'},
{'pagenum=66|center=CENTER|center_even=E', '{{RunningHeader|66|CENTER|}}'},
{'pagenum=66|center=CENTER|center_odd=O', '{{RunningHeader|66|CENTER|}}'},
{'pagenum=88|center=CENTER|center_even=E|center_odd=O', '{{RunningHeader|88|CENTER|}}'},
{'pagenum=101|center=CENTER|center_odd=O|center_even=E', '{{RunningHeader||CENTER|101}}'}
}, {nowiki=1})
end
function p:test_three_unsupported_no_pagenum()
self:preprocess_equals_many('{{#invoke:BethNaught/RHH|three|', '}}', {
-- pagenum not provided: should return empty RunningHeader for now
{'center=CENTER', '{{RunningHeader|||}}'},
{'center_even=EVEN|center_odd=ODD', '{{RunningHeader|||}}'},
{'center=CENTER|center_even=EVEN|center_odd=ODD', '{{RunningHeader|||}}'}
}, {nowiki=1})
end
function p:test_three_unsupported_invalid_pagenum()
self:preprocess_equals_many('{{#invoke:BethNaught/RHH|three|', '}}', {
-- pagenum invalid: should return empty RunningHeader for now
{'pagenum=xyz|center=CENTER', '{{RunningHeader|||}}'},
{'pagenum=xyz|center_even=EVEN|center_odd=ODD', '{{RunningHeader|||}}'},
{'pagenum=xyz|center=CENTER|center_even=EVEN|center_odd=ODD', '{{RunningHeader|||}}'},
{'pagenum=5.9|center=CENTER', '{{RunningHeader|||}}'},
{'pagenum=5.9|center_even=EVEN|center_odd=ODD', '{{RunningHeader|||}}'},
{'pagenum=5.9|center=CENTER|center_even=EVEN|center_odd=ODD', '{{RunningHeader|||}}'}
}, {nowiki=1})
end
return p