import { ConnectionProfileUtil } from '../../src/util/ConnectionProfileUtil' ; import * as path from 'path' ; import * as chai from 'chai' ; import * as sinon from 'sinon' ; import * as sinonChai from 'sinon-chai' ; import * as chaiAsPromised from 'chai-as-promised' ; chai . should ( ) ; chai . use ( sinonChai ) ; chai . use ( chaiAsPromised ) ; describe ( 'ConnectionProfileUtil' , ( ) => { let sandbox ; beforeEach ( async ( ) => { sandbox = sinon . createSandbox ( ) ; } ) ; afterEach ( async ( ) => { sandbox . restore ( ) ; } ) ; describe ( '#readConnectionProfile' , ( ) => { it ( 'should read the connection profile (json)' , async ( ) => { const profilePath = path . join ( __dirname , '../data/connectionProfiles/connection.json' ) ; const result = await ConnectionProfileUtil . readConnectionProfile ( profilePath ) ; result . name . should . equal ( 'hlfv1' ) ; } ) ; it ( 'should read the connection profile (yaml)' , async ( ) => { const profilePath = path . join ( __dirname , '../data/connectionProfiles/connection.yaml' ) ; const result = await ConnectionProfileUtil . readConnectionProfile ( profilePath ) ; result . name . should . equal ( 'hlfv1' ) ; } ) ; it ( 'should throw an error if not a json or yml file' , async ( ) => { const profilePath = path . join ( __dirname , '../data/connectionProfiles/connection.bad' ) ; await ConnectionProfileUtil . readConnectionProfile ( profilePath ) . should . eventually . be . rejectedWith ( 'Connection profile must be in JSON or yaml format' ) ; } ) ; } ) ; } ) ;