Skip to content

Commit 4328a45

Browse files
hbaltypYassine
authored andcommitted
feat(frontend): migrating testing modules
1 parent a40fe84 commit 4328a45

File tree

78 files changed

+483
-387
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+483
-387
lines changed

packages/frontend/jest.config.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
module.exports = {
22
preset: "jest-preset-angular",
33
setupFilesAfterEnv: ["<rootDir>/setup-jest.ts"],
4-
globalSetup: "jest-preset-angular/global-setup",
54
moduleNameMapper: {
65
"^src/(.*)$": "<rootDir>/src/$1",
76
"^app/(.*)$": "<rootDir>/src/app/$1",

packages/frontend/src/app/app.component.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
import { MATOMO_INJECTORS } from "./shared/constants/MATOMO_INJECTORS.const";
22
import { ReactiveFormsModule } from "@angular/forms";
3-
import { HttpClientTestingModule } from "@angular/common/http/testing";
43
import { CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA } from "@angular/core";
54
import { TestBed, waitForAsync } from "@angular/core/testing";
6-
import { RouterTestingModule } from "@angular/router/testing";
75

86
import { AppComponent } from "./app.component";
97
import { StoreModule } from "@ngrx/store";
108
import { _usagerReducer } from "./shared";
9+
import { RouterModule } from "@angular/router";
10+
import { provideHttpClient } from "@angular/common/http";
1111

1212
describe("AppComponent", () => {
1313
beforeEach(waitForAsync(() => {
1414
TestBed.configureTestingModule({
1515
declarations: [AppComponent],
1616
imports: [
17-
HttpClientTestingModule,
18-
RouterTestingModule,
17+
RouterModule.forRoot([]),
1918
ReactiveFormsModule,
2019
...MATOMO_INJECTORS,
2120
StoreModule.forRoot({ app: _usagerReducer }),
2221
],
22+
providers: [provideHttpClient()],
2323
schemas: [CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA],
2424
}).compileComponents();
2525
}));

packages/frontend/src/app/modules/admin-portail-usagers/components/manage-structure-information/manage-structure-information.component.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import { ComponentFixture, TestBed } from "@angular/core/testing";
2-
32
import { ManageStructureInformationComponent } from "./manage-structure-information.component";
43
import { CUSTOM_ELEMENTS_SCHEMA } from "@angular/core";
5-
import { HttpClientTestingModule } from "@angular/common/http/testing";
6-
import { RouterTestingModule } from "@angular/router/testing";
74
import { NgbModule } from "@ng-bootstrap/ng-bootstrap";
5+
import { RouterModule } from "@angular/router";
6+
import { provideHttpClient } from "@angular/common/http";
87

98
describe("ManageStructureInformationComponent", () => {
109
let component: ManageStructureInformationComponent;
@@ -14,7 +13,8 @@ describe("ManageStructureInformationComponent", () => {
1413
await TestBed.configureTestingModule({
1514
declarations: [ManageStructureInformationComponent],
1615
schemas: [CUSTOM_ELEMENTS_SCHEMA],
17-
imports: [NgbModule, HttpClientTestingModule, RouterTestingModule],
16+
imports: [NgbModule, RouterModule.forRoot([])],
17+
providers: [provideHttpClient()],
1818
}).compileComponents();
1919

2020
fixture = TestBed.createComponent(ManageStructureInformationComponent);

packages/frontend/src/app/modules/admin-portail-usagers/components/portail-usagers-params/portail-usagers-params.component.spec.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
import { ComponentFixture, TestBed } from "@angular/core/testing";
2-
32
import { PortailUsagersParamsComponent } from "./portail-usagers-params.component";
43
import { APP_BASE_HREF } from "@angular/common";
5-
import { HttpClientTestingModule } from "@angular/common/http/testing";
64
import { CUSTOM_ELEMENTS_SCHEMA } from "@angular/core";
75
import { ReactiveFormsModule, FormsModule } from "@angular/forms";
8-
import { RouterTestingModule } from "@angular/router/testing";
96
import { NgbModule } from "@ng-bootstrap/ng-bootstrap";
107
import {
118
MockAuthService,
129
USER_STRUCTURE_MOCK,
1310
} from "../../../../../_common/mocks";
1411
import { AuthService } from "../../../shared/services";
12+
import { RouterModule } from "@angular/router";
13+
import { provideHttpClient } from "@angular/common/http";
1514

1615
describe("PortailUsagersParamsComponent", () => {
1716
let component: PortailUsagersParamsComponent;
@@ -23,10 +22,10 @@ describe("PortailUsagersParamsComponent", () => {
2322
NgbModule,
2423
ReactiveFormsModule,
2524
FormsModule,
26-
HttpClientTestingModule,
27-
RouterTestingModule,
25+
RouterModule.forRoot([]),
2826
],
2927
providers: [
28+
provideHttpClient(),
3029
{ provide: APP_BASE_HREF, useValue: "/" },
3130
{ provide: AuthService, useClass: MockAuthService },
3231
],

packages/frontend/src/app/modules/general/components/contact-support/contact-support.component.spec.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import { APP_BASE_HREF } from "@angular/common";
2-
import { HttpClientTestingModule } from "@angular/common/http/testing";
32
import { CUSTOM_ELEMENTS_SCHEMA } from "@angular/core";
43
import { ComponentFixture, TestBed } from "@angular/core/testing";
54
import { ReactiveFormsModule, FormsModule } from "@angular/forms";
6-
import { RouterTestingModule } from "@angular/router/testing";
75
import { NgbModule } from "@ng-bootstrap/ng-bootstrap";
86

97
import { ContactSupportComponent } from "./contact-support.component";
108
import { StoreModule } from "@ngrx/store";
119
import { _usagerReducer } from "../../../../shared";
1210
import { NoopAnimationsModule } from "@angular/platform-browser/animations";
11+
import { RouterModule } from "@angular/router";
12+
import { provideHttpClient } from "@angular/common/http";
1313

1414
describe("ContactSupportComponent", () => {
1515
let component: ContactSupportComponent;
@@ -22,11 +22,13 @@ describe("ContactSupportComponent", () => {
2222
ReactiveFormsModule,
2323
FormsModule,
2424
StoreModule.forRoot({ app: _usagerReducer }),
25-
HttpClientTestingModule,
2625
NoopAnimationsModule,
27-
RouterTestingModule,
26+
RouterModule.forRoot([]),
27+
],
28+
providers: [
29+
provideHttpClient(),
30+
{ provide: APP_BASE_HREF, useValue: "/" },
2831
],
29-
providers: [{ provide: APP_BASE_HREF, useValue: "/" }],
3032
schemas: [CUSTOM_ELEMENTS_SCHEMA],
3133
}).compileComponents();
3234
});

packages/frontend/src/app/modules/general/components/errors/not-found/not-found.component.spec.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { ComponentFixture, TestBed, waitForAsync } from "@angular/core/testing";
22

33
import { APP_BASE_HREF } from "@angular/common";
4-
import { HttpClientTestingModule } from "@angular/common/http/testing";
54
import { CUSTOM_ELEMENTS_SCHEMA } from "@angular/core";
65
import { FormsModule, ReactiveFormsModule } from "@angular/forms";
76
import { NgbModule } from "@ng-bootstrap/ng-bootstrap";
87
import { NotFoundComponent } from "./not-found.component";
9-
import { RouterTestingModule } from "@angular/router/testing";
8+
import { RouterModule } from "@angular/router";
9+
import { provideHttpClient } from "@angular/common/http";
1010

1111
describe("NotFoundComponent", () => {
1212
let component: NotFoundComponent;
@@ -19,11 +19,12 @@ describe("NotFoundComponent", () => {
1919
NgbModule,
2020
ReactiveFormsModule,
2121
FormsModule,
22-
23-
HttpClientTestingModule,
24-
RouterTestingModule,
22+
RouterModule.forRoot([]),
23+
],
24+
providers: [
25+
provideHttpClient(),
26+
{ provide: APP_BASE_HREF, useValue: "/" },
2527
],
26-
providers: [{ provide: APP_BASE_HREF, useValue: "/" }],
2728
schemas: [CUSTOM_ELEMENTS_SCHEMA],
2829
}).compileComponents();
2930
}));

packages/frontend/src/app/modules/general/components/faq/faq.component.spec.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,13 @@ import { ComponentFixture, TestBed, waitForAsync } from "@angular/core/testing";
33

44
import { APP_BASE_HREF } from "@angular/common";
55

6-
import { HttpClientTestingModule } from "@angular/common/http/testing";
76
import { CUSTOM_ELEMENTS_SCHEMA } from "@angular/core";
87
import { FormsModule, ReactiveFormsModule } from "@angular/forms";
98

109
import { NgbModule } from "@ng-bootstrap/ng-bootstrap";
1110
import { FaqComponent } from "./faq.component";
12-
13-
import { RouterTestingModule } from "@angular/router/testing";
11+
import { RouterModule } from "@angular/router";
12+
import { provideHttpClient } from "@angular/common/http";
1413

1514
describe("FaqComponent", () => {
1615
let component: FaqComponent;
@@ -22,11 +21,13 @@ describe("FaqComponent", () => {
2221
NgbModule,
2322
ReactiveFormsModule,
2423
FormsModule,
25-
HttpClientTestingModule,
26-
RouterTestingModule,
24+
RouterModule.forRoot([]),
2725
...MATOMO_INJECTORS,
2826
],
29-
providers: [{ provide: APP_BASE_HREF, useValue: "/" }],
27+
providers: [
28+
provideHttpClient(),
29+
{ provide: APP_BASE_HREF, useValue: "/" },
30+
],
3031
schemas: [CUSTOM_ELEMENTS_SCHEMA],
3132
}).compileComponents();
3233
}));

packages/frontend/src/app/modules/general/components/home/home.component.spec.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,11 @@ import { ComponentFixture, TestBed, waitForAsync } from "@angular/core/testing";
33
import { HomeComponent } from "./home.component";
44
import { CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA } from "@angular/core";
55
import { CommonModule, APP_BASE_HREF } from "@angular/common";
6-
76
import { SharedModule } from "../../../../modules/shared/shared.module";
8-
9-
import { HttpClientTestingModule } from "@angular/common/http/testing";
10-
import { RouterTestingModule } from "@angular/router/testing";
117
import { _usagerReducer, MATOMO_INJECTORS } from "../../../../shared";
128
import { StoreModule } from "@ngrx/store";
9+
import { RouterModule } from "@angular/router";
10+
import { provideHttpClient } from "@angular/common/http";
1311

1412
describe("HomeComponent", () => {
1513
let component: HomeComponent;
@@ -21,12 +19,14 @@ describe("HomeComponent", () => {
2119
imports: [
2220
CommonModule,
2321
SharedModule,
24-
RouterTestingModule,
25-
HttpClientTestingModule,
22+
RouterModule.forRoot([]),
2623
...MATOMO_INJECTORS,
2724
StoreModule.forRoot({ app: _usagerReducer }),
2825
],
29-
providers: [{ provide: APP_BASE_HREF, useValue: "/" }],
26+
providers: [
27+
provideHttpClient(),
28+
{ provide: APP_BASE_HREF, useValue: "/" },
29+
],
3030
schemas: [CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA],
3131
}).compileComponents();
3232
}));

packages/frontend/src/app/modules/general/components/login/login.component.spec.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
import { ComponentFixture, TestBed, waitForAsync } from "@angular/core/testing";
22

33
import { APP_BASE_HREF } from "@angular/common";
4-
import { HttpClientTestingModule } from "@angular/common/http/testing";
54
import { CUSTOM_ELEMENTS_SCHEMA } from "@angular/core";
65
import { FormsModule, ReactiveFormsModule } from "@angular/forms";
76

87
import { NgbModule } from "@ng-bootstrap/ng-bootstrap";
98
import { LoginComponent } from "./login.component";
109

11-
import { RouterTestingModule } from "@angular/router/testing";
1210
import { _usagerReducer, MATOMO_INJECTORS } from "../../../../shared";
1311
import { StoreModule } from "@ngrx/store";
12+
import { RouterModule } from "@angular/router";
13+
import { provideHttpClient } from "@angular/common/http";
1414

1515
describe("LoginComponent", () => {
1616
let component: LoginComponent;
@@ -23,12 +23,14 @@ describe("LoginComponent", () => {
2323
NgbModule,
2424
ReactiveFormsModule,
2525
FormsModule,
26-
HttpClientTestingModule,
2726
...MATOMO_INJECTORS,
28-
RouterTestingModule,
27+
RouterModule.forRoot([]),
2928
StoreModule.forRoot({ app: _usagerReducer }),
3029
],
31-
providers: [{ provide: APP_BASE_HREF, useValue: "/" }],
30+
providers: [
31+
provideHttpClient(),
32+
{ provide: APP_BASE_HREF, useValue: "/" },
33+
],
3234
schemas: [CUSTOM_ELEMENTS_SCHEMA],
3335
}).compileComponents();
3436
}));

packages/frontend/src/app/modules/general/components/navbar/navbar.component.spec.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
import { CommonModule, APP_BASE_HREF } from "@angular/common";
2-
3-
import { HttpClientTestingModule } from "@angular/common/http/testing";
42
import { CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA } from "@angular/core";
53
import { ComponentFixture, TestBed, waitForAsync } from "@angular/core/testing";
64

7-
import { RouterTestingModule } from "@angular/router/testing";
85
import { _usagerReducer, MATOMO_INJECTORS } from "../../../../shared";
96

107
import { SharedModule } from "../../../shared/shared.module";
118

129
import { NavbarComponent } from "./navbar.component";
1310
import { StoreModule } from "@ngrx/store";
11+
import { RouterModule } from "@angular/router";
12+
import { provideHttpClient } from "@angular/common/http";
1413

1514
describe("NavbarComponent", () => {
1615
let component: NavbarComponent;
@@ -22,12 +21,14 @@ describe("NavbarComponent", () => {
2221
imports: [
2322
CommonModule,
2423
SharedModule,
25-
RouterTestingModule,
24+
RouterModule.forRoot([]),
2625
MATOMO_INJECTORS,
27-
HttpClientTestingModule,
2826
StoreModule.forRoot({ app: _usagerReducer }),
2927
],
30-
providers: [{ provide: APP_BASE_HREF, useValue: "/" }],
28+
providers: [
29+
provideHttpClient(),
30+
{ provide: APP_BASE_HREF, useValue: "/" },
31+
],
3132
schemas: [CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA],
3233
}).compileComponents();
3334
}));

0 commit comments

Comments
 (0)