Skip to content

Commit 52a9361

Browse files
Merge pull request #33 from raylanlin/test/coverage-improvements
test: add missing tests for file/upload, search/query, vision/describe
2 parents 765bb74 + ea862bd commit 52a9361

16 files changed

Lines changed: 182 additions & 36 deletions

test/commands/auth/login.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ describe('auth login command', () => {
1818
noColor: true,
1919
yes: false,
2020
dryRun: false,
21-
nonInteractive: false,
21+
nonInteractive: true,
2222
async: false,
2323
};
2424

@@ -31,7 +31,7 @@ describe('auth login command', () => {
3131
yes: false,
3232
dryRun: false,
3333
help: false,
34-
nonInteractive: false,
34+
nonInteractive: true,
3535
async: false,
3636
}),
3737
).rejects.toThrow('--api-key is required');

test/commands/auth/logout.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ describe('auth logout command', () => {
1717
noColor: true,
1818
yes: false,
1919
dryRun: true,
20-
nonInteractive: false,
20+
nonInteractive: true,
2121
async: false,
2222
};
2323

@@ -33,7 +33,7 @@ describe('auth logout command', () => {
3333
yes: false,
3434
dryRun: true,
3535
help: false,
36-
nonInteractive: false,
36+
nonInteractive: true,
3737
async: false,
3838
});
3939

test/commands/auth/refresh.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ describe('auth refresh command', () => {
1717
noColor: true,
1818
yes: false,
1919
dryRun: false,
20-
nonInteractive: false,
20+
nonInteractive: true,
2121
async: false,
2222
};
2323

@@ -29,7 +29,7 @@ describe('auth refresh command', () => {
2929
yes: false,
3030
dryRun: false,
3131
help: false,
32-
nonInteractive: false,
32+
nonInteractive: true,
3333
async: false,
3434
}),
3535
).rejects.toThrow('not authenticated via OAuth');

test/commands/auth/status.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ describe('auth status command', () => {
1717
noColor: true,
1818
yes: false,
1919
dryRun: false,
20-
nonInteractive: false,
20+
nonInteractive: true,
2121
async: false,
2222
};
2323

@@ -33,7 +33,7 @@ describe('auth status command', () => {
3333
yes: false,
3434
dryRun: false,
3535
help: false,
36-
nonInteractive: false,
36+
nonInteractive: true,
3737
async: false,
3838
});
3939

test/commands/config/set.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ describe('config set command', () => {
1717
noColor: true,
1818
yes: false,
1919
dryRun: false,
20-
nonInteractive: false,
20+
nonInteractive: true,
2121
async: false,
2222
};
2323

@@ -29,7 +29,7 @@ describe('config set command', () => {
2929
yes: false,
3030
dryRun: false,
3131
help: false,
32-
nonInteractive: false,
32+
nonInteractive: true,
3333
async: false,
3434
}),
3535
).rejects.toThrow('--key and --value are required');
@@ -46,7 +46,7 @@ describe('config set command', () => {
4646
noColor: true,
4747
yes: false,
4848
dryRun: false,
49-
nonInteractive: false,
49+
nonInteractive: true,
5050
async: false,
5151
};
5252

@@ -60,7 +60,7 @@ describe('config set command', () => {
6060
yes: false,
6161
dryRun: false,
6262
help: false,
63-
nonInteractive: false,
63+
nonInteractive: true,
6464
async: false,
6565
}),
6666
).rejects.toThrow('Invalid config key');

test/commands/config/show.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ describe('config show command', () => {
1818
noColor: true,
1919
yes: false,
2020
dryRun: false,
21-
nonInteractive: false,
21+
nonInteractive: true,
2222
async: false,
2323
};
2424

@@ -34,7 +34,7 @@ describe('config show command', () => {
3434
yes: false,
3535
dryRun: false,
3636
help: false,
37-
nonInteractive: false,
37+
nonInteractive: true,
3838
async: false,
3939
});
4040

test/commands/file/upload.test.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { describe, it, expect } from 'bun:test';
2+
import { default as uploadCommand } from '../../../src/commands/file/upload';
3+
4+
describe('file upload command', () => {
5+
it('has correct name', () => {
6+
expect(uploadCommand.name).toBe('file upload');
7+
});
8+
9+
it('requires file argument', async () => {
10+
const config = {
11+
apiKey: 'test-key',
12+
region: 'global' as const,
13+
baseUrl: 'https://api.minimax.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+
await expect(
26+
uploadCommand.execute(config, {
27+
quiet: false,
28+
verbose: false,
29+
noColor: true,
30+
yes: false,
31+
dryRun: true,
32+
help: false,
33+
nonInteractive: true,
34+
async: false,
35+
}),
36+
).rejects.toThrow('Missing required argument: --file');
37+
});
38+
});

test/commands/image/generate.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ describe('image generate command', () => {
1818
noColor: true,
1919
yes: false,
2020
dryRun: false,
21-
nonInteractive: false,
21+
nonInteractive: true,
2222
async: false,
2323
};
2424

@@ -30,7 +30,7 @@ describe('image generate command', () => {
3030
yes: false,
3131
dryRun: false,
3232
help: false,
33-
nonInteractive: false,
33+
nonInteractive: true,
3434
async: false,
3535
}),
3636
).rejects.toThrow('Missing required argument: --prompt');

test/commands/quota/show.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ describe('quota show command', () => {
1818
noColor: true,
1919
yes: false,
2020
dryRun: true,
21-
nonInteractive: false,
21+
nonInteractive: true,
2222
async: false,
2323
};
2424

@@ -34,7 +34,7 @@ describe('quota show command', () => {
3434
yes: false,
3535
dryRun: true,
3636
help: false,
37-
nonInteractive: false,
37+
nonInteractive: true,
3838
async: false,
3939
});
4040

test/commands/search/query.test.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { describe, it, expect } from 'bun:test';
2+
import { default as queryCommand } from '../../../src/commands/search/query';
3+
4+
describe('search query command', () => {
5+
it('has correct name', () => {
6+
expect(queryCommand.name).toBe('search query');
7+
});
8+
9+
it('requires q argument', async () => {
10+
const config = {
11+
apiKey: 'test-key',
12+
region: 'global' as const,
13+
baseUrl: 'https://api.minimax.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+
await expect(
26+
queryCommand.execute(config, {
27+
quiet: false,
28+
verbose: false,
29+
noColor: true,
30+
yes: false,
31+
dryRun: true,
32+
help: false,
33+
nonInteractive: true,
34+
async: false,
35+
}),
36+
).rejects.toThrow('--q is required');
37+
});
38+
});

0 commit comments

Comments
 (0)