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 invoke = ""	self:preprocess_equals(invoke:gsub(" ", "vtsax"), "https://fund/vtsax", {nowiki = true}) self:preprocess_equals(invoke:gsub(" ", "VTSAX"), "https://fund/vtsax", {nowiki = true}) self:preprocess_equals(invoke:gsub(" ", "0585"), "https://fund/vtsax", {nowiki = true})

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

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

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

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

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

return p