Skip to content

Commit 65fa9a5

Browse files
committed
adding tests for new getTreeItem function
1 parent 8d433ef commit 65fa9a5

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/views/live-watch/live-watch.test.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,12 +154,22 @@ describe('LiveWatchTreeDataProvider', () => {
154154
expect(parent.children.length).toBe(0);
155155
});
156156

157-
it('getTreeItem returns correct TreeItem', () => {
158-
const node = makeNode('expression', { result: 'value', variablesReference: 1 }, 1);
157+
it('returns correct TreeItem for parent nodes', () => {
158+
const node = makeNode('expression', { result: 'value', variablesReference: 0 }, 1);
159159
const item = liveWatchTreeDataProvider.getTreeItem(node);
160160
expect(item.label).toBe('expression = ');
161161
expect(item.description).toBe('value');
162-
expect(item.contextValue).toBe('expression');
162+
expect(item.contextValue).toBe('parentExpression');
163+
});
164+
165+
it('returns correct TreeItem for leaf nodes', () => {
166+
// Create a child node within a parent node
167+
const parent = makeNode('parentExpression', { result: 'parentValue', variablesReference: 1 }, 1);
168+
const child = makeNode('childExpression', { result: 'childValue', variablesReference: 0 }, 2, parent);
169+
const item = liveWatchTreeDataProvider.getTreeItem(child);
170+
expect(item.label).toBe('childExpression = ');
171+
expect(item.description).toBe('childValue');
172+
expect(item.contextValue).toBe('childExpression');
163173
});
164174
});
165175

0 commit comments

Comments
 (0)