1 import { HttpClientTestingModule } from '@angular/common/http/testing';
2 import { ComponentFixture, TestBed } from '@angular/core/testing';
3 import { FormsModule } from '@angular/forms';
4 import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
5 import { RouterTestingModule } from '@angular/router/testing';
7 import { ToastrModule } from 'ngx-toastr';
8 import { of } from 'rxjs';
10 import { configureTestBed, i18nProviders } from '../../../../testing/unit-test-helper';
11 import { OrchestratorService } from '../../../shared/api/orchestrator.service';
12 import { SharedModule } from '../../../shared/shared.module';
13 import { InventoryDevicesComponent } from './inventory-devices/inventory-devices.component';
14 import { InventoryComponent } from './inventory.component';
16 describe('InventoryComponent', () => {
17 let component: InventoryComponent;
18 let fixture: ComponentFixture<InventoryComponent>;
19 let orchService: OrchestratorService;
23 BrowserAnimationsModule,
26 HttpClientTestingModule,
28 ToastrModule.forRoot()
30 providers: [i18nProviders],
31 declarations: [InventoryComponent, InventoryDevicesComponent]
35 fixture = TestBed.createComponent(InventoryComponent);
36 component = fixture.componentInstance;
37 orchService = TestBed.get(OrchestratorService);
38 spyOn(orchService, 'status').and.returnValue(of({ available: true }));
39 spyOn(orchService, 'inventoryDeviceList').and.callThrough();
42 it('should create', () => {
43 expect(component).toBeTruthy();
46 describe('after ngOnInit', () => {
47 it('should load devices', () => {
48 fixture.detectChanges();
49 expect(orchService.inventoryDeviceList).toHaveBeenCalledWith(undefined);
52 it('should load devices for a host', () => {
53 component.hostname = 'host0';
54 fixture.detectChanges();
55 expect(orchService.inventoryDeviceList).toHaveBeenCalledWith('host0');