forked from cpatni/aasm-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelpers.spec.coffee
56 lines (51 loc) · 1.82 KB
/
helpers.spec.coffee
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
{_callAction} = require '../lib/helpers'
describe 'Helper', ->
describe 'callAction', ->
it 'All methods should be executed', ->
class TestCallClass
init: -> true
someTestClass = new TestCallClass()
spyOn(someTestClass,"init")
_callAction("init",someTestClass)
expect(someTestClass.init).toHaveBeenCalled()
it 'All methods should be executed context of this class', ->
class TestCallClass
init: -> true
someTestClass = new TestCallClass()
spyOn(someTestClass,"init")
someMethod = ()-> @init()
_callAction(someMethod,someTestClass)
expect(someTestClass.init).toHaveBeenCalled()
it 'All methods should be executed if it if an Array of string', ->
class TestCallClass
init: -> true
done: -> true
someTestClass = new TestCallClass()
spyOn(someTestClass,"init")
spyOn(someTestClass,"done")
_callAction(["init",'done'],someTestClass)
expect(someTestClass.init).toHaveBeenCalled()
expect(someTestClass.done).toHaveBeenCalled()
it 'All methods should be executed if it if an Array of functions', ->
class TestCallClass
init: -> true
done: -> true
someTestClass = new TestCallClass()
spyOn(someTestClass,"init")
spyOn(someTestClass,"done")
someMethod = ()-> @init()
someOther = ()-> @done()
_callAction([someMethod,someOther],someTestClass)
expect(someTestClass.init).toHaveBeenCalled()
expect(someTestClass.done).toHaveBeenCalled()
it 'All methods should be executed if it if mixed array', ->
class TestCallClass
init: -> true
done: -> true
someTestClass = new TestCallClass()
spyOn(someTestClass,"init")
spyOn(someTestClass,"done")
someMethod = ()-> @init()
_callAction([someMethod,"done"],someTestClass)
expect(someTestClass.init).toHaveBeenCalled()
expect(someTestClass.done).toHaveBeenCalled()