-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
00-misc.spec.js
37 lines (33 loc) · 922 Bytes
/
00-misc.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
const { expect } = require('chai');
const gpiod = require('..');
describe('libgpiod miscellaneous bindings', () => {
it('should get libgpiod version', done => {
expect(gpiod.version()).to.be.ok;
done();
});
it('should get line instant value', done => {
const value = gpiod.getInstantLineValue(0, 17);
expect(value).to.eq(0);
done();
});
it('should NOT get line instant value due wrong chip name', done => {
try {
gpiod.getInstantLineValue('/dev/gpiochipZero', 17);
} catch (e) {
expect(e.errno).eq(2)
expect(e.code).eq('ENOENT')
expect(e.syscall).eq('::getInstantLineValue - Unable to get instant value')
done();
}
});
it('should blink line with instant value', done => {
let count = 7;
const interval = setInterval(() => {
gpiod.setInstantLineValue('/dev/gpiochip0', 17, count-- % 2);
if (count === 0) {
clearInterval(interval);
done();
}
}, 70);
});
});