1 import { TestBed } from '@angular/core/testing';
2 import { PackagesStore } from './packages.store';
3 import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
4 import { PackagesApiService } from './packages-api.service';
5 import { of } from 'rxjs';
6 import { BluePrintPage } from './model/BluePrint.model';
7 import { getBluePrintPageMock } from './blueprint.page.mock';
9 describe('PackagesStore', () => {
10 let store: PackagesStore;
12 const MOCK_BLUEPRINTS_PAGE: BluePrintPage = getBluePrintPageMock();
14 let httpMock: HttpTestingController;
17 TestBed.configureTestingModule({
19 HttpClientTestingModule
26 httpMock = TestBed.get(HttpTestingController);
30 it('should correctly get page of packages', () => {
31 const packagesServiceSpy = jasmine.createSpyObj('PackagesListService', ['getPagedPackages']);
33 // set the value to return when the `getPagedPackages` spy is called.
34 packagesServiceSpy.getPagedPackages.and.returnValue(of([MOCK_BLUEPRINTS_PAGE]));
35 store = new PackagesStore(packagesServiceSpy);
37 store.getPagedPackages(0, 2);
38 store.state$.subscribe(page => {
39 expect(store.state).toEqual(MOCK_BLUEPRINTS_PAGE);