Module:utilities/testcases

local tests = require("Module:UnitTests")

local languages = require("Module:languages/cache") local format_categories = require("Module:utilities").format_categories

local currentTitle local function specialGetCurrentTitle return currentTitle end

function tests:test_format_categories local examples = { { "English lemmas", "en", "cliché", "" }, { "English lemmas", "en", "Reconstruction:Proto-Indo-European/dn̥ǵʰwéh₂s", "" }, { "English lemmas", "en", "Appendix:English doublets", "" }, { "English lemmas", "en", "Citations:word", "" }, { "English lemmas", "en", "Wiktionary:Grease pit", "" }, }	local actualGetCurrentTitle = mw.title.getCurrentTitle mw.title.getCurrentTitle = specialGetCurrentTitle local options = { display = mw.text.nowiki } self:iterate(examples,		function (self, category, lang, title, expected)			currentTitle = mw.title.new(title)			self:equals( category .. " (" .. lang .. ", " .. title .. ")", format_categories({ category }, languages[lang]), expected, options)		end) mw.title.getCurrentTitle = actualGetCurrentTitle end

return tests