@@ -7,10 +7,15 @@ import { FormHelper, configureTestBed } from '~/testing/unit-test-helper';
77import { SharedModule } from '~/app/shared/shared.module' ;
88import { ToastrModule } from 'ngx-toastr' ;
99import { ReactiveFormsModule } from '@angular/forms' ;
10+ import { By } from '@angular/platform-browser' ;
11+ import { OrchestratorService } from '~/app/shared/api/orchestrator.service' ;
12+ import { of } from 'rxjs' ;
13+
1014describe ( 'CephfsVolumeFormComponent' , ( ) => {
1115 let component : CephfsVolumeFormComponent ;
1216 let fixture : ComponentFixture < CephfsVolumeFormComponent > ;
1317 let formHelper : FormHelper ;
18+ let orchService : OrchestratorService ;
1419
1520 configureTestBed ( {
1621 imports : [
@@ -27,6 +32,8 @@ describe('CephfsVolumeFormComponent', () => {
2732 fixture = TestBed . createComponent ( CephfsVolumeFormComponent ) ;
2833 component = fixture . componentInstance ;
2934 formHelper = new FormHelper ( component . form ) ;
35+ orchService = TestBed . inject ( OrchestratorService ) ;
36+ spyOn ( orchService , 'status' ) . and . returnValue ( of ( { available : true } ) ) ;
3037 fixture . detectChanges ( ) ;
3138 } ) ;
3239
@@ -50,4 +57,26 @@ describe('CephfsVolumeFormComponent', () => {
5057 formHelper . expectError ( 'name' , 'pattern' ) ;
5158 }
5259 } ) ) ;
60+
61+ it ( 'should show placement when orchestrator is available' , ( ) => {
62+ const placement = fixture . debugElement . query ( By . css ( '#placement' ) ) ;
63+ expect ( placement ) . not . toBeNull ( ) ;
64+ } ) ;
65+
66+ describe ( 'when editing' , ( ) => {
67+ beforeEach ( ( ) => {
68+ component . editing = true ;
69+ component . ngOnInit ( ) ;
70+ fixture . detectChanges ( ) ;
71+ } ) ;
72+
73+ it ( 'should not show placement while editing even if orch is available' , ( ) => {
74+ const placement = fixture . debugElement . query ( By . css ( '#placement' ) ) ;
75+ const label = fixture . debugElement . query ( By . css ( '#label' ) ) ;
76+ const hosts = fixture . debugElement . query ( By . css ( '#hosts' ) ) ;
77+ expect ( placement ) . toBeNull ( ) ;
78+ expect ( label ) . toBeNull ( ) ;
79+ expect ( hosts ) . toBeNull ( ) ;
80+ } ) ;
81+ } ) ;
5382} ) ;
0 commit comments