-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: handle default and project level resolve namespace (#1038)
- Loading branch information
Showing
7 changed files
with
88 additions
and
0 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 @@ | ||
.root::unknownPseudoElement {} |
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,4 @@ | ||
{ | ||
"name": "test-project-with-config-errors", | ||
"version": "1.0.0" | ||
} |
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,11 @@ | ||
//@ts-check | ||
|
||
module.exports = { | ||
defaultConfig() { | ||
return { | ||
resolveNamespace(namespace) { | ||
throw new Error('resolveNamespace test error for namespace: ' + namespace); | ||
}, | ||
}; | ||
}, | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import fs from '@file-services/node'; | ||
import vscode from 'vscode'; | ||
import { expect } from 'chai'; | ||
import path from 'path'; | ||
|
||
suite('configuration with errors', function () { | ||
this.timeout(60000); | ||
|
||
let rootDir: string | null; | ||
|
||
suiteSetup(() => { | ||
rootDir = fs.dirname(fs.findClosestFileSync(__dirname, 'package.json')!); | ||
}); | ||
|
||
async function getWorkingDocument(...testSubPath: string[]) { | ||
const casesPath = path.join(rootDir!, 'fixtures', 'config-errors', ...testSubPath); | ||
const ext = vscode.extensions.getExtension('wix.stylable-intelligence'); | ||
|
||
if (ext) { | ||
const doc = await vscode.workspace.openTextDocument(casesPath); | ||
await ext.activate(); | ||
return doc; | ||
} else { | ||
throw new Error('Where is my extension?!!'); | ||
} | ||
} | ||
function collectDiagnostics(source: 'stylable' | 'css', file: string) { | ||
const diags = vscode.languages.getDiagnostics(); | ||
const res = []; | ||
|
||
for (const [pathObj, fileDiags] of diags) { | ||
for (const diag of fileDiags) { | ||
if (diag.source === source && file === pathObj.fsPath) { | ||
res.push({ | ||
message: diag.message, | ||
range: diag.range, | ||
severity: diag.severity, | ||
filePath: fs.realpathSync.native(pathObj.fsPath), | ||
}); | ||
} | ||
} | ||
} | ||
|
||
return res; | ||
} | ||
|
||
test('should handle errors in resolve namespace config', async () => { | ||
const testDoc = await getWorkingDocument('errors.st.css'); | ||
await vscode.window.showTextDocument(testDoc); | ||
const diags = collectDiagnostics('stylable', testDoc.uri.fsPath); | ||
// make sure extension functions correctly | ||
expect(diags.length).to.not.eql(0); | ||
}); | ||
}); |
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 @@ | ||
import { collectAndRunTests } from '../../lsp-testkit/collect-and-run-tests'; | ||
|
||
export function run() { | ||
return collectAndRunTests({ testsRoot: __dirname, suiteName: 'config errors' }); | ||
} |