1 import { HttpClientTestingModule } from '@angular/common/http/testing';
2 import { ComponentFixture, TestBed } from '@angular/core/testing';
4 import { CephfsSnapshotscheduleFormComponent } from './cephfs-snapshotschedule-form.component';
9 } from '@ng-bootstrap/ng-bootstrap';
10 import { ToastrModule } from 'ngx-toastr';
11 import { SharedModule } from '~/app/shared/shared.module';
12 import { RouterTestingModule } from '@angular/router/testing';
13 import { ReactiveFormsModule } from '@angular/forms';
14 import { FormHelper, configureTestBed } from '~/testing/unit-test-helper';
15 import { CephfsSnapshotScheduleService } from '~/app/shared/api/cephfs-snapshot-schedule.service';
17 describe('CephfsSnapshotscheduleFormComponent', () => {
18 let component: CephfsSnapshotscheduleFormComponent;
19 let fixture: ComponentFixture<CephfsSnapshotscheduleFormComponent>;
20 let formHelper: FormHelper;
21 let createSpy: jasmine.Spy;
24 declarations: [CephfsSnapshotscheduleFormComponent],
25 providers: [NgbActiveModal],
28 ToastrModule.forRoot(),
30 HttpClientTestingModule,
38 fixture = TestBed.createComponent(CephfsSnapshotscheduleFormComponent);
39 component = fixture.componentInstance;
40 component.fsName = 'test_fs';
42 formHelper = new FormHelper(component.snapScheduleForm);
43 createSpy = spyOn(TestBed.inject(CephfsSnapshotScheduleService), 'create').and.stub();
44 fixture.detectChanges();
47 it('should create', () => {
48 expect(component).toBeTruthy();
51 it('should have a form open in modal', () => {
52 const nativeEl = fixture.debugElement.nativeElement;
53 expect(nativeEl.querySelector('cd-modal')).not.toBe(null);
56 it('should submit the form', () => {
73 formHelper.setMultipleValues(input);
74 component.snapScheduleForm.get('directory').setValue('/test');
77 expect(createSpy).toHaveBeenCalled();