Skip to content

Commit fc6f1d1

Browse files
[DURACOM-383] fix compilation errors
1 parent da77ecc commit fc6f1d1

1 file changed

Lines changed: 13 additions & 12 deletions

File tree

src/app/item-page/edit-item-page/item-delete/item-delete.component.spec.ts

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,17 @@ let entityTypeService;
6969
let notificationsServiceStub;
7070
let typesSelection;
7171
let scriptDataService;
72+
let router;
73+
let scriptService;
74+
let notificationService: NotificationsServiceStub;
7275

73-
describe('ItemDeleteComponent', () => {
76+
fdescribe('ItemDeleteComponent', () => {
7477
beforeEach(waitForAsync(() => {
78+
notificationService = new NotificationsServiceStub();
79+
scriptService = jasmine.createSpyObj('scriptService', {
80+
invoke: createSuccessfulRemoteDataObject$({ processId: '123' }),
81+
});
82+
router = jasmine.createSpyObj('router', ['navigateByUrl', 'navigate']);
7583

7684
mockItem = Object.assign(new Item(), {
7785
id: 'fake-id',
@@ -199,10 +207,6 @@ describe('ItemDeleteComponent', () => {
199207
beforeEach(() => {
200208
fixture = TestBed.createComponent(ItemDeleteComponent);
201209
comp = fixture.componentInstance;
202-
// Verifica che il componente stia usando il mock corretto
203-
expect(comp.scriptDataService).toBe(scriptDataService);
204-
console.log('scriptDataService mock:', scriptDataService);
205-
console.log('comp scriptDataService:', comp.scriptDataService);
206210
fixture.detectChanges();
207211
});
208212

@@ -227,21 +231,18 @@ describe('ItemDeleteComponent', () => {
227231
console.log('Before performAction - isSpy:', jasmine.isSpy(scriptDataService.invoke));
228232
comp.performAction();
229233
setTimeout(() => {
230-
console.log('After performAction - scriptDataService.invoke:', scriptDataService.invoke);
231-
console.log('After performAction - calls:', scriptDataService.invoke.calls);
232-
console.log('After performAction - isSpy:', jasmine.isSpy(scriptDataService.invoke));
233234
expect(scriptDataService.invoke).toHaveBeenCalledWith(DSPACE_OBJECT_DELETION_SCRIPT_NAME, parameterValues, []);
234-
expect(comp.notificationsService.success).toHaveBeenCalled();
235-
expect(comp.router.navigateByUrl).toHaveBeenCalledWith(getProcessDetailRoute('123'));
235+
expect(notificationsServiceStub.success).toHaveBeenCalled();
236+
expect(router.navigateByUrl).toHaveBeenCalledWith(getProcessDetailRoute('123'));
236237
done();
237238
}, 0);
238239
});
239240
it('should show error notification and redirect to item edit page on failure', (done) => {
240241
scriptDataService.invoke.and.returnValue(createFailedRemoteDataObject$('Error', 500));
241242
comp.performAction();
242243
setTimeout(() => {
243-
expect(comp.notificationsService.error).toHaveBeenCalled();
244-
expect(comp.router.navigate).toHaveBeenCalledWith([getItemEditRoute(mockItem)]);
244+
expect(notificationService.error).toHaveBeenCalled();
245+
expect(router.navigate).toHaveBeenCalledWith([getItemEditRoute(mockItem)]);
245246
done();
246247
}, 0);
247248
});

0 commit comments

Comments
 (0)