github.com/insionng/yougam@v0.0.0-20170714101924-2bc18d833463/public/libs/vue-1.0.24/test/unit/specs/instance/init_spec.js (about) 1 var Vue = require('src') 2 var init = Vue.prototype._init 3 4 describe('Instance Init', function () { 5 var stub = { 6 constructor: { 7 options: { a: 1, b: 2 } 8 }, 9 _updateRef: jasmine.createSpy(), 10 _initEvents: jasmine.createSpy(), 11 _callHook: jasmine.createSpy(), 12 _initState: jasmine.createSpy(), 13 $mount: jasmine.createSpy() 14 } 15 16 var options = { 17 a: 2, 18 el: {} 19 } 20 21 init.call(stub, options) 22 23 it('should setup properties', function () { 24 expect(stub.$el).toBe(null) 25 expect(stub.$root).toBe(stub) 26 expect(stub.$refs).toBeTruthy() 27 expect(stub.$els).toBeTruthy() 28 expect(stub._watchers).toBeTruthy() 29 expect(stub._directives).toBeTruthy() 30 expect(stub._events).toBeTruthy() 31 expect(stub._eventsCount).toBeTruthy() 32 }) 33 34 it('should merge options', function () { 35 expect(stub.$options.a).toBe(2) 36 expect(stub.$options.b).toBe(2) 37 }) 38 39 it('should call other init methods', function () { 40 expect(stub._initEvents).toHaveBeenCalled() 41 expect(stub._initState).toHaveBeenCalled() 42 expect(stub._updateRef).toHaveBeenCalled() 43 }) 44 45 it('should call created hook', function () { 46 expect(stub._callHook).toHaveBeenCalledWith('created') 47 }) 48 49 it('should call $mount when options.el is present', function () { 50 expect(stub.$mount).toHaveBeenCalledWith(stub.$options.el) 51 }) 52 })