From 440e61ffab2ba257f30852940fdce18a48a168ea Mon Sep 17 00:00:00 2001 From: Martin Aeschlimann Date: Wed, 7 Sep 2022 19:43:47 +0200 Subject: [PATCH] bring back css tests (#160326) --- .../server/src/cssServer.ts | 2 +- .../server/src/test/completion.test.ts | 22 +++++++++---------- .../server/src/test/links.test.ts | 6 ++--- .../server/src/utils/documentContext.ts | 6 ++--- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/extensions/css-language-features/server/src/cssServer.ts b/extensions/css-language-features/server/src/cssServer.ts index a22ff9625dd..ccc0958c502 100644 --- a/extensions/css-language-features/server/src/cssServer.ts +++ b/extensions/css-language-features/server/src/cssServer.ts @@ -74,7 +74,7 @@ export function startServer(connection: Connection, runtime: RuntimeEnvironment) if (!Array.isArray(workspaceFolders)) { workspaceFolders = []; if (params.rootPath) { - workspaceFolders.push({ name: '', uri: URI.file(params.rootPath).toString() }); + workspaceFolders.push({ name: '', uri: URI.file(params.rootPath).toString(true) }); } } diff --git a/extensions/css-language-features/server/src/test/completion.test.ts b/extensions/css-language-features/server/src/test/completion.test.ts index 23570c7e1e5..efb2953e3ec 100644 --- a/extensions/css-language-features/server/src/test/completion.test.ts +++ b/extensions/css-language-features/server/src/test/completion.test.ts @@ -60,8 +60,8 @@ suite('Completions', () => { } test('CSS url() Path completion', async function () { - const testUri = URI.file(path.resolve(__dirname, '../../test/pathCompletionFixtures/about/about.css')).toString(); - const folders = [{ name: 'x', uri: URI.file(path.resolve(__dirname, '../../test')).toString() }]; + const testUri = URI.file(path.resolve(__dirname, '../../test/pathCompletionFixtures/about/about.css')).toString(true); + const folders = [{ name: 'x', uri: URI.file(path.resolve(__dirname, '../../test')).toString(true) }]; await assertCompletions('html { background-image: url("./|")', { items: [ @@ -119,8 +119,8 @@ suite('Completions', () => { }); test('CSS url() Path Completion - Unquoted url', async function () { - const testUri = URI.file(path.resolve(__dirname, '../../test/pathCompletionFixtures/about/about.css')).toString(); - const folders = [{ name: 'x', uri: URI.file(path.resolve(__dirname, '../../test')).toString() }]; + const testUri = URI.file(path.resolve(__dirname, '../../test/pathCompletionFixtures/about/about.css')).toString(true); + const folders = [{ name: 'x', uri: URI.file(path.resolve(__dirname, '../../test')).toString(true) }]; await assertCompletions('html { background-image: url(./|)', { items: [ @@ -148,8 +148,8 @@ suite('Completions', () => { }); test('CSS @import Path completion', async function () { - const testUri = URI.file(path.resolve(__dirname, '../../test/pathCompletionFixtures/about/about.css')).toString(); - const folders = [{ name: 'x', uri: URI.file(path.resolve(__dirname, '../../test')).toString() }]; + const testUri = URI.file(path.resolve(__dirname, '../../test/pathCompletionFixtures/about/about.css')).toString(true); + const folders = [{ name: 'x', uri: URI.file(path.resolve(__dirname, '../../test')).toString(true) }]; await assertCompletions(`@import './|'`, { items: [ @@ -171,8 +171,8 @@ suite('Completions', () => { * For SCSS, `@import 'foo';` can be used for importing partial file `_foo.scss` */ test('SCSS @import Path completion', async function () { - const testCSSUri = URI.file(path.resolve(__dirname, '../../test/pathCompletionFixtures/about/about.css')).toString(); - const folders = [{ name: 'x', uri: URI.file(path.resolve(__dirname, '../../test')).toString() }]; + const testCSSUri = URI.file(path.resolve(__dirname, '../../test/pathCompletionFixtures/about/about.css')).toString(true); + const folders = [{ name: 'x', uri: URI.file(path.resolve(__dirname, '../../test')).toString(true) }]; /** * We are in a CSS file, so no special treatment for SCSS partial files @@ -184,7 +184,7 @@ suite('Completions', () => { ] }, testCSSUri, folders); - const testSCSSUri = URI.file(path.resolve(__dirname, '../../test/pathCompletionFixtures/scss/main.scss')).toString(); + const testSCSSUri = URI.file(path.resolve(__dirname, '../../test/pathCompletionFixtures/scss/main.scss')).toString(true); await assertCompletions(`@import './|'`, { items: [ { label: '_foo.scss', resultText: `@import './foo'` } @@ -193,8 +193,8 @@ suite('Completions', () => { }); test('Completion should ignore files/folders starting with dot', async function () { - const testUri = URI.file(path.resolve(__dirname, '../../test/pathCompletionFixtures/about/about.css')).toString(); - const folders = [{ name: 'x', uri: URI.file(path.resolve(__dirname, '../../test')).toString() }]; + const testUri = URI.file(path.resolve(__dirname, '../../test/pathCompletionFixtures/about/about.css')).toString(true); + const folders = [{ name: 'x', uri: URI.file(path.resolve(__dirname, '../../test')).toString(true) }]; await assertCompletions('html { background-image: url("../|")', { count: 4 diff --git a/extensions/css-language-features/server/src/test/links.test.ts b/extensions/css-language-features/server/src/test/links.test.ts index 0eed896fcf5..96bca1e4864 100644 --- a/extensions/css-language-features/server/src/test/links.test.ts +++ b/extensions/css-language-features/server/src/test/links.test.ts @@ -58,7 +58,7 @@ suite('Links', () => { return URI.file(resolve(__dirname, '../../test/linksTestFixtures', path)).toString(true); } - test.skip('url links', async function () { + test('url links', async function () { const testUri = getTestResource('about.css'); const folders = [{ name: 'x', uri: getTestResource('') }]; @@ -68,7 +68,7 @@ suite('Links', () => { ); }); - test.skip('node module resolving', async function () { + test('node module resolving', async function () { const testUri = getTestResource('about.css'); const folders = [{ name: 'x', uri: getTestResource('') }]; @@ -78,7 +78,7 @@ suite('Links', () => { ); }); - test.skip('node module subfolder resolving', async function () { + test('node module subfolder resolving', async function () { const testUri = getTestResource('subdir/about.css'); const folders = [{ name: 'x', uri: getTestResource('') }]; diff --git a/extensions/css-language-features/server/src/utils/documentContext.ts b/extensions/css-language-features/server/src/utils/documentContext.ts index 0570ac92375..3defe4a445d 100644 --- a/extensions/css-language-features/server/src/utils/documentContext.ts +++ b/extensions/css-language-features/server/src/utils/documentContext.ts @@ -27,11 +27,11 @@ export function getDocumentContext(documentUri: string, workspaceFolders: Worksp if (ref[0] === '/') { // resolve absolute path against the current workspace folder const folderUri = getRootFolder(); if (folderUri) { - return folderUri + ref.substr(1); + return folderUri + ref.substring(1); } } - base = base.substr(0, base.lastIndexOf('/') + 1); - return Utils.resolvePath(URI.parse(base), ref).toString(); + base = base.substring(0, base.lastIndexOf('/') + 1); + return Utils.resolvePath(URI.parse(base), ref).toString(true); }, }; }