@@ -2,25 +2,25 @@ import { test } from 'vitest'
2
2
import { withFixture } from '../common'
3
3
4
4
withFixture ( 'basic' , ( c ) => {
5
- async function testHover ( name , { text, lang, position, expected, expectedRange, settings } ) {
5
+ async function testHover ( name , { text, lang, position, exact = false , expected, expectedRange, settings } ) {
6
6
test . concurrent ( name , async ( { expect } ) => {
7
7
let textDocument = await c . openDocument ( { text, lang, settings } )
8
8
let res = await c . sendRequest ( 'textDocument/hover' , {
9
9
textDocument,
10
10
position,
11
11
} )
12
12
13
- expect ( res ) . toEqual (
14
- expected
15
- ? {
16
- contents : {
17
- language : 'css' ,
18
- value : expected ,
19
- } ,
20
- range : expectedRange ,
21
- }
22
- : expected ,
23
- )
13
+ if ( ! exact && expected ) {
14
+ expected = {
15
+ contents : {
16
+ language : 'css' ,
17
+ value : expected ,
18
+ } ,
19
+ range : expectedRange ,
20
+ }
21
+ }
22
+
23
+ expect ( res ) . toEqual ( expected )
24
24
} )
25
25
}
26
26
@@ -38,7 +38,7 @@ withFixture('basic', (c) => {
38
38
expected :
39
39
'.bg-red-500 {\n' +
40
40
' --tw-bg-opacity: 1;\n' +
41
- ' background-color: rgb(239 68 68 / var(--tw-bg-opacity))/* #ef4444 */;\n' +
41
+ ' background-color: rgb(239 68 68 / var(--tw-bg-opacity)) /* #ef4444 */;\n' +
42
42
'}' ,
43
43
expectedRange : {
44
44
start : { line : 0 , character : 12 } ,
@@ -59,7 +59,7 @@ withFixture('basic', (c) => {
59
59
testHover ( 'arbitrary value with theme function' , {
60
60
text : '<div class="p-[theme(spacing.4)]">' ,
61
61
position : { line : 0 , character : 13 } ,
62
- expected : '.p-\\[theme\\(spacing\\.4\\)\\] {\n' + ' padding: 1rem/* 16px */;\n' + '}' ,
62
+ expected : '.p-\\[theme\\(spacing\\.4\\)\\] {\n' + ' padding: 1rem /* 16px */;\n' + '}' ,
63
63
expectedRange : {
64
64
start : { line : 0 , character : 12 } ,
65
65
end : { line : 0 , character : 32 } ,
@@ -89,6 +89,28 @@ withFixture('basic', (c) => {
89
89
end : { line : 2 , character : 18 } ,
90
90
} ,
91
91
} )
92
+
93
+ testHover ( 'showPixelEquivalents works with theme()' , {
94
+ lang : 'tailwindcss' ,
95
+ text : `.foo { font-size: theme(fontSize.xl) }` ,
96
+ position : { line : 0 , character : 32 } ,
97
+
98
+ exact : true ,
99
+ expected : {
100
+ contents : {
101
+ kind : 'markdown' ,
102
+ value : [
103
+ '```plaintext' ,
104
+ '1.25rem /* 20px */' ,
105
+ '```' ,
106
+ ] . join ( '\n' ) ,
107
+ } ,
108
+ range : {
109
+ start : { line : 0 , character : 24 } ,
110
+ end : { line : 0 , character : 35 } ,
111
+ }
112
+ } ,
113
+ } )
92
114
} )
93
115
94
116
withFixture ( 'v4/basic' , ( c ) => {
@@ -146,7 +168,7 @@ withFixture('v4/basic', (c) => {
146
168
// testHover('arbitrary value with theme function', {
147
169
// text: '<div class="p-[theme(spacing.4)]">',
148
170
// position: { line: 0, character: 13 },
149
- // expected: '.p-\\[theme\\(spacing\\.4\\)\\] {\n' + ' padding: 1rem/* 16px */;\n' + '}',
171
+ // expected: '.p-\\[theme\\(spacing\\.4\\)\\] {\n' + ' padding: 1rem /* 16px */;\n' + '}',
150
172
// expectedRange: {
151
173
// start: { line: 0, character: 12 },
152
174
// end: { line: 0, character: 32 },
0 commit comments