User:Riccardo Casini/Sandbox/Module:Tests
Appearance
-- Modulo Unit tests per [[Modulo:Navbox]]. Cliccare sulla pagina di discussione per eseguire i test.
local p = require("Modulo:UnitTests")
function p:test_navbox()
self:preprocess_equals_many("{{Navbox/Sandbox|debug=1|navbar=plain|", "}}", {
-- nessun parametro
{ "", "<table class=\"navbox mw-collapsible autocollapse nowraplinks noprint metadata\"><tr><th colspan=\"2\"></th></tr></table>" },
-- style
{ "style=-test-style: 1", "<table class=\"navbox mw-collapsible autocollapse nowraplinks noprint metadata\" style=\"-test-style: 1\"><tr><th colspan=\"2\"></th></tr></table>" },
-- bodystyle
{ "bodystyle=-test-bodystyle: 1", "<table class=\"navbox mw-collapsible autocollapse nowraplinks noprint metadata\" style=\"-test-bodystyle: 1\"><tr><th colspan=\"2\"></th></tr></table>" },
-- style e bodystyle
{ "style=-test-style: 1|bodystyle=-test-bodystyle: 1", "<table class=\"navbox mw-collapsible autocollapse nowraplinks noprint metadata\" style=\"-test-style: 1;-test-bodystyle: 1\"><tr><th colspan=\"2\"></th></tr></table>" },
-- state = "collapsed"
{ "state=collapsed", "<table class=\"navbox mw-collapsible mw-collapsed nowraplinks noprint metadata\"><tr><th colspan=\"2\"></th></tr></table>" },
-- state != "collapsed"
{ "state=unknown", "<table class=\"navbox mw-collapsible nowraplinks noprint metadata\"><tr><th colspan=\"2\"></th></tr></table>" },
-- title
{ "title=titolo", "<table class=\"navbox mw-collapsible autocollapse nowraplinks noprint metadata\"><tr><th colspan=\"2\"><span>titolo</span></th></tr></table>" },
-- title e titlestyle
{ "title=titolo|titlestyle=-test-titlestyle: 1", "<table class=\"navbox mw-collapsible autocollapse nowraplinks noprint metadata\"><tr><th colspan=\"2\" style=\"-test-titlestyle: 1\"><span>titolo</span></th></tr></table>" },
-- title e above
{ "title=titolo|above=sopra", "<table class=\"navbox mw-collapsible autocollapse nowraplinks noprint metadata\"><tr><th colspan=\"2\"><span>titolo</span></th></tr><tr><td colspan=\"2\">sopra</td></tr></table>" },
-- title, above e abovestyle
{ "title=titolo|above=sopra|abovestyle=-test-abovestyle: 1", "<table class=\"navbox mw-collapsible autocollapse nowraplinks noprint metadata\"><tr><th colspan=\"2\"><span>titolo</span></th></tr><tr><td colspan=\"2\" style=\"-test-abovestyle: 1\">sopra</td></tr></table>" },
-- title e below
{ "title=titolo|below=sotto", "<table class=\"navbox mw-collapsible autocollapse nowraplinks noprint metadata\"><tr><th colspan=\"2\"><span>titolo</span></th></tr><tr><td colspan=\"2\">sotto</td></tr></table>" },
-- title, below e belowstyle
{ "title=titolo|below=sotto|belowstyle=-test-belowstyle: 1", "<table class=\"navbox mw-collapsible autocollapse nowraplinks noprint metadata\"><tr><th colspan=\"2\"><span>titolo</span></th></tr><tr><td colspan=\"2\" style=\"-test-belowstyle: 1\">sotto</td></tr></table>" },
-- title, above e below
{ "title=titolo|above=sopra|below=sotto", "<table class=\"navbox mw-collapsible autocollapse nowraplinks noprint metadata\"><tr><th colspan=\"2\"><span>titolo</span></th></tr><tr><td colspan=\"2\">sopra</td></tr><tr><td colspan=\"2\">sotto</td></tr></table>" },
-- title e list1
{ "title=titolo|list1=lista1", "<table class=\"navbox mw-collapsible autocollapse nowraplinks noprint metadata\"><tr><th colspan=\"2\"><span>titolo</span></th></tr><tr><td colspan=\"2\">lista1</td></tr></table>" },
-- title e list30
{ "title=titolo|list30=lista30", "<table class=\"navbox mw-collapsible autocollapse nowraplinks noprint metadata\"><tr><th colspan=\"2\"><span>titolo</span></th></tr><tr><td colspan=\"2\">lista30</td></tr></table>" },
-- title e list31
{ "title=titolo|list31=lista31", "<table class=\"navbox mw-collapsible autocollapse nowraplinks noprint metadata\"><tr><th colspan=\"2\"><span>titolo</span></th></tr></table>" },
-- title, list1 e liststyle
{ "title=titolo|list1=lista1|liststyle=-test-liststyle: 1", "<table class=\"navbox mw-collapsible autocollapse nowraplinks noprint metadata\"><tr><th colspan=\"2\"><span>titolo</span></th></tr><tr><td colspan=\"2\" style=\"-test-liststyle: 1\">lista1</td></tr></table>" },
-- title, list1 e list1style
{ "title=titolo|list1=lista1|list1style=-test-list1style: 1", "<table class=\"navbox mw-collapsible autocollapse nowraplinks noprint metadata\"><tr><th colspan=\"2\"><span>titolo</span></th></tr><tr><td colspan=\"2\" style=\"-test-list1style: 1\">lista1</td></tr></table>" },
-- title, list1 e oddstyle
{ "title=titolo|list1=lista1|oddstyle=-test-oddstyle: 1", "<table class=\"navbox mw-collapsible autocollapse nowraplinks noprint metadata\"><tr><th colspan=\"2\"><span>titolo</span></th></tr><tr><td colspan=\"2\" style=\"-test-oddstyle: 1\">lista1</td></tr></table>" },
-- title, group1 e list1
{ "title=titolo|group1=gruppo1|list1=lista1", "<table class=\"navbox mw-collapsible autocollapse nowraplinks noprint metadata\"><tr><th colspan=\"2\"><span>titolo</span></th></tr><tr><th colspan=\"1\">gruppo1</th><td colspan=\"1\">lista1</td></tr></table>" },
-- title, group1, groupstyle e list1
{ "title=titolo|group1=gruppo1|groupstyle=-test-groupstyle: 1|list1=lista1", "<table class=\"navbox mw-collapsible autocollapse nowraplinks noprint metadata\"><tr><th colspan=\"2\"><span>titolo</span></th></tr><tr><th colspan=\"1\" style=\"-test-groupstyle: 1\">gruppo1</th><td colspan=\"1\">lista1</td></tr></table>" },
-- title, group1, group1style e list1
{ "title=titolo|group1=gruppo1|group1style=-test-group1style: 1|list1=lista1", "<table class=\"navbox mw-collapsible autocollapse nowraplinks noprint metadata\"><tr><th colspan=\"2\"><span>titolo</span></th></tr><tr><th colspan=\"1\" style=\"-test-group1style: 1\">gruppo1</th><td colspan=\"1\">lista1</td></tr></table>" },
-- title, list1 e image
{ "title=titolo|list1=lista1|image=[[File:Yes_check.svg|25px]]", "<table class=\"navbox mw-collapsible autocollapse nowraplinks noprint metadata\"><tr><th colspan=\"3\"><span>titolo</span></th></tr><tr><td colspan=\"2\">lista1</td><td rowspan=\"1\">[[File:Yes_check.svg|25px]]</td></tr></table>" },
-- title, list1, image e imagestyle
{ "title=titolo|list1=lista1|image=[[File:Yes_check.svg|25px]]|imagestyle=-test-imagestyle: 1", "<table class=\"navbox mw-collapsible autocollapse nowraplinks noprint metadata\"><tr><th colspan=\"3\"><span>titolo</span></th></tr><tr><td colspan=\"2\">lista1</td><td rowspan=\"1\" style=\"-test-imagestyle: 1\">[[File:Yes_check.svg|25px]]</td></tr></table>" },
-- title, list1 e list2
{ "title=titolo|list1=lista1|list2=lista2", "<table class=\"navbox mw-collapsible autocollapse nowraplinks noprint metadata\"><tr><th colspan=\"2\"><span>titolo</span></th></tr><tr><td colspan=\"2\">lista1</td></tr><tr><td colspan=\"2\">lista2</td></tr></table>" },
-- title, list1, list2, oddstyle e evenstyle
{ "title=titolo|list1=lista1|list2=lista2|oddstyle=-test-oddstyle: 1|evenstyle=-test-evenstyle: 1", "<table class=\"navbox mw-collapsible autocollapse nowraplinks noprint metadata\"><tr><th colspan=\"2\"><span>titolo</span></th></tr><tr><td colspan=\"2\" style=\"-test-oddstyle: 1\">lista1</td></tr><tr><td colspan=\"2\" style=\"-test-evenstyle: 1\">lista2</td></tr></table>" },
-- title, group1, list1, group2, list2
{ "title=titolo|group1=gruppo1|list1=lista1|group2=gruppo2|list2=lista2", "<table class=\"navbox mw-collapsible autocollapse nowraplinks noprint metadata\"><tr><th colspan=\"2\"><span>titolo</span></th></tr><tr><th colspan=\"1\">gruppo1</th><td colspan=\"1\">lista1</td></tr><tr><th colspan=\"1\">gruppo2</th><td colspan=\"1\">lista2</td></tr></table>" },
-- group senza list
{ "title=titolo|group1=gruppo1", "<table class=\"navbox mw-collapsible autocollapse nowraplinks noprint metadata\"><tr><th colspan=\"2\"><span>titolo</span></th></tr><tr><th colspan=\"2\">gruppo1</th></tr></table>" }
})
end
function p:test_navbox_subgroup()
self:preprocess_equals_many("{{Navbox subgroup/Sandbox|debug=1|", "}}", {
-- nessun parametro
{ "", "<table class=\"navbox nowraplinks\"></table>" },
-- bodystyle
{ "bodystyle=-test-bodystyle: 1", "<table class=\"navbox nowraplinks\" style=\"-test-bodystyle: 1\"></table>" },
-- list1
{ "list1=lista1", "<table class=\"navbox nowraplinks\"><tr><td colspan=\"2\">lista1</td></tr></table>" },
-- list20
{ "list20=lista20", "<table class=\"navbox nowraplinks\"><tr><td colspan=\"2\">lista20</td></tr></table>" },
-- list21
{ "list21=lista21", "<table class=\"navbox nowraplinks\"></table>" },
-- list1 e liststyle
{ "list1=lista1|liststyle=-test-liststyle: 1", "<table class=\"navbox nowraplinks\"><tr><td colspan=\"2\" style=\"-test-liststyle: 1\">lista1</td></tr></table>" },
-- list1 e oddstyle
{ "list1=lista1|oddstyle=-test-oddstyle: 1", "<table class=\"navbox nowraplinks\"><tr><td colspan=\"2\" style=\"-test-oddstyle: 1\">lista1</td></tr></table>" },
-- group1 e list1
{ "group1=gruppo1|list1=lista1", "<table class=\"navbox nowraplinks\"><tr><th>gruppo1</th><td colspan=\"1\">lista1</td></tr></table>" },
-- group1, groupstyle e list1
{ "group1=gruppo1|groupstyle=-test-groupstyle: 1|list1=lista1", "<table class=\"navbox nowraplinks\"><tr><th style=\"-test-groupstyle: 1\">gruppo1</th><td colspan=\"1\">lista1</td></tr></table>" },
-- list1 e list2
{ "list1=lista1|list2=lista2", "<table class=\"navbox nowraplinks\"><tr><td colspan=\"2\">lista1</td></tr><tr><td colspan=\"2\">lista2</td></tr></table>" },
-- list1, list2, oddstyle e evenstyle
{ "list1=lista1|list2=lista2|oddstyle=-test-oddstyle: 1|evenstyle=-test-evenstyle: 1", "<table class=\"navbox nowraplinks\"><tr><td colspan=\"2\" style=\"-test-oddstyle: 1\">lista1</td></tr><tr><td colspan=\"2\" style=\"-test-evenstyle: 1\">lista2</td></tr></table>" },
-- group1, list1, group2, list2
{ "group1=gruppo1|list1=lista1|group2=gruppo2|list2=lista2", "<table class=\"navbox nowraplinks\"><tr><th>gruppo1</th><td colspan=\"1\">lista1</td></tr><tr><th>gruppo2</th><td colspan=\"1\">lista2</td></tr></table>" },
})
end
return p