This repository was archived by the owner on Nov 20, 2020. It is now read-only.
forked from lunarmodules/busted
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathasync_spec.lua
87 lines (73 loc) · 2.51 KB
/
async_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
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
pending('testing the done callback with tokens', function()
it('Tests done call back ordered', function()
async()
stub(done, 'done_cb') -- create a stub to prevent actually calling 'done'
done:wait_ordered('1', '2', '3')
assert.has_no_error(function() done('1') end)
assert.has_error(function() done('1') end) -- was already done
assert.has_error(function() done('3') end) -- bad order
assert.has_no_error(function() done('2') end)
assert.has_error(function() done('this is no valid token') end)
assert.has_no_error(function() done('3') end)
assert.has_error(function() done('3') end) -- tokenlist empty by now
assert.stub(done.done_cb).was.called(1)
done.done_cb:revert() -- revert so test can complete
done()
end)
it('Tests done call back unordered', function()
async()
stub(done, 'done_cb') -- create a stub to prevent actually calling 'done'
done:wait_unordered('1', '2', '3')
assert.has_no_error(function() done('1') end)
assert.has_error(function() done('1') end) -- was already done
assert.has_no_error(function() done('3') end) -- different order
assert.has_no_error(function() done('2') end)
assert.has_error(function() done('this is no valid token') end)
assert.has_error(function() done('3') end) -- tokenlist empty by now
assert.stub(done.done_cb).was.called(1)
done.done_cb:revert() -- revert so test can complete
done()
end)
it('Tests done call back defaulting to ordered', function()
async()
stub(done, 'done_cb') -- create a stub to prevent actually calling 'done'
done:wait('1', '2')
assert.has_error(function() done('2') end) -- different order
assert.has_no_error(function() done('1') end)
assert.has_no_error(function() done('2') end)
done.done_cb:revert() -- revert so test can complete
done()
end)
end)
pending('testing done callbacks being provided for async tests', function()
setup(function()
async()
assert.is_table(done)
assert.is_function(done.wait)
done()
end)
before_each(function()
async()
assert.is_table(done)
assert.is_function(done.wait)
done()
end)
after_each(function()
async()
assert.is_table(done)
assert.is_function(done.wait)
done()
end)
teardown(function()
async()
assert.is_table(done)
assert.is_function(done.wait)
done()
end)
it('Tests done callbacks being provided for async tests', function()
async()
assert.is_table(done)
assert.is_function(done.wait)
done()
end)
end)