import expect from '@kbn/expect' ; import { kibanaResponseFactory } from '../../../../../../src/core/server' ; import { licensePreRoutingFactory } from '../license_pre_routing_factory' ; import { LicenseStatus } from '../../types' ; describe ( 'licensePreRoutingFactory()' , ( ) => { let mockDeps ; let mockContext ; let licenseStatus ; beforeEach ( ( ) => { mockDeps = { getLicenseStatus : ( ) => licenseStatus } ; mockContext = { core : { } , actions : { } , licensing : { } , } ; } ) ; describe ( 'status is not valid' , ( ) => { it ( 'replies with 403' , ( ) => { licenseStatus = { valid : false } ; const stubRequest = { } ; const stubHandler = ( ) => { } ; const routeWithLicenseCheck = licensePreRoutingFactory ( mockDeps , stubHandler ) ; const response = routeWithLicenseCheck ( mockContext , stubRequest , kibanaResponseFactory ) ; expect ( response . status ) . to . be ( 403 ) ; } ) ; } ) ; describe ( 'status is valid' , ( ) => { it ( 'replies with nothing' , ( ) => { licenseStatus = { valid : true } ; const stubRequest = { } ; const stubHandler = ( ) => null ; const routeWithLicenseCheck = licensePreRoutingFactory ( mockDeps , stubHandler ) ; const response = routeWithLicenseCheck ( mockContext , stubRequest , kibanaResponseFactory ) ; expect ( response ) . to . be ( null ) ; } ) ; } ) ; } ) ;