-
Notifications
You must be signed in to change notification settings - Fork 2
/
test.js
35 lines (30 loc) · 887 Bytes
/
test.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
import { expect } from 'chai';
import lockscreen from './';
describe('LockScreen', () => {
const platform = process.platform;
beforeEach(() => {
Object.defineProperty(process, 'platform', {
value: 'dummyOS'
});
});
afterEach(() => {
Object.defineProperty(process, 'platform', {
value: platform
});
});
it('returns the stdout of the defined command for the platform', (done) => {
lockscreen((err, stdout) => {
expect(stdout.replace('\n','')).to.equal(process.version);
done();
}, {
dummyOS: 'node -v'
});
});
it('throws an error if the command for the current platform is not available', () => {
expect(() => {
lockscreen((err, stdout) => {}, {
notAvailableOS: 'this command should not be executed since "process.platform" isn`t "notAvailableOS"'
});
}).to.throw(Error);
});
});