|
13 | 13 | // limitations under the License.
|
14 | 14 |
|
15 | 15 | import { getOptionsFromArgs } from '../cli';
|
| 16 | +import { |
| 17 | + DEFAULT_DEBUGGER_HOST, |
| 18 | + DEFAULT_DEBUGGER_PORT, |
| 19 | +} from '../../lib/debugger-client'; |
| 20 | +import { |
| 21 | + DEFAULT_SERVER_HOST, |
| 22 | + DEFAULT_SERVER_PORT, |
| 23 | +} from '../../lib/cdt-proxy'; |
16 | 24 |
|
17 | 25 | describe('getOptionsFromArgs', () => {
|
18 | 26 |
|
| 27 | + function getOptionsFromUserArgs(userArgs: string[]) { |
| 28 | + return getOptionsFromArgs(['node', 'jerry-debugger.js'].concat(userArgs)); |
| 29 | + } |
| 30 | + |
19 | 31 | it('works without --inspect-brk', () => {
|
20 |
| - const opt = getOptionsFromArgs([]); |
21 |
| - expect(opt.proxyAddress.host).toEqual(undefined); |
22 |
| - expect(opt.proxyAddress.port).toEqual(undefined); |
| 32 | + const opt = getOptionsFromUserArgs([]); |
| 33 | + expect(opt.proxyAddress.host).toEqual(DEFAULT_SERVER_HOST); |
| 34 | + expect(opt.proxyAddress.port).toEqual(DEFAULT_SERVER_PORT); |
23 | 35 | });
|
24 | 36 |
|
25 | 37 | it('parses --inspect-brk with port only', () => {
|
26 |
| - const opt = getOptionsFromArgs(['--inspect-brk=1234']); |
| 38 | + const opt = getOptionsFromUserArgs(['--inspect-brk=1234']); |
27 | 39 | expect(opt.proxyAddress.host).toEqual(undefined);
|
28 | 40 | expect(opt.proxyAddress.port).toEqual(1234);
|
29 | 41 | });
|
30 | 42 |
|
31 | 43 | it('parses --inspect-brk with no port', () => {
|
32 |
| - const opt = getOptionsFromArgs(['--inspect-brk=10.10.10.10:']); |
| 44 | + const opt = getOptionsFromUserArgs(['--inspect-brk=10.10.10.10:']); |
33 | 45 | expect(opt.proxyAddress.host).toEqual('10.10.10.10');
|
34 | 46 | expect(opt.proxyAddress.port).toEqual(undefined);
|
35 | 47 | });
|
36 | 48 |
|
37 | 49 | it('parses --inspect-brk with no host', () => {
|
38 |
| - const opt = getOptionsFromArgs(['--inspect-brk=:1234']); |
| 50 | + const opt = getOptionsFromUserArgs(['--inspect-brk=:1234']); |
39 | 51 | expect(opt.proxyAddress.host).toEqual(undefined);
|
40 | 52 | expect(opt.proxyAddress.port).toEqual(1234);
|
41 | 53 | });
|
42 | 54 |
|
43 | 55 | it('parses --inspect-brk with host and port', () => {
|
44 |
| - const opt = getOptionsFromArgs(['--inspect-brk=10.10.10.10:1234']); |
| 56 | + const opt = getOptionsFromUserArgs(['--inspect-brk=10.10.10.10:1234']); |
45 | 57 | expect(opt.proxyAddress.host).toEqual('10.10.10.10');
|
46 | 58 | expect(opt.proxyAddress.port).toEqual(1234);
|
47 | 59 | });
|
48 | 60 |
|
49 | 61 | it('works without --jerry-remote', () => {
|
50 |
| - const opt = getOptionsFromArgs([]); |
51 |
| - expect(opt.remoteAddress.host).toEqual(undefined); |
52 |
| - expect(opt.remoteAddress.port).toEqual(undefined); |
| 62 | + const opt = getOptionsFromUserArgs([]); |
| 63 | + expect(opt.remoteAddress.host).toEqual(DEFAULT_DEBUGGER_HOST); |
| 64 | + expect(opt.remoteAddress.port).toEqual(DEFAULT_DEBUGGER_PORT); |
53 | 65 | });
|
54 | 66 |
|
55 | 67 | it('parses --jerry-remote with port only', () => {
|
56 |
| - const opt = getOptionsFromArgs(['--jerry-remote=1234']); |
| 68 | + const opt = getOptionsFromUserArgs(['--jerry-remote=1234']); |
57 | 69 | expect(opt.remoteAddress.host).toEqual(undefined);
|
58 | 70 | expect(opt.remoteAddress.port).toEqual(1234);
|
59 | 71 | });
|
60 | 72 |
|
61 | 73 | it('parses --jerry-remote with host and port', () => {
|
62 |
| - const opt = getOptionsFromArgs(['--jerry-remote=10.10.10.10:1234']); |
| 74 | + const opt = getOptionsFromUserArgs(['--jerry-remote=10.10.10.10:1234']); |
63 | 75 | expect(opt.remoteAddress.host).toEqual('10.10.10.10');
|
64 | 76 | expect(opt.remoteAddress.port).toEqual(1234);
|
65 | 77 | });
|
66 | 78 |
|
67 | 79 | it('verbose defaults to false', () => {
|
68 |
| - const opt = getOptionsFromArgs([]); |
| 80 | + const opt = getOptionsFromUserArgs([]); |
69 | 81 | expect(opt.verbose).toEqual(false);
|
70 | 82 | });
|
71 | 83 |
|
72 | 84 | it('parses verbose flag', () => {
|
73 |
| - const opt = getOptionsFromArgs(['--verbose']); |
| 85 | + const opt = getOptionsFromUserArgs(['--verbose']); |
74 | 86 | expect(opt.verbose).toEqual(true);
|
75 | 87 | });
|
76 | 88 |
|
77 | 89 | it('parses v alias for verbose', () => {
|
78 |
| - const opt = getOptionsFromArgs(['-v']); |
| 90 | + const opt = getOptionsFromUserArgs(['-v']); |
79 | 91 | expect(opt.verbose).toEqual(true);
|
80 | 92 | });
|
81 | 93 |
|
82 | 94 | it('jsfile defaults to untitled.js', () => {
|
83 |
| - const opt = getOptionsFromArgs([]); |
| 95 | + const opt = getOptionsFromUserArgs([]); |
84 | 96 | expect(opt.jsfile).toEqual('untitled.js');
|
85 | 97 | });
|
86 | 98 |
|
87 | 99 | it('returns client source as jsfile', () => {
|
88 |
| - const opt = getOptionsFromArgs(['foo/bar.js']); |
| 100 | + const opt = getOptionsFromUserArgs(['foo/bar.js']); |
89 | 101 | expect(opt.jsfile).toEqual('foo/bar.js');
|
90 | 102 | });
|
91 | 103 |
|
|
0 commit comments