From d7c77050c662eadada31dc49f49459f8c43b4177 Mon Sep 17 00:00:00 2001 From: William Killerud Date: Tue, 23 Apr 2024 20:16:51 +0200 Subject: [PATCH] test: join lines using EOL from the os --- .../src/features/__tests__/code-actions-extract.test.ts | 5 ++++- packages/language-services/src/utils/test-helpers.ts | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/language-services/src/features/__tests__/code-actions-extract.test.ts b/packages/language-services/src/features/__tests__/code-actions-extract.test.ts index 2393adf0..6734d17d 100644 --- a/packages/language-services/src/features/__tests__/code-actions-extract.test.ts +++ b/packages/language-services/src/features/__tests__/code-actions-extract.test.ts @@ -32,7 +32,10 @@ const getEdit = (result: CodeAction): TextEdit[] => { }; test("extraction for variable", async () => { - const document = fileSystemProvider.createDocument("--var: black;"); + const document = fileSystemProvider.createDocument([ + "--var: black;", + ".a { color: var(--var); }", + ]); const result = await ls.getCodeActions( document, diff --git a/packages/language-services/src/utils/test-helpers.ts b/packages/language-services/src/utils/test-helpers.ts index 7c765234..aa9d7c3d 100644 --- a/packages/language-services/src/utils/test-helpers.ts +++ b/packages/language-services/src/utils/test-helpers.ts @@ -1,3 +1,4 @@ +import { EOL } from "node:os"; import { join } from "path"; import { LanguageServiceOptions, @@ -19,7 +20,7 @@ class MemoryFileSystem implements FileSystemProvider { lines: string[] | string, options: { uri?: string; languageId?: string; version?: number } = {}, ): TextDocument { - const text = Array.isArray(lines) ? lines.join("\n") : lines; + const text = Array.isArray(lines) ? lines.join(EOL) : lines; const uri = URI.file(join(process.cwd(), options.uri || "index.scss")); const document = TextDocument.create( uri.toString(),