-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
49 lines (42 loc) · 1006 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
'use strict';
const {execFile} = require('child_process');
const {promisify} = require('util');
const libfaketimeEnv = require('.');
const test = require('tape');
test('libfaketimeEnv()', async t => {
t.equal(
(await promisify(execFile)('node', ['-p', 'new Date().getFullYear()'], {
env: {
...process.env,
...await libfaketimeEnv(),
FAKETIME: '2018-01-02 03:04:05'
}
})).stdout,
'2018\n',
'should return environment variables that make libfaketime work.'
);
t.end();
});
test('Argument validation', async t => {
try {
await libfaketimeEnv('?');
t.fail('Unexpectedly succeeded.');
} catch ({message}) {
t.equal(
message,
'Expected no arguments, but got 1 argument.',
'should fail when it takes an argument.'
);
}
try {
await libfaketimeEnv('!', '?');
t.fail('Unexpectedly succeeded.');
} catch ({message}) {
t.equal(
message,
'Expected no arguments, but got 2 arguments.',
'should fail when it takes arguments.'
);
}
t.end();
});