-
Notifications
You must be signed in to change notification settings - Fork 123
/
Copy pathconstructor-fails.js
57 lines (39 loc) · 1.04 KB
/
constructor-fails.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
'use strict';
const assert = require('assert');
const mockRequire = require('mock-require');
const MockLinux = require('./mocks/linux');
const MockEpoll = require('./mocks/epoll');
mockRequire('epoll', MockEpoll);
const Gpio = require('../onoff').Gpio;
describe('constructor fails', function () {
let pin;
this.timeout(10000);
beforeEach(() => {
pin = 4;
});
it('fails to construct input while waiting for access permission', () => {
const expected = 'ENOENT';
let actual;
MockLinux.gpioWithoutPinFiles();
try {
const gpio = new Gpio(pin, 'in', 'both');
} catch (err) {
actual = err.code;
}
assert.deepEqual(actual, expected);
});
it('fails to construct output while waiting for access permission', () => {
const expected = 'ENOENT';
let actual;
MockLinux.gpioWithoutPinFiles();
try {
const gpio = new Gpio(pin, 'out');
} catch (err) {
actual = err.code;
}
assert.deepEqual(actual, expected);
});
afterEach(() => {
MockLinux.restore();
});
});