1 import { HttpClientTestingModule } from '@angular/common/http/testing';
2 import { ReactiveFormsModule } from '@angular/forms';
3 import { RouterTestingModule } from '@angular/router/testing';
4 import { ComponentFixture, TestBed } from '@angular/core/testing';
6 import { ToastrModule } from 'ngx-toastr';
8 import { NgbActiveModal, NgbTypeaheadModule } from '@ng-bootstrap/ng-bootstrap';
10 import { SharedModule } from '~/app/shared/shared.module';
11 import { NvmeofService } from '~/app/shared/api/nvmeof.service';
13 import { NvmeofInitiatorsFormComponent } from './nvmeof-initiators-form.component';
15 describe('NvmeofInitiatorsFormComponent', () => {
16 let component: NvmeofInitiatorsFormComponent;
17 let fixture: ComponentFixture<NvmeofInitiatorsFormComponent>;
18 let nvmeofService: NvmeofService;
19 const mockTimestamp = 1720693470789;
21 beforeEach(async () => {
22 spyOn(Date, 'now').and.returnValue(mockTimestamp);
23 await TestBed.configureTestingModule({
24 declarations: [NvmeofInitiatorsFormComponent],
25 providers: [NgbActiveModal],
27 HttpClientTestingModule,
32 ToastrModule.forRoot()
34 }).compileComponents();
36 fixture = TestBed.createComponent(NvmeofInitiatorsFormComponent);
37 component = fixture.componentInstance;
39 fixture.detectChanges();
42 it('should create', () => {
43 expect(component).toBeTruthy();
46 describe('should test form', () => {
48 nvmeofService = TestBed.inject(NvmeofService);
49 spyOn(nvmeofService, 'addInitiators').and.stub();
52 it('should be creating request correctly', () => {
53 const subsystemNQN = 'nqn.2001-07.com.ceph:' + mockTimestamp;
54 component.subsystemNQN = subsystemNQN;
56 expect(nvmeofService.addInitiators).toHaveBeenCalledWith(subsystemNQN, {