import { ComponentFixture , TestBed , waitForAsync } from '@angular/core/testing' ; import { HttpClientTestingModule } from '@angular/common/http/testing' ; import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap' ; import { HealthModalComponent } from './health-modal.component' ; describe ( 'HealthModalComponent' , ( ) => { let comp ; let fixture ; let mockActiveModal ; beforeEach ( waitForAsync ( ( ) => { TestBed . configureTestingModule ( { imports : [ HttpClientTestingModule ] , declarations : [ HealthModalComponent ] , providers : [ NgbActiveModal ] , } ) . overrideTemplate ( HealthModalComponent , '' ) . compileComponents ( ) ; } ) ) ; beforeEach ( ( ) => { fixture = TestBed . createComponent ( HealthModalComponent ) ; comp = fixture . componentInstance ; mockActiveModal = TestBed . inject ( NgbActiveModal ) ; } ) ; describe ( 'readableValue' , ( ) => { it ( 'should return stringify value' , ( ) => { comp . health = undefined ; const result = comp . readableValue ( { name : 'jhipster' } ) ; expect ( result ) . toEqual ( '{"name":"jhipster"}' ) ; } ) ; it ( 'should return string value' , ( ) => { comp . health = undefined ; const result = comp . readableValue ( 'jhipster' ) ; expect ( result ) . toEqual ( 'jhipster' ) ; } ) ; it ( 'should return storage space in an human readable unit (GB)' , ( ) => { comp . health = { key : 'diskSpace' , value : { status : 'UP' , } , } ; const result = comp . readableValue ( 1073741825 ) ; expect ( result ) . toEqual ( '1.00 GB' ) ; } ) ; it ( 'should return storage space in an human readable unit (MB)' , ( ) => { comp . health = { key : 'diskSpace' , value : { status : 'UP' , } , } ; const result = comp . readableValue ( 1073741824 ) ; expect ( result ) . toEqual ( '1024.00 MB' ) ; } ) ; it ( 'should return string value' , ( ) => { comp . health = { key : 'mail' , value : { status : 'UP' , } , } ; const result = comp . readableValue ( 1234 ) ; expect ( result ) . toEqual ( '1234' ) ; } ) ; } ) ; describe ( 'dismiss' , ( ) => { it ( 'should call dismiss when dismiss modal is called' , ( ) => { const spy = jest . spyOn ( mockActiveModal , 'dismiss' ) ; comp . dismiss ( ) ; expect ( spy ) . toHaveBeenCalled ( ) ; } ) ; } ) ; } ) ;