-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi-testing.js
39 lines (36 loc) · 1.23 KB
/
api-testing.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
const vscode = require('vscode');
const codeLense = (document, token) => {
// for the whole test suite
const range = new vscode.Range(0, 1, 10, 10)
const lens = new vscode.CodeLens(range, {
command: 'atest',
title: 'run suite'
})
const lensRunWith = new vscode.CodeLens(range, {
command: 'atest.runwith',
title: 'run suite with env'
})
let result = [lens, lensRunWith]
// for test cases
for (let i = 0; i < document.lineCount; i++) {
let nameAnchor = document.lineAt(i).text
nameAnchor = nameAnchor.trimLeft(' ', '')
if (nameAnchor.startsWith('- name: ')) {
let name = nameAnchor.replace('- name: ', '')
const range = new vscode.Range(i, 1, i, 10)
const testcaseLens = new vscode.CodeLens(range, {
command: 'atest',
title: 'run',
arguments: [name, "info"]
})
const testcaseDebugLens = new vscode.CodeLens(range, {
command: 'atest',
title: 'debug',
arguments: [name, "debug"]
})
result.push(testcaseLens, testcaseDebugLens)
}
}
return result
}
module.exports = codeLense;