import { Observable , Subject } from 'rxjs' ; import { ILicense } from '../../../../licensing/common/types' ; import { MlClientLicense } from './ml_client_license' ; describe ( 'MlClientLicense' , ( ) => { test ( 'should miss the license update when initialized without postInitFunction' , ( ) => { const mlLicense = new MlClientLicense ( ) ; expect ( mlLicense . isFullLicense ( ) ) . toBe ( false ) ; const license$ = new Subject ( ) ; mlLicense . setup ( license$ as Observable < ILicense > ) ; expect ( mlLicense . isFullLicense ( ) ) . toBe ( false ) ; license$ . next ( { check : ( ) => ( { state : 'valid' } ) , getFeature : ( ) => ( { isEnabled : true } ) , status : 'valid' , } ) ; expect ( mlLicense . isFullLicense ( ) ) . toBe ( true ) ; } ) ; test ( 'should not miss the license update when initialized with postInitFunction' , ( done ) => { const mlLicense = new MlClientLicense ( ) ; expect ( mlLicense . isFullLicense ( ) ) . toBe ( false ) ; const license$ = new Subject ( ) ; mlLicense . setup ( license$ as Observable < ILicense > , [ ( license ) => { expect ( license . isFullLicense ( ) ) . toBe ( true ) ; done ( ) ; } , ] ) ; license$ . next ( { check : ( ) => ( { state : 'valid' } ) , getFeature : ( ) => ( { isEnabled : true } ) , status : 'valid' , } ) ; } ) ; } ) ;