-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.spec.js
30 lines (27 loc) · 870 Bytes
/
index.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
const assert = require('assert')
const Timer = require('.')
describe('Timer', () => {
it('start method', () => {
const timer = new Timer()
assert.strictEqual(timer.started.length, 0)
assert.strictEqual(timer.stopped.length, 0)
timer.start()
assert.notStrictEqual(timer.started.length, 0)
assert.strictEqual(timer.stopped.length, 0)
assert.throws(() => { timer.start() })
})
it('stop method', () => {
const timer = new Timer()
assert.throws(() => { timer.stop() })
timer.start().stop()
assert.notStrictEqual(timer.started.length, 0)
assert.notStrictEqual(timer.started.length, 0)
assert.throws(() => { timer.stop() })
})
it('diff method', () => {
const timer = new Timer()
assert.throws(() => { timer.diff() })
timer.start().stop()
assert.strictEqual(typeof timer.diff(), 'number')
})
})