-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
End-to-end test for Go to definition
- Loading branch information
Showing
9 changed files
with
149 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
%brand | ||
color: purple | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
@use 'theme'; | ||
|
||
.a { | ||
@extend %brand; | ||
} |
43 changes: 43 additions & 0 deletions
43
extension/test/electron/definition/go-to-definition.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
const assert = require('node:assert'); | ||
const path = require('node:path'); | ||
const vscode = require('vscode'); | ||
const { showFile, sleepCI } = require('../util'); | ||
|
||
const stylesUri = vscode.Uri.file( | ||
path.resolve(__dirname, 'fixtures', 'styles.scss') | ||
); | ||
|
||
before(async () => { | ||
await showFile(stylesUri); | ||
await sleepCI(); | ||
}); | ||
|
||
after(async () => { | ||
await vscode.commands.executeCommand('workbench.action.closeAllEditors'); | ||
}); | ||
|
||
/** | ||
* @param {import('vscode').Uri} documentUri | ||
* @returns {Promise<Array<import('vscode').Location>>} | ||
*/ | ||
async function goToDefinition(documentUri, position) { | ||
const result = await vscode.commands.executeCommand( | ||
'vscode.executeDefinitionProvider', | ||
documentUri, | ||
position | ||
); | ||
return result; | ||
} | ||
|
||
test('gets document symbols', async () => { | ||
const [result] = await goToDefinition(stylesUri, new vscode.Position(3, 12)); | ||
|
||
assert.ok(result, 'Should have found the definition for %brand'); | ||
assert.match(result.uri.toString(), /_theme\.sass$/); | ||
|
||
assert.equal(result.range.start.line, 0); | ||
assert.equal(result.range.start.character, 0); | ||
|
||
assert.equal(result.range.end.line, 0); | ||
assert.equal(result.range.end.character, 6); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
const path = require('node:path'); | ||
const fs = require('node:fs/promises'); | ||
const vscode = require('vscode'); | ||
const { runMocha } = require('../mocha'); | ||
|
||
/** | ||
* @returns {Promise<void>} | ||
*/ | ||
async function run() { | ||
const filePaths = []; | ||
|
||
const dir = await fs.readdir(__dirname, { withFileTypes: true }); | ||
for (let entry of dir) { | ||
if (entry.isFile() && entry.name.endsWith('test.js')) { | ||
filePaths.push(path.join(entry.parentPath, entry.name)); | ||
} | ||
} | ||
|
||
await runMocha( | ||
filePaths, | ||
vscode.Uri.file(path.resolve(__dirname, 'fixtures', 'styles.scss')) | ||
); | ||
} | ||
|
||
module.exports = { run }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters