Jump to content

Module:Template test case/testcases

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Zyxw (talk | contribs) at 16:19, 10 August 2018 (add/update tests). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
-- Unit tests for [[Module:Template test case]]. Click talk page to run tests.

local p = require('Module:UnitTests')

function p:test1a_columns()
    self:preprocess_equals_preprocess(
        '{{#invoke:Template test case         |main |_format=columns |_caption=_caption |_rowheader=_rowheader |_heading0=_heading0 |_heading1=_heading1 |_heading2=_heading2 |_heading3=_heading3 |_before=_before |_after=_after |_template1=Commons-inline |_template2=Commons category-inline |_template3=Commons and category-inline |Lorem ipsum|Lorem ipsum}}',
        '{{#invoke:Template test case/sandbox |main |_format=columns |_caption=_caption |_rowheader=_rowheader |_heading0=_heading0 |_heading1=_heading1 |_heading2=_heading2 |_heading3=_heading3 |_before=_before |_after=_after |_template1=Commons-inline |_template2=Commons category-inline |_template3=Commons and category-inline |Lorem ipsum|Lorem ipsum}}'
        )
end

function p:test1b_columns_nowiki()
    self:preprocess_equals_preprocess(
        '{{#invoke:Template test case         |main |_format=columns |_caption=_caption |_rowheader=_rowheader |_heading0=_heading0 |_heading1=_heading1 |_heading2=_heading2 |_heading3=_heading3 |_before=_before |_after=_after |_template1=Commons-inline |_template2=Commons category-inline |_template3=Commons and category-inline |Lorem ipsum|Lorem ipsum}}',
        '{{#invoke:Template test case/sandbox |main |_format=columns |_caption=_caption |_rowheader=_rowheader |_heading0=_heading0 |_heading1=_heading1 |_heading2=_heading2 |_heading3=_heading3 |_before=_before |_after=_after |_template1=Commons-inline |_template2=Commons category-inline |_template3=Commons and category-inline |Lorem ipsum|Lorem ipsum}}',
        {nowiki=1}
    )
end

function p:test2a_showheader()
    self:preprocess_equals_preprocess(
        '{{#invoke:Template test case         |main |_format=columns |_showheader=no |_template1=Commons-inline |_template2=Commons category-inline |_template3=Commons and category-inline |Lorem ipsum|Lorem ipsum}}',
        '{{#invoke:Template test case/sandbox |main |_format=columns |_showheader=no |_template1=Commons-inline |_template2=Commons category-inline |_template3=Commons and category-inline |Lorem ipsum|Lorem ipsum}}'
        )
end

function p:test2b_showheader_nowiki()
    self:preprocess_equals_preprocess(
        '{{#invoke:Template test case         |main |_format=columns |_showheader=no |_template1=Commons-inline |_template2=Commons category-inline |_template3=Commons and category-inline |Lorem ipsum|Lorem ipsum}}',
        '{{#invoke:Template test case/sandbox |main |_format=columns |_showheader=no |_template1=Commons-inline |_template2=Commons category-inline |_template3=Commons and category-inline |Lorem ipsum|Lorem ipsum}}',
        {nowiki=1}
    )
end

function p:test3a_caption()
    self:preprocess_equals_preprocess(
        '{{#invoke:Template test case         |main |_format=columns |_caption=  |_template1=Commons-inline |_template2=Commons category-inline |_template3=Commons and category-inline |Lorem ipsum|Lorem ipsum}}',
        '{{#invoke:Template test case/sandbox |main |_format=columns |_caption=  |_template1=Commons-inline |_template2=Commons category-inline |_template3=Commons and category-inline |Lorem ipsum|Lorem ipsum}}'
        )
end

function p:test3b_caption_nowiki()
    self:preprocess_equals_preprocess(
        '{{#invoke:Template test case         |main |_format=columns |_caption=  |_template1=Commons-inline |_template2=Commons category-inline |_template3=Commons and category-inline |Lorem ipsum|Lorem ipsum}}',
        '{{#invoke:Template test case/sandbox |main |_format=columns |_caption=  |_template1=Commons-inline |_template2=Commons category-inline |_template3=Commons and category-inline |Lorem ipsum|Lorem ipsum}}',
        {nowiki=1}
    )
end

function p:test4a_showcaption()
    self:preprocess_equals_preprocess(
        '{{#invoke:Template test case         |main |_format=columns |_showcaption=no |_template1=Commons-inline |_template2=Commons category-inline |_template3=Commons and category-inline |Lorem ipsum|Lorem ipsum}}',
        '{{#invoke:Template test case/sandbox |main |_format=columns |_showcaption=no |_template1=Commons-inline |_template2=Commons category-inline |_template3=Commons and category-inline |Lorem ipsum|Lorem ipsum}}'
        )
end

function p:test4b_showcaption_nowiki()
    self:preprocess_equals_preprocess(
        '{{#invoke:Template test case         |main |_format=columns |_showcaption=no |_template1=Commons-inline |_template2=Commons category-inline |_template3=Commons and category-inline |Lorem ipsum|Lorem ipsum}}',
        '{{#invoke:Template test case/sandbox |main |_format=columns |_showcaption=no |_template1=Commons-inline |_template2=Commons category-inline |_template3=Commons and category-inline |Lorem ipsum|Lorem ipsum}}',
        {nowiki=1}
    )
end

function p:test5a_addline()
    self:preprocess_equals_preprocess(
        '{{#invoke:Template test case         |main |_format=inline |_showcode=yes |_template1=Height |m=1.51 |_addline=Output of Convert template: {{Cvt|1.51|m|frac=2}} }}',
        '{{#invoke:Template test case/sandbox |main |_format=inline |_showcode=yes |_template1=Height |m=1.51 |_addline=Output of Convert template: {{Cvt|1.51|m|frac=2}} }}'
        )
end

function p:test5b_addline_nowiki()
    self:preprocess_equals_preprocess(
        '{{#invoke:Template test case         |main |_format=inline |_showcode=yes |_template1=Height |m=1.51 |_addline=Output of Convert template: {{Cvt|1.51|m|frac=2}} }}',
        '{{#invoke:Template test case/sandbox |main |_format=inline |_showcode=yes |_template1=Height |m=1.51 |_addline=Output of Convert template: {{Cvt|1.51|m|frac=2}} }}',
        {nowiki=1}
    )
end

function p:test6a_output_default()
    self:preprocess_equals_preprocess(
        '{{#invoke:Template test case         |main |_output=nowiki |_showcode=yes |_template1=Height |m=1.51}}',
        '{{#invoke:Template test case/sandbox |main |_output=nowiki |_showcode=yes |_template1=Height |m=1.51}}'
        )
end

function p:test6b_output_default()
    self:preprocess_equals_preprocess(
        '{{#invoke:Template test case         |main |_output=nowiki |_showcode=yes |_template1=Height |m=1.51}}',
        '{{#invoke:Template test case/sandbox |main |_output=nowiki |_showcode=yes |_template1=Height |m=1.51}}',
        {nowiki=1}
    )
end

function p:test7a_output_columns()
    self:preprocess_equals_preprocess(
        '{{#invoke:Template test case         |main |_output=nowiki |_format=columns |_showcode=yes |_template1=Height |m=1.51}}',
        '{{#invoke:Template test case/sandbox |main |_output=nowiki |_format=columns |_showcode=yes |_template1=Height |m=1.51}}'
        )
end

function p:test7b_output_columns()
    self:preprocess_equals_preprocess(
        '{{#invoke:Template test case         |main |_output=nowiki |_format=columns |_showcode=yes |_template1=Height |m=1.51}}',
        '{{#invoke:Template test case/sandbox |main |_output=nowiki |_format=columns |_showcode=yes |_template1=Height |m=1.51}}',
        {nowiki=1}
    )
end

function p:test8a_output_rows()
    self:preprocess_equals_preprocess(
        '{{#invoke:Template test case         |main |_output=nowiki |_format=rows |_showcode=yes |_template1=Height |m=1.51}}',
        '{{#invoke:Template test case/sandbox |main |_output=nowiki |_format=rows |_showcode=yes |_template1=Height |m=1.51}}'
        )
end

function p:test8b_output_rows()
    self:preprocess_equals_preprocess(
        '{{#invoke:Template test case         |main |_output=nowiki |_format=rows |_showcode=yes |_template1=Height |m=1.51}}',
        '{{#invoke:Template test case/sandbox |main |_output=nowiki |_format=rows |_showcode=yes |_template1=Height |m=1.51}}',
        {nowiki=1}
    )
end

function p:test9a_output_inline()
    self:preprocess_equals_preprocess(
        '{{#invoke:Template test case         |main |_output=nowiki |_format=inline |_showcode=yes |_template1=Height |m=1.51}}',
        '{{#invoke:Template test case/sandbox |main |_output=nowiki |_format=inline |_showcode=yes |_template1=Height |m=1.51}}'
        )
end

function p:test9b_output_inline()
    self:preprocess_equals_preprocess(
        '{{#invoke:Template test case         |main |_output=nowiki |_format=inline |_showcode=yes |_template1=Height |m=1.51}}',
        '{{#invoke:Template test case/sandbox |main |_output=nowiki |_format=inline |_showcode=yes |_template1=Height |m=1.51}}',
        {nowiki=1}
    )
end

return p