]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/blob
3e60a3ba787bca4fc489b604fe721d431ec0e4c4
[ceph-ci.git] /
1 import { HttpClientTestingModule } from '@angular/common/http/testing';
2 import { ComponentFixture, TestBed } from '@angular/core/testing';
3 import { ReactiveFormsModule } from '@angular/forms';
4 import { RouterTestingModule } from '@angular/router/testing';
5
6 import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
7 import { ToastrModule } from 'ngx-toastr';
8
9 import { configureTestBed, i18nProviders } from '../../../../testing/unit-test-helper';
10 import { ComponentsModule } from '../../../shared/components/components.module';
11 import { PipesModule } from '../../../shared/pipes/pipes.module';
12 import { AuthStorageService } from '../../../shared/services/auth-storage.service';
13 import { RbdSnapshotFormModalComponent } from './rbd-snapshot-form-modal.component';
14
15 describe('RbdSnapshotFormModalComponent', () => {
16   let component: RbdSnapshotFormModalComponent;
17   let fixture: ComponentFixture<RbdSnapshotFormModalComponent>;
18
19   configureTestBed({
20     imports: [
21       ReactiveFormsModule,
22       ComponentsModule,
23       PipesModule,
24       HttpClientTestingModule,
25       ToastrModule.forRoot(),
26       RouterTestingModule
27     ],
28     declarations: [RbdSnapshotFormModalComponent],
29     providers: [NgbActiveModal, AuthStorageService, i18nProviders]
30   });
31
32   beforeEach(() => {
33     fixture = TestBed.createComponent(RbdSnapshotFormModalComponent);
34     component = fixture.componentInstance;
35   });
36
37   it('should create', () => {
38     expect(component).toBeTruthy();
39   });
40
41   it('should show "Create" text', () => {
42     fixture.detectChanges();
43
44     const header = fixture.debugElement.nativeElement.querySelector('h4');
45     expect(header.textContent).toBe('Create RBD Snapshot');
46
47     const button = fixture.debugElement.nativeElement.querySelector('cd-submit-button');
48     expect(button.textContent).toBe('Create RBD Snapshot');
49   });
50
51   it('should show "Rename" text', () => {
52     component.setEditing();
53
54     fixture.detectChanges();
55
56     const header = fixture.debugElement.nativeElement.querySelector('h4');
57     expect(header.textContent).toBe('Rename RBD Snapshot');
58
59     const button = fixture.debugElement.nativeElement.querySelector('cd-submit-button');
60     expect(button.textContent).toBe('Rename RBD Snapshot');
61   });
62 });