-- Unit tests for [[Module:LangSwitch]]. Click talk page to run tests.
local p = require('Module:UnitTests')

function p:test_langSwitch_without_default()
    self:preprocess_equals_many('{{#invoke:LangSwitch/sandbox | langSwitch | en = English | co = Corsu | lang = ', '}}', {{'en', 'English'},  {'fr', 'English'}, {'co', 'Corsu'}})
    self:preprocess_equals_many('{{#invoke:LangSwitch/sandbox | langSwitch | en = English | de = German | lang = ', '}}', {{'en', 'English'},  {'de', 'German'},  {'gsw', 'German'}})
    self:preprocess_equals_many ('{{#invoke:LangSwitch/sandbox | langSwitch | en = English | gsw = Alemanic | lang = ', '}}', {{'en', 'English'},  {'de', 'English'},  {'gsw', 'Alemanic'}})
    self:preprocess_equals_many ('{{#invoke:LangSwitch/sandbox | langSwitch | en = English | no = Norwegian | lang = ', '}}', {{'en', 'English'},  {'no', 'Norwegian'},  {'de', 'English'}})
    self:preprocess_equals_many ('{{#invoke:LangSwitch/sandbox | langSwitch | de=Grün|es/it/pt=Verde|fr=Vert|en=Green | lang = ', '}}', {{'fr', 'Vert'},  {'it', 'Verde'},  {'de', 'Grün'}})
end

function p:test_langSwitch_with_default()
    self:preprocess_equals_many('{{#invoke:LangSwitch/sandbox | langSwitch | it = Italian | default = default | lang = ', '}}', {{'en', 'default'},  {'it', 'Italian'}, {'co', 'Italian'}})
    self:preprocess_equals_many('{{#invoke:LangSwitch/sandbox | langSwitch | en = English | co = Corsu | default = default | lang = ', '}}', {{'en', 'English'},  {'it', 'default'}, {'co', 'Corsu'}})
    self:preprocess_equals_many('{{#invoke:LangSwitch/sandbox | langSwitch | en = ~ | it = Italian | default = default | lang = ', '}}', {{'en', ''},  {'it', 'Italian'}, {'co', 'Italian'}})
    self:preprocess_equals_many('{{#invoke:LangSwitch/sandbox | langSwitch | en = English | it = ~| co = Corsu | default = default | lang = ', '}}', {{'en', 'English'},  {'it', ''}, {'co', 'Corsu'}})
    self:preprocess_equals_many('{{#invoke:LangSwitch/sandbox | langSwitch | en = English | it = | co = Corsu | default = default | lang = ', '}}', {{'en', 'English'},  {'it', 'default'}, {'co', 'Corsu'}})
    self:preprocess_equals_many('{{#invoke:LangSwitch/sandbox | langSwitch | bn = English | default = default | lang = ', '}}', {{'en', 'default'}})
end

return p
"https://si.wikibooks.org/w/index.php?title=Module:LangSwitch/sandbox/testcases&oldid=23858" වෙතින් සම්ප්‍රවේශනය කෙරිණි