-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutil_spec.lua
50 lines (48 loc) · 1.21 KB
/
util_spec.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
describe('utility functions', function()
describe('pre-click button', function()
it('returns the button', function()
local count = 0
local button = wow.addon.PreClickButton('Foo', function()
count = count + 1
return {
macrotext = 'cow' .. count,
type = 'macro',
}
end)
assert.equal(wow.env.mooFoo, button)
button:Click()
wow.state:EnterCombat()
button:Click()
wow.state:LeaveCombat()
button:Click()
assert.same({
{ macro = 'cow1' },
{ macro = 'cow2' },
}, wow.state.commands)
end)
end)
describe('updater', function()
it('runs on first tick', function()
local count = 0
wow.addon.Updater(10000, function()
count = count + 1
end)
wow.state:TickUpdate(1)
assert.same(1, count)
end)
it('respects period', function()
local count = 0
wow.addon.Updater(10000, function()
count = count + 1
end)
for _ = 1, 9999 do
wow.state:TickUpdate(1)
end
assert.same(1, count)
wow.state:TickUpdate(1)
assert.same(1, count)
wow.state:TickUpdate(1)
assert.same(2, count)
end)
end)
end)