]> git.apps.os.sepia.ceph.com Git - ceph.git/blob
53187cd0f8d8c799f18b022b756b0995e123c0fb
[ceph.git] /
1 import { ComponentFixture, TestBed, fakeAsync, tick } from '@angular/core/testing';
2 import { of } from 'rxjs';
3 import { NvmeofGatewayComponent } from './nvmeof-gateway.component';
4 import { NvmeofService } from '../../../shared/api/nvmeof.service';
5 import { HttpClientModule } from '@angular/common/http';
6 import { SharedModule } from '~/app/shared/shared.module';
7
8 const mockGateways = [
9   {
10     cli_version: '',
11     version: '1.2.5',
12     name: 'client.nvmeof.rbd.ceph-node-01.jnmnwa',
13     group: '',
14     addr: '192.168.100.101',
15     port: '5500',
16     load_balancing_group: 1,
17     spdk_version: '24.01'
18   }
19 ];
20
21 class MockNvmeOfService {
22   listGateways() {
23     return of(mockGateways);
24   }
25 }
26
27 describe('NvmeofGatewayComponent', () => {
28   let component: NvmeofGatewayComponent;
29   let fixture: ComponentFixture<NvmeofGatewayComponent>;
30
31   beforeEach(fakeAsync(() => {
32     TestBed.configureTestingModule({
33       declarations: [NvmeofGatewayComponent],
34       imports: [HttpClientModule, SharedModule],
35       providers: [{ provide: NvmeofService, useClass: MockNvmeOfService }]
36     }).compileComponents();
37   }));
38
39   beforeEach(() => {
40     fixture = TestBed.createComponent(NvmeofGatewayComponent);
41     component = fixture.componentInstance;
42   });
43
44   it('should create', () => {
45     expect(component).toBeTruthy();
46   });
47
48   it('should retrieve gateways', fakeAsync(() => {
49     component.getGateways();
50     tick();
51     expect(component.gateways).toEqual(mockGateways);
52   }));
53 });