Skip to content

Commit cbbca79

Browse files
committed
rewrite test
1 parent 785909d commit cbbca79

File tree

1 file changed

+72
-25
lines changed

1 file changed

+72
-25
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,85 @@
1-
import { test } from 'vitest'
2-
import { withFixture } from '../common'
1+
import { expect } from 'vitest'
2+
import { css, defineTest, html, js, json, symlinkTo } from '../../src/testing'
3+
import dedent from 'dedent'
4+
import { createClient } from '../utils/client'
35

4-
withFixture('multi-config-content', (c) => {
5-
test.concurrent('multi-config with content config - 1', async ({ expect }) => {
6-
let textDocument = await c.openDocument({ text: '<div class="bg-foo">', dir: 'one' })
7-
let res = await c.sendRequest('textDocument/hover', {
8-
textDocument,
9-
position: { line: 0, character: 13 },
6+
defineTest({
7+
name: 'multi-config with content config',
8+
fs: {
9+
'tailwind.config.one.js': js`
10+
module.exports = {
11+
content: ['./one/**/*'],
12+
theme: {
13+
extend: {
14+
colors: {
15+
foo: 'red',
16+
},
17+
},
18+
},
19+
}
20+
`,
21+
'tailwind.config.two.js': js`
22+
module.exports = {
23+
content: ['./two/**/*'],
24+
theme: {
25+
extend: {
26+
colors: {
27+
foo: 'blue',
28+
},
29+
},
30+
},
31+
}
32+
`,
33+
},
34+
prepare: async ({ root }) => ({ client: await createClient({ root }) }),
35+
handle: async ({ client }) => {
36+
let one = await client.open({
37+
lang: 'html',
38+
name: 'one/index.html',
39+
text: '<div class="bg-foo">',
1040
})
1141

12-
expect(res).toEqual({
42+
let two = await client.open({
43+
lang: 'html',
44+
name: 'two/index.html',
45+
text: '<div class="bg-foo">',
46+
})
47+
48+
// <div class="bg-foo">
49+
// ^
50+
let hoverOne = await one.hover({ line: 0, character: 13 })
51+
let hoverTwo = await two.hover({ line: 0, character: 13 })
52+
53+
expect(hoverOne).toEqual({
1354
contents: {
1455
language: 'css',
15-
value:
16-
'.bg-foo {\n --tw-bg-opacity: 1;\n background-color: rgb(255 0 0 / var(--tw-bg-opacity, 1)) /* #ff0000 */;\n}',
56+
value: dedent`
57+
.bg-foo {
58+
--tw-bg-opacity: 1;
59+
background-color: rgb(255 0 0 / var(--tw-bg-opacity, 1)) /* #ff0000 */;
60+
}
61+
`,
62+
},
63+
range: {
64+
start: { line: 0, character: 12 },
65+
end: { line: 0, character: 18 },
1766
},
18-
range: { start: { line: 0, character: 12 }, end: { line: 0, character: 18 } },
19-
})
20-
})
21-
22-
test.concurrent('multi-config with content config - 2', async ({ expect }) => {
23-
let textDocument = await c.openDocument({ text: '<div class="bg-foo">', dir: 'two' })
24-
let res = await c.sendRequest('textDocument/hover', {
25-
textDocument,
26-
position: { line: 0, character: 13 },
2767
})
2868

29-
expect(res).toEqual({
69+
expect(hoverTwo).toEqual({
3070
contents: {
3171
language: 'css',
32-
value:
33-
'.bg-foo {\n --tw-bg-opacity: 1;\n background-color: rgb(0 0 255 / var(--tw-bg-opacity, 1)) /* #0000ff */;\n}',
72+
value: dedent`
73+
.bg-foo {
74+
--tw-bg-opacity: 1;
75+
background-color: rgb(0 0 255 / var(--tw-bg-opacity, 1)) /* #0000ff */;
76+
}
77+
`,
78+
},
79+
range: {
80+
start: { line: 0, character: 12 },
81+
end: { line: 0, character: 18 },
3482
},
35-
range: { start: { line: 0, character: 12 }, end: { line: 0, character: 18 } },
3683
})
37-
})
84+
},
3885
})

0 commit comments

Comments
 (0)