Files
WoW-Hybrid-gateway/tests/lua/native_guild_bank_buy_test.lua

22 lines
1.2 KiB
Lua

local hooks={}
function hooksecurefunc(t,n,f) hooks[n]=f end
local function C_AddOnsStub() end
C_AddOns={IsAddOnLoaded=function() return true end}
function CreateFrame() return {RegisterEvent=function() end,SetScript=function() end} end
format=string.format; NUM_GUILDBANK_TABS_PURCHASED="%d/%d tabs purchased"
local text,col,enabled,shown
local money, tabs = 600*10000, 1
function GetNumGuildBankTabs() return tabs end
function GetMoney() return money end
function SetMoneyFrameColor(_,c) col=c end
function MoneyFrame_Update(_,v) shown=v end
GuildBankFrame={UpdateTabs=function() end,UpdateTabBuyingInfo=function() end,
BuyInfo={PurchasedText={SetText=function(_,t) text=t end},PurchaseButton={SetEnabled=function(_,e) enabled=e end}}}
dofile(arg[1])
local h=hooks.UpdateTabBuyingInfo
h(GuildBankFrame); assert(text=="1/5 tabs purchased" and shown==500*10000 and enabled and col=="white",text)
tabs=2; h(GuildBankFrame); assert(shown==1000*10000 and enabled==false and col=="red")
tabs=0; money=2000*10000; h(GuildBankFrame); assert(shown==2000*10000 and enabled and text=="0/5 tabs purchased")
tabs=5; shown=nil; h(GuildBankFrame); assert(text=="5/5 tabs purchased" and shown==nil)
print("NativeGuildBank buy panel PASS")