import { of } from 'rxjs' ; import { licenseMock } from '../../../licensing/common/licensing.mock' ; import type { LicenseType } from '../../../licensing/common/types' ; import { LICENSE_TYPE } from '../../../licensing/common/types' ; import { SpacesLicenseService } from './license_service' ; describe ( 'license#isEnabled' , function ( ) { it ( 'should indicate that Spaces is disabled when there is no license information' , ( ) => { const serviceSetup = new SpacesLicenseService ( ) . setup ( { license$ : of ( undefined as any ) , } ) ; expect ( serviceSetup . license . isEnabled ( ) ) . toEqual ( false ) ; } ) ; it ( 'should indicate that Spaces is disabled when xpack is unavailable' , ( ) => { const rawLicenseMock = licenseMock . createLicenseMock ( ) ; rawLicenseMock . isAvailable = false ; const serviceSetup = new SpacesLicenseService ( ) . setup ( { license$ : of ( rawLicenseMock ) , } ) ; expect ( serviceSetup . license . isEnabled ( ) ) . toEqual ( false ) ; } ) ; for ( const level in LICENSE_TYPE ) { if ( isNaN ( level as any ) ) { it ( `should indicate that Spaces is enabled with a ${ level } license` , ( ) => { const rawLicense = licenseMock . createLicense ( { license : { status : 'active' , type : level as LicenseType , } , } ) ; const serviceSetup = new SpacesLicenseService ( ) . setup ( { license$ : of ( rawLicense ) , } ) ; expect ( serviceSetup . license . isEnabled ( ) ) . toEqual ( true ) ; } ) ; } } } ) ;