-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
test.lua
121 lines (105 loc) · 2.83 KB
/
test.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
--- WoW Stubbing
function strmatch(arg, arg2)
return arg
end
local frameMock = {}
function frameMock:SetFrameStrata() end
function frameMock:Hide(f) return f end
function frameMock:CreateTexture(args) return frameMock end
function frameMock:SetTexture(args) return frameMock end
function frameMock:SetBlendMode(args) return frameMock end
function frameMock:SetAllPoints(args) return frameMock end
function frameMock:SetScript(args) return frameMock end
_G['SlashCmdList'] = {}
function CreateFrame()
return frameMock
end
function frameMock:RegisterEvent() return frameMock end
function UnitLevel(level)
return level
end
function IsSpellKnown(spellId)
return false
end
function UnitClass(target)
return 'Rogue', 'ROGUE', 7
end
function GetCoinTextureString(amount)
return amount
end
local TestFailures = {}
function UnitTest(message, test)
require 'main'
function assert(test, value)
if (value ~= nil) then
if (test == value) then
print '.'
else
TestFailures[test] = value
print 'F'
end
else
if (test == true) then
print(test)
print '.'
else
TestFailures[test] = value
print 'F'
end
end
end
function GetAddon()
return _G['BrokerClassicTraining']
end
test()
end
--- Project Dependencies
dofile('Libs/LibStub/LibStub.lua')
dofile('Libs/CallbackHandler-1.0/CallbackHandler-1.0.lua')
dofile('Libs/LibQTip-1.0/LibQTip-1.0.lua')
dofile('Libs/LibDataBroker-1.1/LibDataBroker-1.1.lua')
dofile('Libs/AceEvent-3.0/AceEvent-3.0.lua')
dofile('Libs/AceAddon-3.0/AceAddon-3.0.lua')
-- All classes have spells defined
local classes = {
['warrior'] = 'WARRIOR',
['paladin'] = 'PALADIN',
['shaman'] = 'SHAMAN',
['hunter'] = 'HUNTER',
['druid'] = 'DRUID',
['rogue'] = 'ROGUE',
['mage'] = 'MAGE',
['warlock'] = 'WARLOCK',
['priest'] = 'PRIEST'
}
UnitTest('A level 60 paladin, with no spells learned', function ()
table.foreach(classes, function (_, class)
dofile('Libs/ClassSpells-1.0/'..class..'.lua')
local addon = GetAddon()
local classSpells = _G['Broker_Classic_Training_' .. class]
if (classSpells ~= nil) then
addon:FilterSpells(classSpells, 60)
table.foreach(addon.Feed.spells, print)
else
print(class)
end
end)
end)
-- CONTEXT: Paladin, Level 60
-- UnitTest('A level 60 paladin, with no spells learned', function ()
-- dofile('Libs/ClassSpells-1.0/paladin.lua')
-- -- Mocks
-- function UnitClass(target)
-- return '', 'PALADIN', 9
-- end
-- function IsSpellKnown(spellId)
-- return false
-- end
-- local addon = GetAddon()
-- -- Tests
-- local _,class,_ = UnitClass('player')
-- local classSpells = _G['Broker_Classic_Training_' .. class]
-- table.foreach(classSpells, print)
-- table.foreach(addon, print)
-- local data = GetAddon():BuildTrainingData()
-- end)