Skip to content

Commit 4649c98

Browse files
author
John Doe
committed
refactor: wip
1 parent 20f9ffd commit 4649c98

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

packages/utils/src/lib/command.unit.test.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import process from 'node:process';
44
import { describe, expect, it, vi } from 'vitest';
55
import { formatCommandStatus } from './command.js';
66

7-
describe('formatCommand', () => {
7+
describe('formatCommandStatus', () => {
88
it('should format complex command with cwd, env, and status', () => {
99
expect(
1010
formatCommandStatus(
@@ -32,12 +32,17 @@ describe('formatCommand', () => {
3232
});
3333

3434
it('should not include cwd prefix when cwd is same as process.cwd()', () => {
35-
vi.spyOn(path, 'relative').mockReturnValue('');
3635
expect(formatCommandStatus('npx -v', { cwd: process.cwd() })).toStartWith(
3736
`${ansis.blue('$')}`,
3837
);
3938
});
4039

40+
it('should include cwd prefix when cwd is provided and different from process.cwd()', () => {
41+
expect(
42+
formatCommandStatus('npx -v', { cwd: path.join(process.cwd(), 'src') }),
43+
).toStartWith(`${ansis.blue('src')} `);
44+
});
45+
4146
it('should format command with multiple environment variables', () => {
4247
const result = formatCommandStatus('npx eslint .', {
4348
env: { NODE_ENV: 'test', NODE_OPTIONS: '--import tsx' },

0 commit comments

Comments
 (0)