10BC0 chore: applied suggestions · podman-desktop/podman-desktop@c0bc225 · GitHub
[go: up one dir, main page]

Skip to content

Commit c0bc225

Browse files
committed
chore: applied suggestions
Signed-off-by: Evzen Gasta <evzen.ml@seznam.cz>
1 parent 545cf54 commit c0bc225

File tree

1 file changed

+6
-138
lines changed

1 file changed

+6
-138
lines changed

packages/main/src/plugin/tasks/task-manager.spec.ts

Lines changed: 6 additions & 138 deletions
Original file line numberDiff line numberDiff line change
@@ -53,19 +53,22 @@ const experimentalConfigurationManager: ExperimentalConfigurationManager = {
5353
isExperimentalConfigurationEnabled: vi.fn(),
5454
} as unknown as ExperimentalConfigurationManager;
5555

56+
let taskManager: TaskManager;
57+
5658
beforeEach(() => {
5759
vi.resetAllMocks();
58-
});
5960

60-
test('task manager init should register a configuration option', async () => {
61-
const taskManager = new TaskManager(
61+
taskManager = new TaskManager(
6262
apiSender,
6363
statusBarRegistry,
6464
commandRegistry,
6565
configurationRegistry,
6666
experimentalConfigurationManager,
6767
);
6868
taskManager.init();
69+
});
70+
71+
test('task manager init should register a configuration option', async () => {
6972
expect(configurationRegistry.registerConfigurations).toHaveBeenCalledOnce();
7073
expect(configurationRegistry.registerConfigurations).toHaveBeenCalledWith(
7174
expect.arrayContaining([expect.objectContaining({ id: 'preferences.experimental.tasks' })]),
@@ -114,13 +117,6 @@ test('task manager init should register a configuration option', async () => {
114117
});
115118

116119
test('create task with title', async () => {
117-
const taskManager = new TaskManager(
118-
apiSender,
119-
statusBarRegistry,
120-
commandRegistry,
121-
configurationRegistry,
122-
experimentalConfigurationManager,
123-
);
124120
const task = taskManager.createTask({ title: 'title' });
125121
expect(task.id).equal('task-1');
126122
expect(task.name).equal('title');
@@ -136,13 +132,6 @@ test('create task with title', async () => {
136132
});
137133

138134
test('create task without title', async () => {
139-
const taskManager = new TaskManager(
140-
apiSender,
141-
statusBarRegistry,
142-
commandRegistry,
143-
configurationRegistry,
144-
experimentalConfigurationManager,
145-
);
146135
const task = taskManager.createTask();
147136
expect(task.id).equal('task-1');
148137
expect(task.name).equal('Task 1');
@@ -158,13 +147,6 @@ test('create task without title', async () => {
158147
});
159148

160149
test('create multiple tasks with title', async () => {
161-
const taskManager = new TaskManager(
162-
apiSender,
163-
statusBarRegistry,
164-
commandRegistry,
165-
configurationRegistry,
166-
experimentalConfigurationManager,
167-
);
168150
const task = taskManager.createTask({ title: 'title' });
169151
expect(task.id).equal('task-1');
170152
expect(task.name).equal('title');
@@ -206,13 +188,6 @@ test('create multiple tasks with title', async () => {
206188
});
207189

208190
test('create notification task with body', async () => {
209-
const taskManager = new TaskManager(
210-
apiSender,
211-
statusBarRegistry,
212-
commandRegistry,
213-
configurationRegistry,
214-
experimentalConfigurationManager,
215-
);
216191
const task = taskManager.createNotificationTask({
217192
title: 'title',
218193
body: 'body',
@@ -234,13 +209,6 @@ test('create notification task with body', async () => {
234209
});
235210

236211
test('create error notification task', async () => {
237-
const taskManager = new TaskManager(
238-
apiSender,
239-
statusBarRegistry,
240-
commandRegistry,
241-
configurationRegistry,
242-
experimentalConfigurationManager,
243-
);
244212
const task = taskManager.createNotificationTask({
245213
title: 'title',
246214
body: 'body',
@@ -263,13 +231,6 @@ test('create error notification task', async () => {
263231
});
264232

265233
test('create task without body', async () => {
266-
const taskManager = new TaskManager(
267-
apiSender,
268-
statusBarRegistry,
269-
commandRegistry,
270-
configurationRegistry,
271-
experimentalConfigurationManager,
272-
);
273234
const task = taskManager.createNotificationTask({
274235
title: 'title',
275236
});
@@ -289,13 +250,6 @@ test('create task without body', async () => {
289250
});
290251

291252
test('create task with markdown actions', async () => {
292-
const taskManager = new TaskManager(
293-
apiSender,
294-
statusBarRegistry,
295-
commandRegistry,
296-
configurationRegistry,
297-
experimentalConfigurationManager,
298-
);
299253
const task = taskManager.createNotificationTask({
300254
title: 'title',
301255
markdownActions: 'action',
@@ -316,13 +270,6 @@ test('create task with markdown actions', async () => {
316270
});
317271

318272
test('create multiple stateful tasks with title', async () => {
319-
const taskManager = new TaskManager(
320-
apiSender,
321-
statusBarRegistry,
322-
commandRegistry,
323-
configurationRegistry,
324-
experimentalConfigurationManager,
325-
);
326273
const task = taskManager.createNotificationTask({
327274
title: 'title',
328275
});
@@ -376,14 +323,6 @@ test('create multiple stateful tasks with title', async () => {
376323
});
377324

378325
test('clear tasks should clear task not in running state', async () => {
379-
const taskManager = new TaskManager(
380-
apiSender,
381-
statusBarRegistry,
382-
commandRegistry,
383-
configurationRegistry,
384-
experimentalConfigurationManager,
385-
);
386-
387326
const task1 = taskManager.createTask({ title: 'Task 1' });
388327
task1.status = 'success';
389328
const task2 = taskManager.createTask({ title: 'Task 2' });
@@ -416,13 +355,6 @@ test('clear tasks should clear task not in running state', async () => {
416355
});
417356

418357
test('create task being cancellable', async () => {
419-
const taskManager = new TaskManager(
420-
apiSender,
421-
statusBarRegistry,
422-
commandRegistry,
423-
configurationRegistry,
424-
experimentalConfigurationManager,
425-
);
426358
const task = taskManager.createTask({ cancellable: true, cancellationTokenSourceId: 1 });
427359
expect(task.id).equal('task-1') BB4C ;
428360
expect(task.name).equal('Task 1');
@@ -442,72 +374,32 @@ test('create task being cancellable', async () => {
442374
});
443375

444376
test('create task being cancellable throw error if missing cancellationTokenSourceId', async () => {
445-
const taskManager = new TaskManager(
446-
apiSender,
447-
statusBarRegistry,
448-
commandRegistry,
449-
configurationRegistry,
450-
experimentalConfigurationManager,
451-
);
452-
453377
expect(() => taskManager.createTask({ cancellable: true })).toThrow(
454378
'cancellable task requires a cancellationTokenSourceId',
455379
);
456380
});
457381

458382
test('create task having cancellationTokenSourceId without being cancellable throw error', async () => {
459-
const taskManager = new TaskManager(
460-
apiSender,
461-
statusBarRegistry,
462-
commandRegistry,
463-
configurationRegistry,
464-
experimentalConfigurationManager,
465-
);
466-
467383
expect(() => taskManager.createTask({ cancellationTokenSourceId: 4 })).toThrow(
468384
'cancellationTokenSourceId is only allowed for cancellable tasks',
469385
);
470386
});
471387

472388
describe('execute', () => {
473389
test('execute should throw an error if the task does not exist', async () => {
474-
const taskManager = new TaskManager(
475-
apiSender,
476-
statusBarRegistry,
477-
commandRegistry,
478-
configurationRegistry,
479-
experimentalConfigurationManager,
480-
);
481-
482390
expect(() => {
483391
taskManager.execute('fake-id');
484392
}).toThrowError(`task with id fake-id does not exist.`);
485393
});
486394

487395
test('execute should throw an error if the task has no action', async () => {
488-
const taskManager = new TaskManager(
489-
apiSender,
490-
statusBarRegistry,
491-
commandRegistry,
492-
configurationRegistry,
493-
experimentalConfigurationManager,
494-
);
495-
496396
const task = taskManager.createTask({ title: 'Task 1' });
497397
expect(() => {
498398
taskManager.execute(task.id);
499399
}).toThrowError(`task with id ${task.id} (${task.name}) does not have an action.`);
500400
});
501401

502402
test('execute should execute the task execute function', async () => {
503-
const taskManager = new TaskManager(
504-
apiSender,
505-
statusBarRegistry,
506-
commandRegistry,
507-
configurationRegistry,
508-
experimentalConfigurationManager,
509-
);
510-
511403
const task = taskManager.createTask({ title: 'Task 1' });
512404
task.action = {
513405
name: 'Dummy action name',
@@ -520,14 +412,6 @@ describe('execute', () => {
520412
});
521413

522414
test('updating a task should notify apiSender', () => {
523-
const taskManager = new TaskManager(
524-
apiSender,
525-
statusBarRegistry,
526-
commandRegistry,
527-
configurationRegistry,
528-
experimentalConfigurationManager,
529-
);
530-
531415
const task = taskManager.createTask({ title: 'Task 1' });
532416
expect(apiSenderSendMock).toHaveBeenCalledWith('task-created', expect.anything());
533417

@@ -544,15 +428,6 @@ test('updating a task should notify apiSender', () => {
544428
});
545429

546430
test('Ensure init setup command and statusbar registry', async () => {
547-
const taskManager = new TaskManager(
548-
apiSender,
549-
statusBarRegistry,
550-
commandRegistry,
551-
configurationRegistry,
552-
experimentalConfigurationManager,
553-
);
554-
taskManager.init();
555-
556431
expect(mocks.registerCommandMock).toHaveBeenCalledOnce();
557432
expect(mocks.setEntryMock).toHaveBeenCalledOnce();
558433
});
@@ -583,13 +458,6 @@ test('Ensure statusbar registry', async () => {
583458
});
584459

585460
test('task dispose should send `task-removed` message', async () => {
586-
const taskManager = new TaskManager(
587-
apiSender,
588-
statusBarRegistry,
589-
commandRegistry,
590-
configurationRegistry,
591-
experimentalConfigurationManager,
592-
);
593461
const task = taskManager.createNotificationTask({
594462
title: 'title',
595463
body: 'body',

0 commit comments

Comments
 (0)
0