-
Notifications
You must be signed in to change notification settings - Fork 0
/
jest.setup.ts
50 lines (46 loc) · 1.54 KB
/
jest.setup.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import 'jest-preset-angular/setup-jest';
import fetchMock from 'jest-fetch-mock';
import {TestBed} from '@angular/core/testing';
import {TranslateLoader, TranslateModule} from '@ngx-translate/core';
import {HttpClient, provideHttpClient, withInterceptorsFromDi} from '@angular/common/http';
import {SharedModule} from "@shared/shared.module";
import {TranslateHttpLoader} from "@ngx-translate/http-loader";
import {ThemesService} from "@services/themes.service";
import {DataService} from "@services/data.service";
import {ToastService} from "@services/toast.service";
import {MailService} from "@services/mail.service";
import {AppRoutingModule} from "@app/app-routing.module";
import {PhotoService} from "@services/photo.service";
import {AngularFireStorageModule} from "@angular/fire/compat/storage";
fetchMock.enableMocks();
export function HttpLoaderFactory(http: HttpClient) {
return new TranslateHttpLoader(http, './assets/locales/', '.json');
}
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [
AppRoutingModule,
TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useFactory: HttpLoaderFactory,
deps: [HttpClient],
},
}),
SharedModule,
AngularFireStorageModule
],
providers: [
provideHttpClient(withInterceptorsFromDi()),
ThemesService,
DataService,
ToastService,
MailService,
PhotoService
]
}).compileComponents();
});
afterEach((): void => {
jest.restoreAllMocks();
jest.clearAllMocks();
})