Skip to content

Commit d26527b

Browse files
committed
refactor tests
1 parent a0500cc commit d26527b

File tree

1 file changed

+8
-53
lines changed

1 file changed

+8
-53
lines changed

js/__tests__/helper.test.js

Lines changed: 8 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -172,57 +172,7 @@ describe('SentryCli helper', () => {
172172
});
173173
});
174174

175-
describe('silentLogs functionality', () => {
176-
let consoleInfoSpy;
177-
let consoleErrorSpy;
178-
179-
beforeEach(() => {
180-
consoleInfoSpy = jest.spyOn(console, 'info').mockImplementation();
181-
consoleErrorSpy = jest.spyOn(console, 'error').mockImplementation();
182-
});
183-
184-
afterEach(() => {
185-
consoleInfoSpy.mockRestore();
186-
consoleErrorSpy.mockRestore();
187-
});
188-
189-
test('determineSuccessMessage returns correct message for releases new', () => {
190-
const args = ['releases', 'new', 'v1.0.0'];
191-
const message = helper.determineSuccessMessage(args);
192-
expect(message).toBe('✓ Release v1.0.0 created');
193-
});
194-
195-
test('determineSuccessMessage returns correct message for sourcemaps upload', () => {
196-
const args = ['sourcemaps', 'upload'];
197-
const message = helper.determineSuccessMessage(args);
198-
expect(message).toBe('✓ Source maps uploaded');
199-
});
200-
201-
test('determineSuccessMessage returns null for version check', () => {
202-
const args = ['--version'];
203-
const message = helper.determineSuccessMessage(args);
204-
expect(message).toBe(null);
205-
});
206-
207-
test('determineSuccessMessage handles empty args', () => {
208-
const message = helper.determineSuccessMessage([]);
209-
expect(message).toBe(null);
210-
});
211-
212-
test('determineSuccessMessage handles null args', () => {
213-
const message = helper.determineSuccessMessage(null);
214-
expect(message).toBe(null);
215-
});
216-
217-
test('execute with silent=true takes precedence over silentLogs=true', async () => {
218-
const result = await helper.execute(['--version'], false, true, true);
219-
220-
expect(result).toBe('');
221-
expect(consoleInfoSpy).not.toHaveBeenCalled();
222-
});
223-
});
224-
225-
describe('command type coverage', () => {
175+
describe('determineSuccessMessage type coverage', () => {
226176
test('determineSuccessMessage handles supported high-impact commands', () => {
227177
const testCases = [
228178
{ args: ['releases', 'new', 'v1.0.0'], expected: '✓ Release v1.0.0 created' },
@@ -307,6 +257,13 @@ describe('SentryCli helper', () => {
307257
expect(consoleInfoSpy).not.toHaveBeenCalled();
308258
});
309259

260+
test('execute with silent=true takes precedence over silentLogs=true', async () => {
261+
const result = await helper.execute(['--version'], false, true, true);
262+
263+
expect(result).toBe('');
264+
expect(consoleInfoSpy).not.toHaveBeenCalled();
265+
});
266+
310267
test('execute with live=false, silentLogs=true shows success message and returns empty string', async () => {
311268
const result = await helper.execute(['sourcemaps', 'upload'], false, false, true);
312269

@@ -334,14 +291,12 @@ describe('SentryCli helper', () => {
334291
const result3 = await helper.execute(['sourcemaps', 'upload'], false, true, true);
335292
expect(result3).toBe('');
336293

337-
// No success messages should be shown when silent=true
338294
expect(consoleInfoSpy).not.toHaveBeenCalled();
339295
});
340296

341297
test('execute with live=true and normal mode uses stdio inherit and resolves with undefined', async () => {
342298
const result = await helper.execute(['--version'], true, false, false);
343299

344-
// Should resolve with undefined (stdio inherit mode)
345300
expect(result).toBeUndefined();
346301
expect(consoleInfoSpy).not.toHaveBeenCalled();
347302
});

0 commit comments

Comments
 (0)