|
1 | 1 | import { describe, it, expect } from 'bun:test'; |
2 | 2 | import { default as showCommand } from '../../../src/commands/quota/show'; |
3 | 3 |
|
| 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 | + |
4 | 30 | describe('quota show command', () => { |
5 | 31 | it('has correct name', () => { |
6 | 32 | expect(showCommand.name).toBe('quota show'); |
7 | 33 | }); |
8 | 34 |
|
9 | 35 | 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; }; |
29 | 39 | 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'); |
42 | 45 | } finally { |
43 | | - console.log = originalLog; |
| 46 | + console.log = origLog; |
44 | 47 | } |
45 | 48 | }); |
| 49 | + |
46 | 50 | }); |
0 commit comments