Skip to content

Commit 60ce237

Browse files
committed
test: improve quota show command tests
1 parent 6ed7c6b commit 60ce237

1 file changed

Lines changed: 36 additions & 32 deletions

File tree

test/commands/quota/show.test.ts

Lines changed: 36 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,50 @@
11
import { describe, it, expect } from 'bun:test';
22
import { default as showCommand } from '../../../src/commands/quota/show';
33

4+
const baseConfig = {
5+
apiKey: 'test-key',
6+
region: 'global' as const,
7+
baseUrl: 'https://api.mmx.io',
8+
output: 'text' as const,
9+
timeout: 10,
10+
verbose: false,
11+
quiet: false,
12+
noColor: true,
13+
yes: false,
14+
dryRun: false,
15+
nonInteractive: true,
16+
async: false,
17+
};
18+
19+
const baseFlags = {
20+
quiet: false,
21+
verbose: false,
22+
noColor: true,
23+
yes: false,
24+
dryRun: false,
25+
help: false,
26+
nonInteractive: true,
27+
async: false,
28+
};
29+
430
describe('quota show command', () => {
531
it('has correct name', () => {
632
expect(showCommand.name).toBe('quota show');
733
});
834

935
it('handles dry run', async () => {
10-
const config = {
11-
apiKey: 'test-key',
12-
region: 'global' as const,
13-
baseUrl: 'https://api.mmx.io',
14-
output: 'text' as const,
15-
timeout: 10,
16-
verbose: false,
17-
quiet: false,
18-
noColor: true,
19-
yes: false,
20-
dryRun: true,
21-
nonInteractive: true,
22-
async: false,
23-
};
24-
25-
const originalLog = console.log;
26-
let output = '';
27-
console.log = (msg: string) => { output += msg; };
28-
36+
let captured = '';
37+
const origLog = console.log;
38+
console.log = (msg: string) => { captured += msg; };
2939
try {
30-
await showCommand.execute(config, {
31-
quiet: false,
32-
verbose: false,
33-
noColor: true,
34-
yes: false,
35-
dryRun: true,
36-
help: false,
37-
nonInteractive: true,
38-
async: false,
39-
});
40-
41-
expect(output).toContain('Would fetch quota');
40+
await showCommand.execute(
41+
{ ...baseConfig, dryRun: true },
42+
{ ...baseFlags, dryRun: true },
43+
);
44+
expect(captured).toContain('Would fetch quota');
4245
} finally {
43-
console.log = originalLog;
46+
console.log = origLog;
4447
}
4548
});
49+
4650
});

0 commit comments

Comments
 (0)