import { BlockchainGatewayExplorerProvider } from '../../../extension/explorer/gatewayExplorer' ; import { ExtensionUtil } from '../../../extension/util/ExtensionUtil' ; import { TestUtil } from '../../TestUtil' ; import * as sinon from 'sinon' ; import * as vscode from 'vscode' ; import { FabricEnvironmentRegistryEntry , FabricNode } from 'ibm-blockchain-platform-common' ; import { NodeTreeItem } from '../../../extension/explorer/runtimeOps/connectedTree/NodeTreeItem' ; import { BlockchainExplorerProvider } from '../../../extension/explorer/BlockchainExplorerProvider' ; class TestTreeItem extends NodeTreeItem { contextValue : string = 'blockchain-peer-item' ; constructor ( provider , public readonly peerName , public readonly tooltip , environmentRegistryEntry , node , public readonly command ? ) { super ( provider , peerName , tooltip , environmentRegistryEntry , node , command ) ; } } describe ( 'NodeTreeItem' , ( ) => { const sandbox = sinon . createSandbox ( ) ; let provider ; let node ; before ( async ( ) => { await TestUtil . setupTests ( sandbox ) ; } ) ; beforeEach ( async ( ) => { await ExtensionUtil . activateExtension ( ) ; node = FabricNode . newPeer ( 'peer1' , 'peer1.org1.example.com' , 'http://peer.sample.org' , 'admin' , 'myWallet' , 'Org1MSP' ) ; provider = ExtensionUtil . getBlockchainGatewayExplorerProvider ( ) ; } ) ; afterEach ( async ( ) => { sandbox . restore ( ) ; } ) ; describe ( '#constructor' , ( ) => { it ( 'should have the right properties for a node' , async ( ) => { const tooltip = `Name: ${ node . name }\nMSPID: ${ node . msp_id }\nAssociated Identity:\n${ node . identity }` ; const treeItem = new TestTreeItem ( provider , 'peer1.org1.example.com' , tooltip , new FabricEnvironmentRegistryEntry ( ) , node ) ; treeItem . label . should . equal ( 'peer1.org1.example.com' ) ; treeItem . tooltip . should . equal ( tooltip ) ; } ) ; } ) ; } ) ;