-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit_spec.js
52 lines (44 loc) · 1.32 KB
/
init_spec.js
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
var Vue = require('src')
var init = Vue.prototype._init
describe('Instance Init', function () {
var stub = {
constructor: {
options: { a: 1, b: 2 }
},
_updateRef: jasmine.createSpy(),
_initEvents: jasmine.createSpy(),
_callHook: jasmine.createSpy(),
_initState: jasmine.createSpy(),
$mount: jasmine.createSpy()
}
var options = {
a: 2,
el: {}
}
init.call(stub, options)
it('should setup properties', function () {
expect(stub.$el).toBe(null)
expect(stub.$root).toBe(stub)
expect(stub.$refs).toBeTruthy()
expect(stub.$els).toBeTruthy()
expect(stub._watchers).toBeTruthy()
expect(stub._directives).toBeTruthy()
expect(stub._events).toBeTruthy()
expect(stub._eventsCount).toBeTruthy()
})
it('should merge options', function () {
expect(stub.$options.a).toBe(2)
expect(stub.$options.b).toBe(2)
})
it('should call other init methods', function () {
expect(stub._initEvents).toHaveBeenCalled()
expect(stub._initState).toHaveBeenCalled()
expect(stub._updateRef).toHaveBeenCalled()
})
it('should call created hook', function () {
expect(stub._callHook).toHaveBeenCalledWith('created')
})
it('should call $mount when options.el is present', function () {
expect(stub.$mount).toHaveBeenCalledWith(stub.$options.el)
})
})