-
Notifications
You must be signed in to change notification settings - Fork 2
/
angular-class-test.coffee
69 lines (46 loc) · 2.28 KB
/
angular-class-test.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
57
58
59
60
61
62
63
64
65
66
67
68
69
class Helper extends IdFly.AngularClass
@_import = [
'DEP1',
'DEP2',
]
@helper: 'HELPER'
describe 'AngularClass.factory', ->
it 'should return array', ->
expect(Helper.factory() instanceof Array).toEqual(true)
it 'should return array with dependecies 1', ->
expect(Helper.factory()[0]).toEqual('DEP1')
it 'should return array with dependecies 2', ->
expect(Helper.factory()[1]).toEqual('DEP2')
it 'should return array with callback', ->
expect(typeof Helper.factory()[2]).toEqual('function')
it 'should return callback that returns object', ->
expect(typeof Helper.factory()[2]()).toEqual('object')
it 'should return callback that sets dependecies 1', ->
expect(Helper.factory()[2]('MODULE')._DEP1).toEqual('MODULE')
it 'should return callback that sets dependecies 2', ->
expect(Helper.factory()[2](null, 'MODULE')._DEP2).toEqual('MODULE')
it 'should inject array as dependency 1 properly', ->
expect(Helper.factory()[2]([1, 2, 3])._DEP1).toEqual([1, 2, 3])
it 'should inject array as dependency 2 properly', ->
expect(Helper.factory()[2](null, [1, 2, 3])._DEP2).toEqual([1, 2, 3])
it 'should return instance of Helper', ->
expect(Helper.factory()[2]() instanceof Helper).toEqual(true)
describe 'AngularClass.classFactory', ->
it 'should return array', ->
expect(Helper.classFactory() instanceof Array).toEqual(true)
it 'should return callback that returns class', ->
expect(Helper.classFactory()[2]().helper).toEqual('HELPER')
it 'should return callback that sets dependencies', ->
expect(Helper.classFactory()[2]('MODULE')._DEP1).toEqual('MODULE')
it 'should not sets dependencies to original class', ->
Helper.classFactory()[2]()
expect(Helper._DEP1).toEqual(undefined)
describe 'AngularClass.directive', ->
it 'should return function', ->
expect(typeof Helper.directive() == 'function').toEqual(true)
it 'should return function that returns object', ->
expect(typeof Helper.directive()()).toEqual('object')
it 'should return function that returns object with all properties set', ->
expect(Helper.directive()().helper).toEqual('HELPER')
it 'should return function that returns object with controller set', ->
expect(Helper.directive()().controller instanceof Array).toEqual(true)