debug_spec.js 1.0 KB

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