-
Notifications
You must be signed in to change notification settings - Fork 343
/
Copy pathtest.cli.run.js
67 lines (59 loc) · 1.82 KB
/
test.cli.run.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
57
58
59
60
61
62
63
64
65
66
67
/* @flow */
import {describe, it} from 'mocha';
import {assert} from 'chai';
import {
minimalAddonPath, fakeFirefoxPath,
withTempAddonDir, execWebExt, reportCommandErrors,
} from './common';
const EXPECTED_MESSAGE = 'Fake Firefox binary executed correctly.';
describe('web-ext run', () => {
it('should accept: --no-reload --source-dir SRCDIR --firefox FXPATH',
() => withTempAddonDir(
{addonPath: minimalAddonPath},
(srcDir) => {
const argv = [
'run', '--verbose', '--no-reload',
'--source-dir', srcDir,
'--firefox', fakeFirefoxPath,
];
const spawnOptions = {
env: {
PATH: process.env.PATH,
EXPECTED_MESSAGE,
addonPath: srcDir,
},
};
const cmd = execWebExt(argv, spawnOptions);
return cmd.waitForExit.then(({exitCode, stdout, stderr}) => {
if (stdout.indexOf(EXPECTED_MESSAGE) < 0) {
reportCommandErrors({
argv,
exitCode,
stdout,
stderr,
}, 'The fake Firefox binary has not been executed');
} else if (exitCode !== 0) {
reportCommandErrors({
argv,
exitCode,
stdout,
stderr,
});
}
});
}));
it('should not accept: --target INVALIDTARGET', async () => {
const argv = [
'run',
'--target', 'firefox-desktop',
'--target', 'firefox-android',
'--target', 'chromium',
'--target', 'not-supported',
];
return execWebExt(argv, {}).waitForExit.then(({exitCode, stderr}) => {
assert.notEqual(exitCode, 0);
assert.match(stderr, /Invalid values/);
assert.match(stderr, /Given: "not-supported"/);
});
});
});