From 15b0357db4876a847b4320058a020c8a1991de7d Mon Sep 17 00:00:00 2001 From: nevio18324 <141240169+nevio18324@users.noreply.github.com> Date: Thu, 31 Oct 2024 10:48:49 +0100 Subject: [PATCH] create tests for dialog-service (#1112) --- .../src/app/services/dialog.service.spec.ts | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/frontend/src/app/services/dialog.service.spec.ts b/frontend/src/app/services/dialog.service.spec.ts index a454504ed1..16b4888d16 100644 --- a/frontend/src/app/services/dialog.service.spec.ts +++ b/frontend/src/app/services/dialog.service.spec.ts @@ -1,9 +1,10 @@ import { TestBed } from '@angular/core/testing'; import { DialogService } from './dialog.service'; -import { HttpClientTestingModule } from '@angular/common/http/testing'; -import { TranslateCompiler, TranslateModule, TranslateService } from '@ngx-translate/core'; -import { TranslateTestingModule } from 'ngx-translate-testing'; +import { TranslateModule, TranslateService } from '@ngx-translate/core'; +import { MatDialogRef } from '@angular/material/dialog'; +import { ConfirmDialogComponent } from '../shared/dialog/confirm-dialog/confirm-dialog.component'; +import { TeamComponent } from '../components/team/team.component'; describe('DialogService', () => { let service: DialogService; @@ -16,4 +17,22 @@ describe('DialogService', () => { it('should be created', () => { expect(service).toBeTruthy(); }); + + it('should open dialog', () => { + const dialog = service.open(TeamComponent); + expect(dialog).toBeInstanceOf(MatDialogRef); + expect(dialog._containerInstance._config.panelClass).toEqual(service.DIALOG_CONFIG.panelClass); + expect(dialog._containerInstance._config.maxWidth).toEqual(service.DIALOG_CONFIG.maxWidth); + expect(dialog.componentInstance).toBeInstanceOf(TeamComponent); + }); + + it('should open confirm dialog', () => { + jest.spyOn(service, 'open'); + const dialog = service.openConfirmDialog('DELETE.ACTION'); + expect(service.open).toHaveBeenCalledTimes(1); + expect(dialog).toBeInstanceOf(MatDialogRef); + expect(dialog.componentInstance).toBeInstanceOf(ConfirmDialogComponent); + expect(dialog.componentInstance.data.title).toBe('DELETE.ACTION.TITLE'); + expect(dialog.componentInstance.data.text).toBe('DELETE.ACTION.TEXT'); + }); });