Modulo:Panagduktal ti nagan ti espasio/pangsubok

-- Panagsubok para iti [[Modulo:Panagduktal ti nagan ti espasio]]. Pinduten ti tungtunganna a panid tapno maipataray ti panagsubok.
local p = require('Modulo:UnitTests')
local nsDetect = require('Modulo:Panagduktal ti nagan ti espasio/pagipadasan')._main

function p:test_template_testcases_page()
    self:preprocess_equals_many('{{#invoke:Panagduktal ti nagan ti espasio/pagipadasan|main', '}}', {
        {[[
| main = Article text.
| talk = Any talk page text.
| user = User page text.
| other = Other pages text.]], 'Any talk page text.'},
        {[[
| main = Article text.
| talk = Any talk page text.
| user = User page text.
| other = Other pages text.
| demospace = ]], 'Any talk page text.'},
        {[[
| main = Article text.
| talk = Any talk page text.
| user = User page text.
| other = Other pages text.
| demospace = main]], 'Article text.'},
        {[[
| main = Article text.
| talk = Any talk page text.
| user = User page text.
| other = Other pages text.
| demospace = talk]], 'Any talk page text.'},
        {[[
| main = Article text.
| talk = Any talk page text.
| user = User page text.
| other = Other pages text.
| demospace = help talk]], 'Other pages text.'},
        {[[
| main = Article text.
| talk = Any talk page text.
| user = User page text.
| other = Other pages text.
| page = ]], 'Any talk page text.'},
        {[[
| main = Article text.
| talk = Any talk page text.
| user = User page text.
| other = Other pages text.
| page = Example/test]], 'Article text.'},
        {[[
| main = Article text.
| talk = Any talk page text.
| user = User page text.
| other = Other pages text.
| page = User:Example/test]], 'User page text.'},
        {[[
| main = Article text.
| talk = Any talk page text.
| user = User page text.
| other = Other pages text.
| page = User talk:Example/test]], 'Any talk page text.'},
    })
end

function p:test_new()
    self:preprocess_equals_many('{{#invoke:Panagduktal ti nagan ti espasio/pagipadasan|main', '}}', {
        {[[]], ''},
        {[[
| main = Article text.
| talk = 
| user = User page text.
| other = Other pages text.
| page = User talk:Example/test]], ''},
        {[[
| main = Article text.
| talk = 
| user = User page text.
| other = Other pages text.
| page = User:Example/test]], 'User page text.'},
        {[[
| main = Article text.
| TALK = Talk page text.
| user = User page text.
| other = Other pages text.
| page = User talk:Example/test]], 'Other pages text.'},
        {[[
| main = Article text.
| talk = talk page text with a delete character here: ""
| user = User page text.
| other = Other pages text.
| page = User talk:Example/test]], 'talk page text with a delete character here: ""'},
        {[[
| main = Article text.
| talk = Talk page text.
| wikipedia = Wikipedia page text.
| user = User page text.
| other = Other pages text.
| demospace = Wikipedia ]], 'Wikipedia page text.'},
        {[[
| main = 
| talk = talk page text with a delete character here: ""
| user = User page text.
| other = Other pages text.
| page = Foo]], ''},
        {[[
| main = Article text.
| talk = talk page text with a delete character here: ""
| user = 
| other = Other pages text.
| page = User:Example/test]], ''},
        --{[[
--| main = Article text.
--| talk = talk page text with a delete character here: ""
--| user = User page text.
--| book = Book page text.
--| other = Other pages text.
--| page = Book:Foo]], 'Book page text.'},
        {[[
| main = Article text.
| talk = talk page text with a delete character here: ""
| user = User page text.
| image = Image page text.
| other = Other pages text.
| page = File:Foo]], 'Image page text.'},
        {[[
| main = Article text.
| talk = talk page text with a delete character here: ""
| user = User page text.
| file = File page text.
| other = Other pages text.
| page = File:Foo]], 'File page text.'},
        {[[
| main = Article text.
| talk = talk page text with a delete character here: ""
| user = User page text.
| image = 
| other = Other pages text.
| page = File:Foo]], ''},
        {[[
| main = Article text.
| talk = talk page text with a delete character here: ""
| user = User page text.
| file = 
| other = Other pages text.
| page = File:Foo]], ''},
        {[[
| main = Article text.
| talk = talk page text with a delete character here: ""
| user = User page text.
| mediawiki = MediaWiki page text.
| other = Other pages text.
| page = MediaWiki:Foo]], 'MediaWiki page text.'},
        {[[
| main = Article text.
| talk = talk page text with a delete character here: ""
| user = User page text.
| template = Template page text.
| other = Other pages text.
| page = Template:Foo]], 'Template page text.'},
        {[[
| main = Article text.
| talk = talk page text with a delete character here: ""
| help = Help page text.
| image = Image page text.
| other = Other pages text.
| page = Help:Foo]], 'Help page text.'},
        {[[
| main = Article text.
| talk = talk page text with a delete character here: ""
| user = User page text.
| category = Category page text.
| other = Other pages text.
| page = Category:Foo]], 'Category page text.'},
        --{[[
--| main = Article text.
--| talk = talk page text with a delete character here: ""
--| user = User page text.
--| portal = Portal page text.
--| other = Other pages text.
--| page = Portal:Foo]], 'Portal page text.'},
        {[[
| main = Article text.
| talk = talk page text with a delete character here: ""
| user = User page text.
| nonexistent = Nonexistent namespace page text.
| other = Other pages text.
| page = Nonexistent:Foo]], 'Article text.'},
        {[[
| main = Article text.
| talk = talk page text with a delete character here: ""
| user = User page text.
| nonexistent = Nonexistent namespace page text.
| other = Other pages text.
| demospace = Nonexistent]], 'Other pages text.'},
    })
end

function p:test_alias_parameters()
    self:preprocess_equals_many('{{#invoke:Panagduktal ti nagan ti espasio/pagipadasan|main', '}}', {
        {[[]], ''},
        {[[
| umuna = Article text.
| tungtungan = 
| agar-aramat = User page text.
| sabali = Other pages text.
| panid = User talk:Example/test]], ''},
        {[[
| nangruna = Article text.
| tungtungan = 
| agar-aramat = User page text.
| sabali = Other pages text.
| panid = User:Example/test]], 'User page text.'},
        {[[
| umuna = Article text.
| TUNGTUNGAN = Talk page text.
| agar-aramat = User page text.
| sabali = Other pages text.
| panid = User talk:Example/test]], 'Other pages text.'},
        {[[
| nangruna = Article text.
| tungtungan = talk page text with a delete character here: ""
| user = User page text.
| sabali = Other pages text.
| page = User talk:Example/test]], 'talk page text with a delete character here: ""'},
        {[[
| umuna = Article text.
| tungtungan = Talk page text.
| wikipedia = Wikipedia page text.
| agar-aramat = User page text.
| sabali = Other pages text.
| demospace = Wikipedia ]], 'Wikipedia page text.'},
        {[[
| umuna = 
| tungtungan = talk page text with a delete character here: ""
| agar-aramat = User page text.
| sabali = Other pages text.
| panid = Foo]], ''},
        {[[
| umuna = Article text.
| tungtungan = talk page text with a delete character here: ""
| agar-aramat = 
| sabali = Other pages text.
| panid = User:Example/test]], ''},
        {[[
| umuna = Article text.
| tungtungan = talk page text with a delete character here: ""
| agar-aramat = User page text.
| papeles = Image page text.
| sabali = Other pages text.
| panid = File:Foo]], 'Image page text.'},
        {[[
| umuna = Article text.
| tungtungan = talk page text with a delete character here: ""
| agar-aramat = User page text.
| papeles = File page text.
| sabali = Other pages text.
| panid = Papeles:Foo]], 'File page text.'},
        {[[
| umuna = Article text.
| tungtungan = talk page text with a delete character here: ""
| agar-aramat = User page text.
| image = 
| sabali = Other pages text.
| panid = Papeles:Foo]], ''},
        {[[
| umuna = Article text.
| tungtungan = talk page text with a delete character here: ""
| agar-aramat = User page text.
| papeles = 
| sabali = Other pages text.
| panid = File:Foo]], ''},
        {[[
| umuna = Article text.
| tungtungan = talk page text with a delete character here: ""
| agar-aramat = User page text.
| mediawiki = MediaWiki page text.
| sabali = Other pages text.
| panid = MediaWiki:Foo]], 'MediaWiki page text.'},
        {[[
| umuna = Article text.
| tungtungan = talk page text with a delete character here: ""
| agar-aramat = User page text.
| plantilia = Template page text.
| sabali = Other pages text.
| panid = Template:Foo]], 'Template page text.'},
        {[[
| umuna = Article text.
| tungtungan = talk page text with a delete character here: ""
| tulong = Help page text.
| papeles = Image page text.
| sabali = Other pages text.
| panid = Tulong:Foo]], 'Help page text.'},
        {[[
| umuna = Article text.
| tungtungan = talk page text with a delete character here: ""
| agar-aramat = User page text.
| kategoria = Category page text.
| sabali = Other pages text.
| panid = Kategoria:Foo]], 'Category page text.'},
        {[[
| umuna = Article text.
| tungtungan = talk page text with a delete character here: ""
| agar-aramat = User page text.
| nonexistent = Nonexistent namespace page text.
| sabali = Other pages text.
| panid = Nonexistent:Foo]], 'Article text.'},
        {[[
| umuna = Article text.
| tungtungan = talk page text with a delete character here: ""
| agar-aramat = User page text.
| nonexistent = Nonexistent namespace page text.
| sabali = Other pages text.
| demospace = Nonexistent]], 'Other pages text.'},
    })
end

function p:test_bad_titles()
    self:preprocess_equals_many('{{#invoke:Panagduktal ti nagan ti espasio/pagipadasan|main', '}}', {
        {[==[
| main = Article text.
| talk = Any talk page text.
| user = User page text.
| other = Other pages text.
| page = Talk:Square [[brackets]] aren't allowed in page titles]==], 'Other pages text.'},
    })
end

function p:test_subject_namespaces()
    self:preprocess_equals_many('{{#invoke:Panagduktal ti nagan ti espasio/pagipadasan|main', '}}', {
           {[==[
| main = Article text.
| talk = Any talk page text.
| user = User page text.
| other = Other pages text.
| page = Talk:Foo]==], 'Any talk page text.'},
        {[==[
| subjectns = yes
| main = Article text.
| talk = Any talk page text.
| user = User page text.
| other = Other pages text.
| page = Talk:Foo]==], 'Article text.'},
        {[==[
| subjectns = no
| main = Article text.
| talk = Any talk page text.
| user = User page text.
| other = Other pages text.
| page = Talk:Foo]==], 'Any talk page text.'},
        {[==[
| subjectns = yes
| main = Article text.
| talk = Any talk page text.
| user = User page text.
| other = Other pages text.
| page = Wikipedia tungtungan:Foo]==], 'Other pages text.'},
    })
end

--function p:test_multiple_word_namespaces()
    --self:preprocess_equals_many('{{#invoke:Panagduktal ti nagan ti espasio/pagipadasan|main', '}}', {
           --{[==[
--| main = Article text.
--| talk = Any talk page text.
--| user = User page text.
--| gadget definition = Gadget definition text.
--| other = Other pages text.
--| page = Gadget definition:Foo]==], 'Gadget definition pages text.'},
    --})
--end

function p:test_returning_false()
    self:equals('Return false from article', nsDetect{page = 'Wikipedia', main = false}, false)
    self:equals('Return false from talk page', nsDetect{page = 'Talk:Wikipedia', main = true, talk = false}, false)
    self:equals('Return false from category page', nsDetect{page = 'Category:Wikipedians', main = true, talk = true, category = false}, false)
    self:equals('Return false from other page', nsDetect{page = 'Plantilia:Kita ti panid', main = true, talk = true, other = false}, false)
end

return p