Skip to content

Commit 830698d

Browse files
chore: replace test() with it() in all vitest test files (#268)
1 parent 52d6cf9 commit 830698d

86 files changed

Lines changed: 767 additions & 798 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

tests/commands/api-keys/create.test.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import {
55
expect,
66
it,
77
type MockInstance,
8-
test,
98
vi,
109
} from 'vitest';
1110
import {
@@ -57,7 +56,7 @@ describe('api-keys create command', () => {
5756
}
5857
});
5958

60-
test('creates API key with --name flag', async () => {
59+
it('creates API key with --name flag', async () => {
6160
spies = setupOutputSpies();
6261

6362
const { createApiKeyCommand } = await import(
@@ -72,7 +71,7 @@ describe('api-keys create command', () => {
7271
expect(args.name).toBe('Production');
7372
});
7473

75-
test('passes permission flag to SDK', async () => {
74+
it('passes permission flag to SDK', async () => {
7675
spies = setupOutputSpies();
7776

7877
const { createApiKeyCommand } = await import(
@@ -87,7 +86,7 @@ describe('api-keys create command', () => {
8786
expect(args.permission).toBe('sending_access');
8887
});
8988

90-
test('passes domain_id (snake_case) to SDK when --domain-id is provided', async () => {
89+
it('passes domain_id (snake_case) to SDK when --domain-id is provided', async () => {
9190
spies = setupOutputSpies();
9291

9392
const { createApiKeyCommand } = await import(
@@ -109,7 +108,7 @@ describe('api-keys create command', () => {
109108
expect(args.domain_id).toBe('domain-123');
110109
});
111110

112-
test('outputs JSON result when non-interactive', async () => {
111+
it('outputs JSON result when non-interactive', async () => {
113112
spies = setupOutputSpies();
114113

115114
const { createApiKeyCommand } = await import(
@@ -125,7 +124,7 @@ describe('api-keys create command', () => {
125124
expect(parsed.token).toBe('re_testtoken1234567890');
126125
});
127126

128-
test('errors with missing_name when --name absent in non-interactive mode', async () => {
127+
it('errors with missing_name when --name absent in non-interactive mode', async () => {
129128
setNonInteractive();
130129
errorSpy = vi.spyOn(console, 'error').mockImplementation(() => {});
131130
exitSpy = mockExitThrow();
@@ -141,7 +140,7 @@ describe('api-keys create command', () => {
141140
expect(output).toContain('missing_name');
142141
});
143142

144-
test('errors with missing_name when --json is set even in TTY', async () => {
143+
it('errors with missing_name when --json is set even in TTY', async () => {
145144
Object.defineProperty(process.stdin, 'isTTY', {
146145
value: true,
147146
writable: true,
@@ -174,7 +173,7 @@ describe('api-keys create command', () => {
174173
expect(output).toContain('missing_name');
175174
});
176175

177-
test('does not call SDK when missing_name error is raised', async () => {
176+
it('does not call SDK when missing_name error is raised', async () => {
178177
setNonInteractive();
179178
errorSpy = vi.spyOn(console, 'error').mockImplementation(() => {});
180179
exitSpy = mockExitThrow();
@@ -189,7 +188,7 @@ describe('api-keys create command', () => {
189188
expect(mockCreate).not.toHaveBeenCalled();
190189
});
191190

192-
test('errors with auth_error when no API key', async () => {
191+
it('errors with auth_error when no API key', async () => {
193192
setNonInteractive();
194193
delete process.env.RESEND_API_KEY;
195194
process.env.XDG_CONFIG_HOME = '/tmp/nonexistent-resend';
@@ -209,7 +208,7 @@ describe('api-keys create command', () => {
209208
expect(output).toContain('auth_error');
210209
});
211210

212-
test('errors with create_error when SDK returns an error', async () => {
211+
it('errors with create_error when SDK returns an error', async () => {
213212
setNonInteractive();
214213
mockCreate.mockResolvedValueOnce(
215214
mockSdkError('Name already taken', 'validation_error'),

tests/commands/api-keys/delete.test.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import {
33
beforeEach,
44
describe,
55
expect,
6+
it,
67
type MockInstance,
7-
test,
88
vi,
99
} from 'vitest';
1010
import {
@@ -51,7 +51,7 @@ describe('api-keys delete command', () => {
5151
exitSpy = undefined;
5252
});
5353

54-
test('deletes API key with --yes flag', async () => {
54+
it('deletes API key with --yes flag', async () => {
5555
spies = setupOutputSpies();
5656

5757
const { deleteApiKeyCommand } = await import(
@@ -64,7 +64,7 @@ describe('api-keys delete command', () => {
6464
expect(mockRemove).toHaveBeenCalledWith('test-key-id');
6565
});
6666

67-
test('outputs synthesized deleted JSON on success', async () => {
67+
it('outputs synthesized deleted JSON on success', async () => {
6868
spies = setupOutputSpies();
6969

7070
const { deleteApiKeyCommand } = await import(
@@ -80,7 +80,7 @@ describe('api-keys delete command', () => {
8080
expect(parsed.id).toBe('test-key-id');
8181
});
8282

83-
test('errors with confirmation_required when --yes absent in non-interactive mode', async () => {
83+
it('errors with confirmation_required when --yes absent in non-interactive mode', async () => {
8484
setNonInteractive();
8585
errorSpy = vi.spyOn(console, 'error').mockImplementation(() => {});
8686
exitSpy = mockExitThrow();
@@ -96,7 +96,7 @@ describe('api-keys delete command', () => {
9696
expect(output).toContain('confirmation_required');
9797
});
9898

99-
test('does not call SDK when confirmation is required but not given', async () => {
99+
it('does not call SDK when confirmation is required but not given', async () => {
100100
setNonInteractive();
101101
errorSpy = vi.spyOn(console, 'error').mockImplementation(() => {});
102102
exitSpy = mockExitThrow();
@@ -111,7 +111,7 @@ describe('api-keys delete command', () => {
111111
expect(mockRemove).not.toHaveBeenCalled();
112112
});
113113

114-
test('errors with auth_error when no API key', async () => {
114+
it('errors with auth_error when no API key', async () => {
115115
setNonInteractive();
116116
delete process.env.RESEND_API_KEY;
117117
process.env.XDG_CONFIG_HOME = '/tmp/nonexistent-resend';
@@ -131,7 +131,7 @@ describe('api-keys delete command', () => {
131131
expect(output).toContain('auth_error');
132132
});
133133

134-
test('errors with delete_error when SDK returns an error', async () => {
134+
it('errors with delete_error when SDK returns an error', async () => {
135135
setNonInteractive();
136136
mockRemove.mockResolvedValueOnce(
137137
mockSdkError('API key not found', 'not_found'),

tests/commands/auth/list.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { mkdirSync, rmSync } from 'node:fs';
22
import { tmpdir } from 'node:os';
33
import { join } from 'node:path';
44
import { Command } from '@commander-js/extra-typings';
5-
import { afterEach, beforeEach, describe, expect, test } from 'vitest';
5+
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
66
import { storeApiKey } from '../../../src/lib/config';
77
import { captureTestEnv, setupOutputSpies } from '../../helpers';
88

@@ -35,7 +35,7 @@ describe('auth list command', () => {
3535
rmSync(tmpDir, { recursive: true, force: true });
3636
});
3737

38-
test('lists profiles in JSON mode', async () => {
38+
it('lists profiles in JSON mode', async () => {
3939
spies = setupOutputSpies();
4040
storeApiKey('re_default', 'default');
4141
storeApiKey('re_staging', 'staging');
@@ -50,7 +50,7 @@ describe('auth list command', () => {
5050
]);
5151
});
5252

53-
test('shows message when no profiles configured', async () => {
53+
it('shows message when no profiles configured', async () => {
5454
spies = setupOutputSpies();
5555

5656
const program = await createProgram();

tests/commands/auth/login.test.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import {
1212
beforeEach,
1313
describe,
1414
expect,
15+
it,
1516
type MockInstance,
16-
test,
1717
vi,
1818
} from 'vitest';
1919
import {
@@ -72,7 +72,7 @@ describe('login command', () => {
7272
rmSync(tmpDir, { recursive: true, force: true });
7373
});
7474

75-
test('rejects key that fails API validation', async () => {
75+
it('rejects key that fails API validation', async () => {
7676
mockDomainListResult = {
7777
data: null,
7878
error: {
@@ -101,7 +101,7 @@ describe('login command', () => {
101101
expect(existsSync(configPath)).toBe(false);
102102
});
103103

104-
test('rejects key not starting with re_', async () => {
104+
it('rejects key not starting with re_', async () => {
105105
setNonInteractive();
106106
errorSpy = vi.spyOn(console, 'error').mockImplementation(() => {});
107107
exitSpy = mockExitThrow();
@@ -115,7 +115,7 @@ describe('login command', () => {
115115
expect(output).toContain('invalid_key_format');
116116
});
117117

118-
test('rejects empty or whitespace-only key with missing_key in non-interactive', async () => {
118+
it('rejects empty or whitespace-only key with missing_key in non-interactive', async () => {
119119
setNonInteractive();
120120
errorSpy = vi.spyOn(console, 'error').mockImplementation(() => {});
121121
exitSpy = mockExitThrow();
@@ -129,7 +129,7 @@ describe('login command', () => {
129129
expect(output).toContain('missing_key');
130130
});
131131

132-
test('trims API key before storing', async () => {
132+
it('trims API key before storing', async () => {
133133
setNonInteractive();
134134

135135
const { loginCommand } = await import('../../../src/commands/auth/login');
@@ -142,7 +142,7 @@ describe('login command', () => {
142142
expect(data.profiles.default.api_key).toBe('re_trimmed_key_456');
143143
});
144144

145-
test('stores valid key to credentials.json and sets active_profile', async () => {
145+
it('stores valid key to credentials.json and sets active_profile', async () => {
146146
setupOutputSpies();
147147

148148
const { loginCommand } = await import('../../../src/commands/auth/login');
@@ -156,7 +156,7 @@ describe('login command', () => {
156156
expect(data.active_profile).toBe('default');
157157
});
158158

159-
test('requires --key in non-interactive mode', async () => {
159+
it('requires --key in non-interactive mode', async () => {
160160
setupOutputSpies();
161161
errorSpy = vi.spyOn(console, 'error').mockImplementation(() => {});
162162
exitSpy = mockExitThrow();
@@ -169,7 +169,7 @@ describe('login command', () => {
169169
expect(output).toContain('missing_key');
170170
});
171171

172-
test('errors with missing_key when --json is set but --key is omitted even in TTY', async () => {
172+
it('errors with missing_key when --json is set but --key is omitted even in TTY', async () => {
173173
Object.defineProperty(process.stdin, 'isTTY', {
174174
value: true,
175175
writable: true,
@@ -201,7 +201,7 @@ describe('login command', () => {
201201
loginCommand.parent = null;
202202
});
203203

204-
test('non-interactive login stores as default when profiles exist', async () => {
204+
it('non-interactive login stores as default when profiles exist', async () => {
205205
// Pre-populate credentials with an existing profile
206206
const configDir = join(tmpDir, 'resend');
207207
mkdirSync(configDir, { recursive: true });
@@ -228,7 +228,7 @@ describe('login command', () => {
228228
expect(data.active_profile).toBe('production');
229229
});
230230

231-
test('auto-switches to profile specified via --profile flag', async () => {
231+
it('auto-switches to profile specified via --profile flag', async () => {
232232
setupOutputSpies();
233233

234234
const { Command } = await import('@commander-js/extra-typings');
@@ -263,7 +263,7 @@ describe('login command', () => {
263263
expect(data.profiles.staging.api_key).toBe('re_staging_key_123');
264264
});
265265

266-
test('deprecated --team alias works like --profile', async () => {
266+
it('deprecated --team alias works like --profile', async () => {
267267
setupOutputSpies();
268268

269269
const { Command } = await import('@commander-js/extra-typings');
@@ -287,7 +287,7 @@ describe('login command', () => {
287287
expect(data.profiles.legacy.api_key).toBe('re_team_alias_key_123');
288288
});
289289

290-
test('rejects invalid profile name with invalid_profile_name', async () => {
290+
it('rejects invalid profile name with invalid_profile_name', async () => {
291291
setNonInteractive();
292292
errorSpy = vi.spyOn(console, 'error').mockImplementation(() => {});
293293
exitSpy = mockExitThrow();
@@ -312,7 +312,7 @@ describe('login command', () => {
312312
expect(output).toContain('invalid_profile_name');
313313
});
314314

315-
test('trims --profile before storing', async () => {
315+
it('trims --profile before storing', async () => {
316316
setupOutputSpies();
317317

318318
const { Command } = await import('@commander-js/extra-typings');
@@ -337,7 +337,7 @@ describe('login command', () => {
337337
expect(data.active_profile).toBe('myprofile');
338338
});
339339

340-
test('--json output includes success, config_path, and profile', async () => {
340+
it('--json output includes success, config_path, and profile', async () => {
341341
setupOutputSpies();
342342
const logSpy = vi.spyOn(console, 'log').mockImplementation(() => {});
343343

@@ -363,7 +363,7 @@ describe('login command', () => {
363363
expect(parsed.profile).toBe('prod');
364364
});
365365

366-
test('accepts sending-only key and stores permission', async () => {
366+
it('accepts sending-only key and stores permission', async () => {
367367
mockDomainListResult = {
368368
data: null,
369369
error: {
@@ -386,7 +386,7 @@ describe('login command', () => {
386386
expect(data.profiles.default.permission).toBe('sending_access');
387387
});
388388

389-
test('stores full_access permission for valid full access key', async () => {
389+
it('stores full_access permission for valid full access key', async () => {
390390
setupOutputSpies();
391391

392392
const { loginCommand } = await import('../../../src/commands/auth/login');
@@ -400,7 +400,7 @@ describe('login command', () => {
400400
expect(data.profiles.default.permission).toBe('full_access');
401401
});
402402

403-
test('--json output includes permission for sending-only key', async () => {
403+
it('--json output includes permission for sending-only key', async () => {
404404
mockDomainListResult = {
405405
data: null,
406406
error: {

tests/commands/auth/logout.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import {
66
beforeEach,
77
describe,
88
expect,
9+
it,
910
type MockInstance,
10-
test,
1111
vi,
1212
} from 'vitest';
1313
import {
@@ -60,7 +60,7 @@ describe('logout command', () => {
6060
);
6161
}
6262

63-
test('removes credentials file when it exists (non-interactive)', async () => {
63+
it('removes credentials file when it exists (non-interactive)', async () => {
6464
spies = setupOutputSpies();
6565
writeCredentials();
6666

@@ -75,7 +75,7 @@ describe('logout command', () => {
7575
expect(output.config_path).toContain('credentials.json');
7676
});
7777

78-
test('exits cleanly when no credentials file exists (non-interactive)', async () => {
78+
it('exits cleanly when no credentials file exists (non-interactive)', async () => {
7979
spies = setupOutputSpies();
8080

8181
const { logoutCommand } = await import('../../../src/commands/auth/logout');
@@ -86,7 +86,7 @@ describe('logout command', () => {
8686
expect(output.already_logged_out).toBe(true);
8787
});
8888

89-
test('logout without --profile removes all profiles', async () => {
89+
it('logout without --profile removes all profiles', async () => {
9090
spies = setupOutputSpies();
9191
writeCredentials({ staging: 're_staging_key', production: 're_prod_key' });
9292

@@ -101,7 +101,7 @@ describe('logout command', () => {
101101
expect(output.profile).toBe('all');
102102
});
103103

104-
test('logout with --profile removes only that profile', async () => {
104+
it('logout with --profile removes only that profile', async () => {
105105
spies = setupOutputSpies();
106106
writeCredentials({ staging: 're_staging_key', production: 're_prod_key' });
107107

@@ -133,7 +133,7 @@ describe('logout command', () => {
133133
expect(output.profile).toBe('staging');
134134
});
135135

136-
test('exits with error when file removal fails', async () => {
136+
it('exits with error when file removal fails', async () => {
137137
spies = setupOutputSpies();
138138
errorSpy = vi.spyOn(console, 'error').mockImplementation(() => {});
139139
exitSpy = mockExitThrow();

0 commit comments

Comments
 (0)