-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathapp.component.spec.ts
More file actions
52 lines (42 loc) · 1.74 KB
/
Copy pathapp.component.spec.ts
File metadata and controls
52 lines (42 loc) · 1.74 KB
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
51
52
import { provideStore, Store } from '@ngxs/store';
import { MockComponents } from 'ng-mocks';
import { provideHttpClient } from '@angular/common/http';
import { provideHttpClientTesting } from '@angular/common/http/testing';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { GetCurrentUser, UserState } from '@core/store/user';
import { UserEmailsState } from '@core/store/user-emails';
import { FullScreenLoaderComponent, ToastComponent } from './shared/components';
import { TranslateServiceMock } from './shared/mocks';
import { AppComponent } from './app.component';
describe('AppComponent', () => {
let component: AppComponent;
let fixture: ComponentFixture<AppComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [AppComponent, ...MockComponents(ToastComponent, FullScreenLoaderComponent)],
providers: [
provideStore([UserState, UserEmailsState]),
provideHttpClient(),
provideHttpClientTesting(),
TranslateServiceMock,
],
}).compileComponents();
fixture = TestBed.createComponent(AppComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
it('should dispatch GetCurrentUser action on initialization', () => {
const store = TestBed.inject(Store);
const dispatchSpy = jest.spyOn(store, 'dispatch');
store.dispatch(GetCurrentUser);
expect(dispatchSpy).toHaveBeenCalledWith(GetCurrentUser);
});
it('should render router outlet', () => {
const routerOutlet = fixture.debugElement.query(By.css('router-outlet'));
expect(routerOutlet).toBeTruthy();
});
});