Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
Vlad Barosan committed Mar 7, 2019
1 parent b2fceb4 commit a47f4a9
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions test/go.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -544,22 +544,18 @@ It returns the number of bytes written and any write error encountered.
test('Test Outline document symbols', (done) => {
const uri = vscode.Uri.file(path.join(fixturePath, 'outlineTest', 'test.go'));
vscode.workspace.openTextDocument(uri).then(document => {
new GoDocumentSymbolProvider().provideDocumentSymbols(document, null).then(symbols => {
const groupedSymbolNames = symbols.reduce((map: any, symbol) => {
map[symbol.kind] = (map[symbol.kind] || []).concat([symbol.name]);
return map;
}, {});

const packageNames = groupedSymbolNames[vscode.SymbolKind.Package];
const variableNames = groupedSymbolNames[vscode.SymbolKind.Variable];
const functionNames = groupedSymbolNames[vscode.SymbolKind.Function];
const structs = groupedSymbolNames[vscode.SymbolKind.Struct];
assert.equal(packageNames[0], 'main');
assert.equal(variableNames, undefined);
assert.equal(functionNames[0], 'print');
assert.equal(functionNames[1], 'main');
new GoDocumentSymbolProvider().provideDocumentSymbols(document, null).then(outlines => {
const packages = outlines.filter(x => x.kind === vscode.SymbolKind.Package);
const variables = outlines[0].children.filter((x: any) => x.kind === vscode.SymbolKind.Variable);
const functions = outlines[0].children.filter((x: any) => x.kind === vscode.SymbolKind.Function);
const structs = outlines[0].children.filter((x: any) => x.kind === vscode.SymbolKind.Struct);

assert.equal(packages[0].name, 'main');
assert.equal(variables.length, 0);
assert.equal(functions[0].name, 'print');
assert.equal(functions[1].name, 'main');
assert.equal(structs.length, 1);
assert.equal(structs[0], 'foo');
assert.equal(structs[0].name, 'foo');
});
}).then(() => done(), done);
});
Expand Down

0 comments on commit a47f4a9

Please sign in to comment.