aboutsummaryrefslogtreecommitdiffstats
path: root/cds-ui/designer-client/src/app/modules/feature-modules/packages/packages.store.spec.ts
blob: 379aaddf2670befed8d987206aeea4e6f443683d (plain)
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
53
54
55
56
57
58
59
60
import { TestBed } from '@angular/core/testing';
import { PackagesStore } from './packages.store';
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
import { PackagesApiService } from './packages-api.service';
import { of } from 'rxjs';
import { BluePrintPage } from './model/BluePrint.model';
import { getBluePrintPageMock } from './blueprint.page.mock';
import { PackagesDashboardState } from './model/packages-dashboard.state';

describe('PackagesStore', () => {
    //    store: PackagesStore;

    const MOCK_BLUEPRINTS_PAGE: BluePrintPage = getBluePrintPageMock();


    let httpMock: HttpTestingController;

    beforeEach(() => {
        TestBed.configureTestingModule({
            imports: [
                HttpClientTestingModule
            ],
            providers: [
                PackagesStore,
                PackagesApiService
            ]
        });
        httpMock = TestBed.get(HttpTestingController);

    });

    it('should correctly get page of packages', () => {
        const packagesServiceSpy = jasmine.createSpyObj('PackagesListService', ['getPagedPackages']);

        // set the value to return when the ` getPagedPackages` spy is called.
        packagesServiceSpy.getPagedPackages.and.returnValue(of([MOCK_BLUEPRINTS_PAGE]));
        // store = new PackagesStore(packagesServiceSpy);

        // Todo check the Abbas's code
        /*store.getPagedPackages(0, 2);
        store.state$.subscribe(page => {
            expect(store.state).toEqual(MOCK_BLUEPRINTS_PAGE);
        });*/

    });

    it('should correctly get all packages', () => {
        const packagesServiceSpy = jasmine.createSpyObj('PackagesListService', ['getPagedPackages']);

        // set the value to return when the `getPagedPackages` spy is called.
        packagesServiceSpy.getPagedPackages.and.returnValue(of([MOCK_BLUEPRINTS_PAGE]));
        // store = new PackagesStore(packagesServiceSpy);
        // store.getAll();
        // store.state$.subscribe(page => {
        //     expect(store.state.page).toEqual(MOCK_BLUEPRINTS_PAGE);
        // });

    });
});