-
Notifications
You must be signed in to change notification settings - Fork 6
/
app.component.spec.ts
44 lines (38 loc) · 1.46 KB
/
app.component.spec.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
import { NO_ERRORS_SCHEMA } from '@angular/core';
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { getStoreServiceMock, provideStoreServiceMock, StoreServiceMock } from '@ngxp/store-service/testing';
import { AppComponent } from './app.component';
import { BookStoreService } from './shared/books/book-store.service';
describe('AppComponent', () => {
let fixture: ComponentFixture<AppComponent>;
let component: AppComponent;
let bookStoreService: StoreServiceMock<BookStoreService>;
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [
AppComponent,
],
providers: [
provideStoreServiceMock(BookStoreService)
],
schemas: [
NO_ERRORS_SCHEMA
]
}).compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(AppComponent);
bookStoreService = getStoreServiceMock(BookStoreService);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create the app', waitForAsync(() => {
const app = fixture.debugElement.componentInstance;
expect(app).toBeTruthy();
}));
it('loads books on init', () => {
const loadBooksSpy = jest.spyOn(bookStoreService, 'loadBooks');
component.ngOnInit();
expect(loadBooksSpy).toHaveBeenCalled();
});
});