'use strict' ; import * as path from 'path' ; import * as sinon from 'sinon' ; import * as chai from 'chai' ; import * as sinonChai from 'sinon-chai' ; import { FabricConnectionFactory } from '../../extension/fabric/FabricConnectionFactory' ; import { IFabricGatewayConnection , IFabricEnvironmentConnection } from 'ibm-blockchain-platform-common' ; chai . should ( ) ; chai . use ( sinonChai ) ; describe ( 'FabricConnectionFactory' , ( ) => { let mySandBox ; beforeEach ( async ( ) => { mySandBox = sinon . createSandbox ( ) ; } ) ; afterEach ( ( ) => { mySandBox . restore ( ) ; } ) ; describe ( 'createFabricGatewayConnection' , ( ) => { it ( 'should create a fabric gateway connection' , async ( ) => { const rootPath = path . dirname ( __dirname ) ; const profilePath = path . join ( rootPath , '../../test/data/connectionTwo/connection.json' ) ; const connection = FabricConnectionFactory . createFabricGatewayConnection ( profilePath ) ; connection . should . exist ; } ) ; it ( 'should resuse connection if have one' , async ( ) => { const rootPath = path . dirname ( __dirname ) ; const profilePath = path . join ( rootPath , '../../test/data/connectionTwo/connection.json' ) ; FabricConnectionFactory . createFabricGatewayConnection ( profilePath ) ; const connection = FabricConnectionFactory . createFabricGatewayConnection ( profilePath ) ; connection . should . exist ; } ) ; } ) ; describe ( 'createFabricEnvironmentConnection' , ( ) => { it ( 'should create a fabric environment connection' , async ( ) => { const connection = FabricConnectionFactory . createFabricEnvironmentConnection ( 'myEnvironment' ) ; connection . should . exist ; } ) ; it ( 'should resuse connection if have one' , async ( ) => { FabricConnectionFactory . createFabricEnvironmentConnection ( 'myEnvironment' ) ; const connection = FabricConnectionFactory . createFabricEnvironmentConnection ( 'myEnvironment' ) ; connection . should . exist ; } ) ; } ) ; } ) ;