-
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test(Language Server): Add monorepo tests
- Loading branch information
Showing
14 changed files
with
197 additions
and
3,305 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
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,20 @@ | ||
import { resolve } from 'path' | ||
import { withFixture } from './setup' | ||
import { test } from 'vitest' | ||
import { Settings } from '../src' | ||
|
||
const settings: Settings = { | ||
workspaces: [ | ||
'./c' | ||
] | ||
} | ||
|
||
withFixture('monorepo', async (context) => { | ||
test.concurrent('workspaces', async ({ expect }) => { | ||
expect(context.server.workspaces.length).toBe(2) | ||
expect(context.server.workspaces).toMatchObject([ | ||
{ path: resolve('tests/fixtures/monorepo') }, | ||
{ path: resolve('tests/fixtures/monorepo/c') }, | ||
]) | ||
}) | ||
}, settings) |
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 @@ | ||
<div class="fg:custom"></div> |
7 changes: 7 additions & 0 deletions
7
packages/language-server/tests/fixtures/monorepo/a/master.css.ts
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,7 @@ | ||
import { Config } from '@master/css' | ||
|
||
export default { | ||
variables: { | ||
custom: '#ff0000' | ||
} | ||
} as Config |
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 @@ | ||
<div class="fg:custom"></div> |
7 changes: 7 additions & 0 deletions
7
packages/language-server/tests/fixtures/monorepo/b/master.css.ts
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,7 @@ | ||
import { Config } from '@master/css' | ||
|
||
export default { | ||
variables: { | ||
custom: '#ffff00' | ||
} | ||
} as Config |
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 @@ | ||
<div class="fg:global"></div> |
4 changes: 4 additions & 0 deletions
4
packages/language-server/tests/fixtures/monorepo/c/package.json
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": "vscode-playground-package-c", | ||
"private": true | ||
} |
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,24 @@ | ||
import { resolve } from 'path' | ||
import { withFixture } from './setup' | ||
import { test } from 'vitest' | ||
|
||
withFixture('monorepo', async (context) => { | ||
test.concurrent('workspaces', async ({ expect }) => { | ||
expect(context.server.workspaces.length).toBe(3) | ||
expect(context.server.workspaces).toMatchObject([ | ||
{ path: resolve('tests/fixtures/monorepo') }, | ||
{ path: resolve('tests/fixtures/monorepo/a') }, | ||
{ path: resolve('tests/fixtures/monorepo/b') }, | ||
]) | ||
}) | ||
|
||
test('open a document and link it to the nearest workspace', async ({ expect }) => { | ||
const dir = resolve(__dirname, './fixtures/monorepo/a') | ||
const textDocument = context.createDocument('', { dir }) | ||
await context.server.onDidOpen({ document: textDocument }) | ||
const targetWorkspace = context.server.workspaces.find((workspace) => workspace.path === resolve(dir)) | ||
expect(targetWorkspace?.openedTextDocuments.length).toBe(1) | ||
await context.server.onDidClose({ document: textDocument }) | ||
expect(context.rootWorkspace?.openedTextDocuments?.length).toBe(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
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
Oops, something went wrong.