|
1 | 1 | import { describe, expect, it } from 'vitest'; |
2 | | -import { createCliCommandString, objectToCliArgs } from './cli.js'; |
| 2 | +import { |
| 3 | + createCliCommandObject, |
| 4 | + createCliCommandString, |
| 5 | + objectToCliArgs, |
| 6 | +} from './cli.js'; |
3 | 7 |
|
4 | 8 | describe('objectToCliArgs', () => { |
5 | 9 | it('should empty params', () => { |
@@ -99,3 +103,34 @@ describe('createCliCommandString', () => { |
99 | 103 | expect(result).toBe('npx @code-pushup/cli autorun --verbose'); |
100 | 104 | }); |
101 | 105 | }); |
| 106 | + |
| 107 | +describe('createCliCommandObject', () => { |
| 108 | + it('should create command out of object for arguments', () => { |
| 109 | + expect(createCliCommandObject({ args: { verbose: true } })).toStrictEqual({ |
| 110 | + args: ['@code-pushup/cli', '--verbose'], |
| 111 | + command: 'npx', |
| 112 | + }); |
| 113 | + }); |
| 114 | + |
| 115 | + it('should create command out of object for arguments with positional', () => { |
| 116 | + expect( |
| 117 | + createCliCommandObject({ |
| 118 | + args: { _: 'autorun', verbose: true }, |
| 119 | + }), |
| 120 | + ).toStrictEqual({ |
| 121 | + args: ['@code-pushup/cli', 'autorun', '--verbose'], |
| 122 | + command: 'npx', |
| 123 | + }); |
| 124 | + }); |
| 125 | + |
| 126 | + it('should create command out of object for arguments with bin', () => { |
| 127 | + expect( |
| 128 | + createCliCommandObject({ |
| 129 | + bin: 'node_modules/@code-pushup/cli/src/bin.js', |
| 130 | + }), |
| 131 | + ).toStrictEqual({ |
| 132 | + args: ['node_modules/@code-pushup/cli/src/bin.js'], |
| 133 | + command: 'npx', |
| 134 | + }); |
| 135 | + }); |
| 136 | +}); |
0 commit comments