Skip to content

Commit 06ced01

Browse files
committed
test(nx-plugin): add unit tests for executor command helper
1 parent b3d95b6 commit 06ced01

File tree

1 file changed

+36
-1
lines changed

1 file changed

+36
-1
lines changed

packages/nx-plugin/src/executors/internal/cli.unit.test.ts

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
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';
37

48
describe('objectToCliArgs', () => {
59
it('should empty params', () => {
@@ -99,3 +103,34 @@ describe('createCliCommandString', () => {
99103
expect(result).toBe('npx @code-pushup/cli autorun --verbose');
100104
});
101105
});
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

Comments
 (0)