'use strict' ; import * as chai from 'chai' ; import * as sinonChai from 'sinon-chai' ; import { IFabricWalletGenerator } from '../../src/interfaces/IFabricWalletGenerator' ; import { FabricWalletGeneratorFactory } from '../../src/util/FabricWalletGeneratorFactory' ; import { FabricWalletRegistryEntry } from '../../src/registries/FabricWalletRegistryEntry' ; chai . use ( sinonChai ) ; describe ( 'FabricWalletGeneratorFactory' , ( ) => { class TestGenerator implements IFabricWalletGenerator { public async getWallet ( walletRegsitryEntry ) { return walletRegsitryEntry ; } } let generator ; beforeEach ( ( ) => { generator = new TestGenerator ( ) ; } ) ; describe ( 'setFabricWalletGenerator' , ( ) => { it ( 'should set the generator' , ( ) => { FabricWalletGeneratorFactory [ 'instance' ] = null ; FabricWalletGeneratorFactory . setFabricWalletGenerator ( generator ) ; FabricWalletGeneratorFactory [ 'instance' ] . should . exist ; } ) ; } ) ; describe ( 'getFabricWalletGenerator' , ( ) => { it ( 'should get the generator' , ( ) => { FabricWalletGeneratorFactory [ 'instance' ] = generator ; const result = FabricWalletGeneratorFactory . getFabricWalletGenerator ( ) ; result . should . exist ; } ) ; it ( 'should throw an error if instance not set' , ( ) => { FabricWalletGeneratorFactory [ 'instance' ] = null ; ( ( ) : any => { FabricWalletGeneratorFactory . getFabricWalletGenerator ( ) ; } ) . should . throw ( 'Must call setFabricWalletGenerator first!' ) ; } ) ; } ) ; } ) ;