-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy path01-chip.spec.js
38 lines (32 loc) · 1.02 KB
/
01-chip.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
const { expect } = require('chai');
const gpiod = require('..');
describe('libgpiod chip bindings', () => {
// 40 for our gpio-sim setup, 54 for raspberry pi zero
const numLines = process.env.NUM_LINES ?? 40
it('should \'create\' a new chip by number', done => {
const chip0 = new gpiod.Chip('0');
expect(chip0.getNumberOfLines()).eq(numLines);
done();
});
it('should \'create\' a new chip by name', done => {
const chip0 = new gpiod.Chip('gpiochip0');
expect(chip0.getNumberOfLines()).eq(numLines);
done();
});
it('should \'create\' a new chip by path', done => {
const chip0 = new gpiod.Chip('/dev/gpiochip0');
expect(chip0.getNumberOfLines()).eq(numLines);
done();
});
it('should NOT \'create\' a chip because it does not exists', done => {
try {
const chip0 = new gpiod.Chip('/dev/gpiochippuden');
chip0.getNumberOfLines()
} catch (e) {
expect(e.errno).eq(2)
expect(e.code).eq("ENOENT")
expect(e.syscall).eq("Chip::new - Unable to open device /dev/gpiochippuden")
done();
}
});
});