-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdebug_spec.js
44 lines (36 loc) · 1.06 KB
/
debug_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
var _ = require('../../../../src/util')
var config = require('../../../../src/config')
var infoPrefix = '[Vue info]: '
var warnPrefix = '[Vue warn]: '
config.silent = true
if (typeof console !== 'undefined') {
describe('Util - Debug', function () {
beforeEach(function () {
spyOn(console, 'log')
spyOn(console, 'warn')
if (console.trace) {
spyOn(console, 'trace')
}
})
it('log when debug is true', function () {
config.debug = true
_.log('hello')
expect(console.log).toHaveBeenCalledWith(infoPrefix + 'hello')
})
it('not log when debug is false', function () {
config.debug = false
_.log('bye')
expect(console.log).not.toHaveBeenCalled()
})
it('warn when silent is false', function () {
config.silent = false
_.warn('oops')
expect(console.warn).toHaveBeenCalledWith(warnPrefix + 'oops')
})
it('not warn when silent is ture', function () {
config.silent = true
_.warn('oops')
expect(console.warn).not.toHaveBeenCalled()
})
})
}