Skip to content

Commit e5871bd

Browse files
committed
Add tests
1 parent 81c2cae commit e5871bd

File tree

2 files changed

+44
-1
lines changed

2 files changed

+44
-1
lines changed

packages/tailwindcss-language-server/src/testing/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export interface TestConfig<Extras extends {}, TestInput extends Record<string,
3232
name: string
3333
inputs?: TestInput[]
3434

35+
skipNPM?: boolean
3536
fs?: Storage
3637
debug?: boolean
3738
prepare?(utils: TestUtils<TestInput>): Promise<Extras>
@@ -70,7 +71,10 @@ async function setup<T, I>(config: TestConfig<T, I>, input: I): Promise<TestUtil
7071

7172
if (config.fs) {
7273
await prepareFileSystem(baseDir, config.fs)
73-
await installDependencies(baseDir, config.fs)
74+
75+
if (!config.skipNPM) {
76+
await installDependencies(baseDir, config.fs)
77+
}
7478
}
7579

7680
onTestFinished(async (ctx) => {

packages/tailwindcss-language-server/tests/env/v4.test.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -856,3 +856,42 @@ defineTest({
856856
})
857857
},
858858
})
859+
860+
defineTest({
861+
name: 'Matches files in a workspace when only one config exists and is nested in a package',
862+
skipNPM: true,
863+
fs: {
864+
'some-dir/package.json': json`{"type": "commonjs"}`,
865+
'some-dir/tailwind.config.js': js`
866+
module.exports = { content: [] }
867+
`,
868+
},
869+
prepare: async ({ root }) => ({ client: await createClient({ root }) }),
870+
handle: async ({ client }) => {
871+
let doc = await client.open({
872+
name: 'files/index.html',
873+
lang: 'html',
874+
text: html`<div class="bg-[#000]"></div>`,
875+
})
876+
877+
// <div class="bg-[#000]"></div>
878+
// ^
879+
let hover = await doc.hover({ line: 0, character: 13 })
880+
881+
expect(hover).toEqual({
882+
contents: {
883+
language: 'css',
884+
value: dedent`
885+
.bg-\[\#000\] {
886+
--tw-bg-opacity: 1;
887+
background-color: rgb(0 0 0 / var(--tw-bg-opacity, 1)) /* #000000 */;
888+
}
889+
`,
890+
},
891+
range: {
892+
start: { line: 0, character: 12 },
893+
end: { line: 0, character: 21 },
894+
},
895+
})
896+
},
897+
})

0 commit comments

Comments
 (0)