@@ -30,6 +30,13 @@ jest.mock('vscode', () => {
3030 public event = jest . fn ( ) ;
3131 }
3232
33+ class ThemeIcon {
34+ public id : string ;
35+
36+ constructor ( id : string ) {
37+ this . id = id ;
38+ }
39+ }
3340 class MarkdownString {
3441 public value : string ;
3542 public supportHtml = false ;
@@ -46,6 +53,7 @@ jest.mock('vscode', () => {
4653 public tooltip : string | MarkdownString | undefined ;
4754 public id : string | undefined ;
4855 public contextValue : string | undefined ;
56+ public iconPath : vscode . ThemeIcon | undefined ;
4957
5058 constructor ( label : string ) {
5159 this . label = label ;
@@ -56,6 +64,7 @@ jest.mock('vscode', () => {
5664 EventEmitter,
5765 MarkdownString,
5866 TreeItem,
67+ ThemeIcon,
5968 TreeItemCollapsibleState : {
6069 Collapsed : 1 ,
6170 None : 0 ,
@@ -173,7 +182,21 @@ describe('ComponentViewerTreeDataProvider', () => {
173182 expect ( rootItem . contextValue ) . toBe ( 'locked.parentInstance' ) ;
174183
175184 const childItem = provider . getTreeItem ( childUnlocked ) ;
176- expect ( childItem . contextValue ) . toBe ( 'child' ) ;
185+ expect ( childItem . contextValue ) . toBe ( '' ) ;
186+ } ) ;
187+
188+ it ( 'assigns lock icon for locked root nodes' , ( ) => {
189+ const provider = new ComponentViewerTreeDataProvider ( ) ;
190+ const rootLocked = makeGui ( { isRootInstance : true , isLocked : true } ) ;
191+ const rootUnLocked = makeGui ( { isRootInstance : true , isLocked : false } ) ;
192+
193+ const rootItem = provider . getTreeItem ( rootLocked ) ;
194+ expect ( rootItem . iconPath ) . toBeInstanceOf ( vscode . ThemeIcon ) ;
195+ const rootIcon = rootItem . iconPath as { id : string } ;
196+ expect ( rootIcon . id ) . toBe ( 'lock' ) ;
197+
198+ const rootUnLockedItem = provider . getTreeItem ( rootUnLocked ) ;
199+ expect ( rootUnLockedItem . iconPath ) . toBeUndefined ( ) ;
177200 } ) ;
178201
179202 it ( 'returns root children when no element is provided' , async ( ) => {
0 commit comments