Skip to content

Commit

Permalink
configure testbead to prevent teardown
Browse files Browse the repository at this point in the history
  • Loading branch information
StephGit committed Aug 21, 2024
1 parent b307bea commit 6b3310d
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ describe('DeploymentComponent (create deployment)', () => {
let deploymentService: DeploymentService;
beforeEach(() => {
TestBed.configureTestingModule({
teardown: { destroyAfterEach: false },
imports: [FormsModule, RouterTestingModule, DeploymentComponent, DummyComponent],
providers: [
ResourceService,
Expand Down
58 changes: 46 additions & 12 deletions AMW_angular/io/src/app/deployments/deployments.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,26 @@ describe('DeploymentsComponent (with query params)', () => {
let deploymentService: DeploymentService;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [FormsModule,
teardown: { destroyAfterEach: false },
imports: [
FormsModule,
RouterTestingModule.withRoutes([]),
DeploymentsComponent,
DeploymentsListComponent,
PaginationComponent,
DeploymentsEditModalComponent],
providers: [DeploymentService, ResourceService, { provide: ActivatedRoute, useValue: mockRoute }, provideHttpClient(withInterceptorsFromDi()), provideHttpClientTesting()]
}).compileComponents();
DeploymentsEditModalComponent,
],
providers: [
DeploymentService,
ResourceService,
{
provide: ActivatedRoute,
useValue: mockRoute,
},
provideHttpClient(withInterceptorsFromDi()),
provideHttpClientTesting(),
],
}).compileComponents();

fixture = TestBed.createComponent(DeploymentsComponent);
component = fixture.componentInstance;
Expand Down Expand Up @@ -176,14 +188,25 @@ describe('DeploymentsComponent (with illegal query params)', () => {
let deploymentService: DeploymentService;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [FormsModule,
imports: [
FormsModule,
RouterTestingModule.withRoutes([]),
DeploymentsComponent,
DeploymentsListComponent,
PaginationComponent,
DeploymentsEditModalComponent],
providers: [DeploymentService, ResourceService, { provide: ActivatedRoute, useValue: mockRoute }, provideHttpClient(withInterceptorsFromDi()), provideHttpClientTesting()]
}).compileComponents();
DeploymentsEditModalComponent,
],
providers: [
DeploymentService,
ResourceService,
{
provide: ActivatedRoute,
useValue: mockRoute,
},
provideHttpClient(withInterceptorsFromDi()),
provideHttpClientTesting(),
],
}).compileComponents();

fixture = TestBed.createComponent(DeploymentsComponent);
component = fixture.componentInstance;
Expand Down Expand Up @@ -226,14 +249,25 @@ describe('DeploymentsComponent (without query params)', () => {
let resourceService: ResourceService;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [FormsModule,
imports: [
FormsModule,
RouterTestingModule.withRoutes([]),
DeploymentsComponent,
DeploymentsListComponent,
PaginationComponent,
DeploymentsEditModalComponent],
providers: [DeploymentService, ResourceService, { provide: ActivatedRoute, useValue: mockRoute }, provideHttpClient(withInterceptorsFromDi()), provideHttpClientTesting()]
}).compileComponents();
DeploymentsEditModalComponent,
],
providers: [
DeploymentService,
ResourceService,
{
provide: ActivatedRoute,
useValue: mockRoute,
},
provideHttpClient(withInterceptorsFromDi()),
provideHttpClientTesting(),
],
}).compileComponents();

fixture = TestBed.createComponent(DeploymentsComponent);
component = fixture.componentInstance;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,24 +34,27 @@ describe('PermissionComponent without any params (default: type Role)', () => {

beforeEach(() => {
TestBed.configureTestingModule({
schemas: [CUSTOM_ELEMENTS_SCHEMA],
imports: [CommonModule,
teardown: { destroyAfterEach: false },
schemas: [CUSTOM_ELEMENTS_SCHEMA],
imports: [
CommonModule,
FormsModule,
RouterTestingModule.withRoutes([]),
NgbModule,
PermissionComponent,
RestrictionEditComponent,
RestrictionAddComponent,
RestrictionListComponent],
providers: [
RestrictionListComponent,
],
providers: [
EnvironmentService,
PermissionService,
ResourceService,
{ provide: ActivatedRoute, useValue: mockRoute },
provideHttpClient(withInterceptorsFromDi()),
provideHttpClientTesting(),
]
});
],
});

fixture = TestBed.createComponent(PermissionComponent);
component = fixture.componentInstance;
Expand Down Expand Up @@ -406,24 +409,26 @@ describe('PermissionComponent with param restrictionType (type User)', () => {

beforeEach(() => {
TestBed.configureTestingModule({
schemas: [CUSTOM_ELEMENTS_SCHEMA],
imports: [CommonModule,
schemas: [CUSTOM_ELEMENTS_SCHEMA],
imports: [
CommonModule,
FormsModule,
RouterTestingModule.withRoutes([]),
NgbModule,
PermissionComponent,
RestrictionEditComponent,
RestrictionAddComponent,
RestrictionListComponent],
providers: [
RestrictionListComponent,
],
providers: [
EnvironmentService,
PermissionService,
ResourceService,
{ provide: ActivatedRoute, useValue: mockRoute },
provideHttpClient(withInterceptorsFromDi()),
provideHttpClientTesting(),
]
});
],
});
fixture = TestBed.createComponent(PermissionComponent);
component = fixture.componentInstance;
fixture.detectChanges();
Expand Down Expand Up @@ -504,24 +509,26 @@ describe('PermissionComponent with param actingUser (delegation mode)', () => {

beforeEach(() => {
TestBed.configureTestingModule({
schemas: [CUSTOM_ELEMENTS_SCHEMA],
imports: [CommonModule,
schemas: [CUSTOM_ELEMENTS_SCHEMA],
imports: [
CommonModule,
FormsModule,
RouterTestingModule.withRoutes([]),
NgbModule,
PermissionComponent,
RestrictionEditComponent,
RestrictionAddComponent,
RestrictionListComponent],
providers: [
RestrictionListComponent,
],
providers: [
EnvironmentService,
PermissionService,
ResourceService,
{ provide: ActivatedRoute, useValue: mockRoute },
provideHttpClient(withInterceptorsFromDi()),
provideHttpClientTesting(),
]
});
],
});
fixture = TestBed.createComponent(PermissionComponent);
component = fixture.componentInstance;
fixture.detectChanges();
Expand Down
2 changes: 1 addition & 1 deletion AMW_angular/io/src/test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file is required by karma.conf.js and loads recursively all the .spec and framework files
// This file loads recursively all the .spec and framework files

import 'zone.js/testing';
import { getTestBed } from '@angular/core/testing';
Expand Down

0 comments on commit 6b3310d

Please sign in to comment.