forked from maty21/mocha-sidebar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mochaItem.js
41 lines (32 loc) · 1.29 KB
/
mochaItem.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
const vscode = require('vscode');
const navigateEditorItem = require('./provider-extensions/NavigateEditorItem.js');
class mochaItem extends vscode.TreeItem {
constructor(label, collapsibleState, contextValue, iconPath, item, hierarchyLevel = 0) {
super(label, collapsibleState);
this.contextValue = contextValue;
this.iconPath = iconPath;
this.item = item;
this.hierarchyLevel = hierarchyLevel;
if (this.contextValue == "testItem") {
this.line = navigateEditorItem(this.item.__test.file, this.item.__test.name);
this.command = {
command: 'mocha-maty.itemSelection',
title: 'item selection',
arguments: [{ __test: this.item.__test, line: this.line }]
}
}
else if (this.contextValue == "testDescriber") {
let testItem = null;
testItem = this._getFirstTestItem(this.item);
this.line = navigateEditorItem(testItem.file,this.label);
}
}
_getFirstTestItem(item) {
let it = Object.keys(item).find(i => i == "__test");
if (it) {
return item.__test;
}
return this._getFirstTestItem(item[Object.keys(item)[1]])
}
}
module.exports = mochaItem;