forked from liriliri/eruda
-
Notifications
You must be signed in to change notification settings - Fork 0
/
console.js
71 lines (62 loc) · 1.55 KB
/
console.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
describe('console', function () {
let tool = eruda.get('console')
tool.config.set('asyncRender', false)
let $tool = $('.eruda-console')
let logger = tool._logger
function log(i) {
return logs()[i].container
}
function logs() {
return logger.displayLogs
}
beforeEach(function () {
eruda.show('console')
logger.clear(true)
})
describe('config', function () {
let config = tool.config
it('override console', function () {
config.set('overrideConsole', true)
console.log('test')
expect($(log(0))).toContainText('test')
})
})
describe('ui', function () {
it('clear', function () {
tool.log('test')
$('.eruda-clear-console').click()
expect($tool.find('.eruda-logs li')).toHaveLength(0)
})
it('filter', function () {
tool.log('test')
tool.warn('test')
expect(logs()).toHaveLength(2)
$('.eruda-filter[data-filter="warn"]').click()
expect(logs()).toHaveLength(1)
$('.eruda-filter[data-filter="all"]').click()
})
})
describe('execute', function () {
it('js', function () {
$tool.find('textarea').val('1+2')
$('.eruda-execute').click()
expect($(log(1))).toContainText('3')
})
})
describe('events', function () {
it('log', function () {
let sum = 0
function add(num) {
sum += num
}
tool.on('log', add)
tool.log(5)
expect(sum).toBe(5)
tool.log(6)
expect(sum).toBe(11)
tool.off('log', add)
tool.log(1)
expect(sum).toBe(11)
})
})
})