Skip to content

Commit

Permalink
[Angular] Improve coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
qmonmert committed Feb 12, 2024
1 parent 290feee commit 94b19a4
Showing 1 changed file with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
const tsKeyId = this.generateTestEntityId(primaryKey.type);
const testEntity = this.generateTestEntityPrimaryKey(primaryKey, 0);
_%>
import { TestBed } from '@angular/core/testing';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { provideRouter, withComponentInputBinding } from '@angular/router';
import { RouterTestingHarness, RouterTestingModule } from '@angular/router/testing';
import { of } from 'rxjs';
Expand All @@ -32,6 +32,8 @@ import { DataUtils } from 'app/core/util/data-util.service';
import { <%= entityAngularName %>DetailComponent } from './<%= entityFileName %>-detail.component';

describe('<%= entityAngularName %> Management Detail Component', () => {
let comp: <%= entityAngularName %>DetailComponent;
let fixture: ComponentFixture<<%= entityAngularName %>DetailComponent>;
<%_ if (anyFieldIsBlobDerived) { _%>
let dataUtils: DataUtils;
<%_ } _%>
Expand Down Expand Up @@ -60,6 +62,11 @@ describe('<%= entityAngularName %> Management Detail Component', () => {
<%_ } _%>
});

beforeEach(() => {
fixture = TestBed.createComponent(<%= entityAngularName %>DetailComponent);
comp = fixture.componentInstance;
});

describe('OnInit', () => {
it('Should load <%= entityInstance %> on init', async () => {
const harness = await RouterTestingHarness.create();
Expand All @@ -70,6 +77,14 @@ describe('<%= entityAngularName %> Management Detail Component', () => {
});
});

describe('PreviousState', () => {
it('Should navigate to previous state', () => {
jest.spyOn(window.history, 'back');
comp.previousState();
expect(window.history.back).toHaveBeenCalled();
});
});

<%_ if (anyFieldIsBlobDerived) { _%>
describe('byteSize', () => {
it('Should call byteSize from DataUtils', () => {
Expand Down

0 comments on commit 94b19a4

Please sign in to comment.