forked from docusign/code-examples-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasic.js
More file actions
72 lines (59 loc) · 1.7 KB
/
basic.js
File metadata and controls
72 lines (59 loc) · 1.7 KB
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
72
'use strict';
var blinker = require('..');
var Code = require('code');
var Lab = require('lab');
var lab = Lab.script();
exports.lab = lab;
var describe = lab.describe;
var it = lab.it;
var before = lab.before;
var after = lab.after;
var expect = Code.expect;
describe('blinker exports', function () {
it('exports an object', function (done) {
expect(blinker).to.be.instanceOf(Object);
done();
});
it('exports an object with method "use"', function (done) {
expect(blinker.use).to.be.instanceOf(Function);
done();
});
it('wraps LEDs', function (done) {
function mockLED() {
return {
state: 0,
setCount: 0,
output: function (state) {
this.state = state;
this.setCount += 1;
},
toggle: function () {
this.output(!this.state);
}
};
}
var mock = {
led: [
mockLED(),
mockLED(),
mockLED(),
mockLED()
]
}, blink;
mock.led[0].output('foo');
expect(mock.led[0].state).to.equal('foo');
blink = blinker.use(mock);
blink.green.on();
expect(mock.led[0].state).to.equal(1);
blink.green.off();
expect(mock.led[0].state).to.equal(0);
blink.red.blink(2, 10);
blink.blue.blink(1);
setTimeout(function () {
expect(mock.led[0].setCount).to.equal(3);
expect(mock.led[1].setCount).to.equal(2);
expect(mock.led[2].setCount).to.equal(4);
done();
}, 150);
});
});