Module:Category handler/testcases explained

-- Unit tests for . Click talk page to run tests.local m_category_handler = require('Module:Category handler/sandbox')local chmain = m_category_handler._mainlocal ScribuntoUnit = require('Module:ScribuntoUnit')local suite = ScribuntoUnit:new

-- Define table of defaultslocal d =

-- Valuesd.absent = nild.blank = d.negation = '¬'d.yes = 'yes'd.no = 'no'd.subpageOnly = 'only'd.subpageNo = 'no'

-- Categoriesd.category = 'Category:Somecat'd.category1 = 'Category:Somecat1'd.category2 = 'Category:Somecat2'

-- Pagesd.article = 'Somearticle'd.file = 'File:Example.png'd.talk = 'Talk:Foo'd.archive = 'User talk:Example/Archive 5'd.subpage = 'User:Example/test'd.basepage = 'User:Example'

-- Paramsd.archiveParam = 'talk'

---------------------------------------------------------------------------------- Test nil--------------------------------------------------------------------------------

function suite:test_nil self:assertEquals(d.absent, chmain)end

---------------------------------------------------------------------------------- Test defaults--------------------------------------------------------------------------------

function suite:test_default_current_page -- Will test either module or module talk space, neither of which are categorised by default. self:assertEquals(d.absent, chmain)end

function suite:test_default_main self:assertEquals(d.category, chmain)end

function suite:test_default_file self:assertEquals(d.category, chmain)end

---------------------------------------------------------------------------------- Test numbered parameters--------------------------------------------------------------------------------

function suite:test_numbered_main self:assertEquals(d.category, chmain)end

function suite:test_numbered_two_params self:assertEquals(d.category2, chmain)end

---------------------------------------------------------------------------------- Test overriding defaults--------------------------------------------------------------------------------

function suite:test_numbered_main self:assertEquals(d.absent, chmain

)end

---------------------------------------------------------------------------------- Test blank namespace parameters--------------------------------------------------------------------------------

function suite:test_blank_namespace_talk self:assertEquals(d.blank, chmain)end

---------------------------------------------------------------------------------- Test other parameter--------------------------------------------------------------------------------

function suite:test_other_only self:assertEquals(d.category, chmain)end

---------------------------------------------------------------------------------- Test nocat parameter--------------------------------------------------------------------------------

function suite:test_nocat_true self:assertEquals(d.absent, chmain)end

function suite:test_nocat_blank self:assertEquals(d.category, chmain)end

function suite:test_nocat_yes self:assertEquals(d.absent, chmain)end

function suite:test_nocat_false self:assertEquals(d.category, chmain)end

function suite:test_nocat_no self:assertEquals(d.category, chmain)end

---------------------------------------------------------------------------------- Test categories parameter--------------------------------------------------------------------------------

function suite:test_categories_true self:assertEquals(d.category, chmain)end

function suite:test_categories_blank self:assertEquals(d.category, chmain)end

function suite:test_categories_yes self:assertEquals(d.category, chmain)end

function suite:test_categories_false self:assertEquals(d.absent, chmain)end

function suite:test_categories_no self:assertEquals(d.absent, chmain)end

---------------------------------------------------------------------------------- Test category2 parameter--------------------------------------------------------------------------------

function suite:test_category2_no self:assertEquals(d.absent, chmain)end

function suite:test_category2_blank self:assertEquals(d.absent, chmain)end

function suite:test_category2_negation self:assertEquals(d.category, chmain)end

function suite:test_category2_blacklist self:assertEquals(d.category, chmain)end

---------------------------------------------------------------------------------- Test subpage parameter--------------------------------------------------------------------------------

function suite:test_subpage_no_basepage self:assertEquals(d.category, chmain)end

function suite:test_subpage_no_subpage self:assertEquals(d.absent, chmain)end

function suite:test_subpage_only_basepage self:assertEquals(d.absent, chmain)end

function suite:test_subpage_only_subpage self:assertEquals(d.category, chmain)end

---------------------------------------------------------------------------------- Test blacklist--------------------------------------------------------------------------------

function suite:test_blacklist_archives self:assertEquals(d.absent, chmain)end

function suite:test_blacklist_archives_lowercase self:assertEquals(d.absent, chmain)end

function suite:test_blacklist_archives_notarchive self:assertEquals(d.category, chmain)end

function suite:test_blacklist_archives_incident_archive self:assertEquals(d.category, chmain)end

function suite:test_blacklist_main_page self:assertEquals(d.absent, chmain)end

function suite:test_blacklist_main_page_talk self:assertEquals(d.category, chmain)end

function suite:test_blacklist_cascade self:assertEquals(d.absent, chmain)end

function suite:test_blacklist_cascade_slash self:assertEquals(d.absent, chmain)end

function suite:test_blacklist_cascade_subpage self:assertEquals(d.absent, chmain)end

function suite:test_blacklist_cascade_not_subpage self:assertEquals(d.category, chmain)end

function suite:test_blacklist_cascade_talk self:assertEquals(d.category, chmain)end

function suite:test_blacklist_ubx self:assertEquals(d.absent, chmain)end

function suite:test_blacklist_ubx_talk self:assertEquals(d.absent, chmain)end

function suite:test_blacklist_ubx_subpage self:assertEquals(d.absent, chmain)end

function suite:test_blacklist_ubx_talk_subpage self:assertEquals(d.absent, chmain)end

function suite:test_blacklist_template_index_basepage self:assertEquals(d.category, chmain)end

function suite:test_blacklist_template_index_slash self:assertEquals(d.absent, chmain)end

function suite:test_blacklist_template_index_not_subpage self:assertEquals(d.category, chmain)end

function suite:test_blacklist_template_index_subpage self:assertEquals(d.absent, chmain)end

---------------------------------------------------------------------------------- Test namespace params--------------------------------------------------------------------------------

function suite:test_main self:assertEquals(d.category, chmain

)end

function suite:test_talk self:assertEquals(d.category, chmain)end

function suite:test_user self:assertEquals(d.category, chmain)end

function suite:test_user_talk self:assertEquals(d.category, chmain) self:assertEquals(d.absent, chmain) self:assertEquals(d.absent, chmain)end

function suite:test_wikipedia self:assertEquals(d.category, chmain)end

function suite:test_wikipedia self:assertEquals(d.category, chmain)end

function suite:test_project self:assertEquals(d.category, chmain)end

function suite:test_wp self:assertEquals(d.category, chmain)end

function suite:test_file self:assertEquals(d.category, chmain)end

function suite:test_image self:assertEquals(d.category, chmain)end

function suite:test_mediawiki self:assertEquals(d.category, chmain)end

function suite:test_template self:assertEquals(d.category, chmain)end

function suite:test_help self:assertEquals(d.category, chmain)end

function suite:test_category self:assertEquals(d.category, chmain)end

function suite:test_category self:assertEquals(d.category, chmain)end

function suite:test_portal self:assertEquals(d.category, chmain)end

function suite:test_draft self:assertEquals(d.category, chmain)end

function suite:test_timedtext self:assertEquals(d.category, chmain)end

function suite:test_module self:assertEquals(d.category, chmain)end

function suite:test_special self:assertEquals(d.category, chmain)end

function suite:test_media self:assertEquals(d.category, chmain)end

return suite