import * as vscode from 'vscode' ; import * as path from 'path' ; import { ConnectedTreeItem } from '../../../extension/explorer/model/ConnectedTreeItem' ; import { FabricGatewayRegistryEntry } from 'ibm-blockchain-platform-common' ; import * as chai from 'chai' ; import * as sinon from 'sinon' ; import { ExtensionUtil } from '../../../extension/util/ExtensionUtil' ; chai . should ( ) ; const should = chai . should ( ) ; describe ( 'ConnectedTreeItem' , ( ) => { let gatewayRegistryEntry ; const rootPath = path . dirname ( __dirname ) ; class TestConnectedTreeItem extends ConnectedTreeItem { constructor ( label ) { super ( ExtensionUtil . getBlockchainGatewayExplorerProvider ( ) , label , gatewayRegistryEntry , vscode . TreeItemCollapsibleState . None ) ; } } let sandbox ; let treeItem ; beforeEach ( ( ) => { sandbox = sinon . createSandbox ( ) ; gatewayRegistryEntry = new FabricGatewayRegistryEntry ( ) ; gatewayRegistryEntry . name = 'testGateway' ; } ) ; afterEach ( ( ) => { sandbox . restore ( ) ; } ) ; describe ( '#iconPath' , ( ) => { it ( 'should set the iconPath to null if tree item is connected via gateway' , ( ) => { treeItem = new TestConnectedTreeItem ( 'test label Connected via gateway' ) ; should . not . exist ( treeItem . iconPath ) ; } ) ; it ( 'should set the iconPath to null if tree item is using ID' , ( ) => { treeItem = new TestConnectedTreeItem ( 'test label Using ID' ) ; should . not . exist ( treeItem . iconPath ) ; } ) ; it ( 'should have an iconPath if the tree item is neither connected via gateway or using ID' , ( ) => { treeItem = new TestConnectedTreeItem ( 'test label' ) ; treeItem . iconPath . should . deep . equal ( { light : path . join ( rootPath , '..' , '..' , '..' , 'resources' , 'light' , 'channel.svg' ) , dark : path . join ( rootPath , '..' , '..' , '..' , 'resources' , 'dark' , 'channel.svg' ) } ) ; } ) ; } ) ; } ) ;