github.com/insionng/yougam@v0.0.0-20170714101924-2bc18d833463/public/libs/vue-1.0.24/test/unit/specs/util/debug_spec.js (about)

     1  var _ = require('src/util')
     2  var Vue = require('src')
     3  var config = require('src/config')
     4  var warnPrefix = '[Vue warn]: '
     5  
     6  if (typeof console !== 'undefined') {
     7    describe('Util - Debug', function () {
     8      beforeEach(function () {
     9        spyOn(console, 'error')
    10      })
    11  
    12      it('warn when silent is false', function () {
    13        config.silent = false
    14        _.warn.and.callThrough()
    15        _.warn('oops')
    16        expect(console.error).toHaveBeenCalledWith(warnPrefix + 'oops')
    17      })
    18  
    19      it('format component name', function () {
    20        config.silent = false
    21        _.warn.and.callThrough()
    22        _.warn('oops', new Vue({ name: 'foo' }))
    23        expect(console.error).toHaveBeenCalledWith(warnPrefix + 'oops (found in component: <foo>)')
    24        _.warn('oops', { name: 'bar' })
    25        expect(console.error).toHaveBeenCalledWith(warnPrefix + 'oops (found in component: <bar>)')
    26      })
    27  
    28      it('not warn when silent is ture', function () {
    29        config.silent = true
    30        _.warn.and.callThrough()
    31        _.warn('oops')
    32        expect(console.error).not.toHaveBeenCalled()
    33      })
    34    })
    35  }