Skip to content

Commit

Permalink
create tests for dialog-service (#1112)
Browse files Browse the repository at this point in the history
  • Loading branch information
nevio18324 authored and MasterEvarior committed Nov 7, 2024
1 parent 3a458a5 commit c11a2ac
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions frontend/src/app/services/dialog.service.spec.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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');
});
});

0 comments on commit c11a2ac

Please sign in to comment.