Module:Vanguard funds/testcases

-- Unit tests for Module:Vanguard funds. Click talk page to run tests. -- Example usage: --  -- Console example: --  mw.log(p.run_tests(mw.getCurrentFrame))

local p = require('Module:UnitTests')

function p:test_lookup_known_mutual_funds self:preprocess_equals("", "f:vtsax") self:preprocess_equals("", "f:vtsax") self:preprocess_equals("", "f:vtsax") end

function p:test_lookup_known_ETFs self:preprocess_equals("", "e:vti") self:preprocess_equals("", "e:vti") self:preprocess_equals("", "e:vti") end

function p:test_lookup_missing_entries self:preprocess_equals("", "undefined") self:preprocess_equals("", "undefined") end

function p:test_url_known_mutual_funds local nowiki = {nowiki = true} local invoke = ""	self:preprocess_equals(invoke:gsub(" ", "vtsax"), "https://fund/vtsax", nowiki) self:preprocess_equals(invoke:gsub(" ", "VTSAX"), "https://fund/vtsax", nowiki) self:preprocess_equals(invoke:gsub(" ", "0585"), "https://fund/vtsax", nowiki)

local invoke = ""	self:preprocess_equals(invoke:gsub(" ", "vtsax"), "https://fund/vtsax#abc", nowiki) self:preprocess_equals(invoke:gsub(" ", "VTSAX"), "https://fund/vtsax#abc", nowiki) self:preprocess_equals(invoke:gsub(" ", "0585"), "https://fund/vtsax#abc", nowiki) end

function p:test_url_known_ETFs local nowiki = {nowiki = true} local invoke = ""	self:preprocess_equals(invoke:gsub(" ", "vti"), "https://etf/vti", nowiki) self:preprocess_equals(invoke:gsub(" ", "VTI"), "https://etf/vti", nowiki) self:preprocess_equals(invoke:gsub(" ", "0970"), "https://etf/vti", nowiki)

local invoke = ""	self:preprocess_equals(invoke:gsub(" ", "vti"), "https://etf/vti#abc", nowiki) self:preprocess_equals(invoke:gsub(" ", "VTI"), "https://etf/vti#abc", nowiki) self:preprocess_equals(invoke:gsub(" ", "0970"), "https://etf/vti#abc", nowiki) end

function p:test_url_missing_entries local nowiki = {nowiki = true} local invoke = ""	self:preprocess_equals(invoke:gsub(" ", "XXXXX"),		"https://search/", nowiki) self:preprocess_equals(invoke:gsub(" ", "9999"),		"https://search/", nowiki)

local invoke = ""	self:preprocess_equals(invoke:gsub(" ", "XXXXX"),		"https://search/xxxxx#abc", nowiki) self:preprocess_equals(invoke:gsub(" ", "9999"),		"https://search/9999#abc", nowiki) end

return p