Skip to content

Commit 7b89ced

Browse files
committed
Rewrite some tests using the new setup
1 parent 8886a12 commit 7b89ced

File tree

1 file changed

+119
-48
lines changed

1 file changed

+119
-48
lines changed

packages/tailwindcss-language-server/src/project-locator.test.ts

Lines changed: 119 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { ProjectLocator } from './project-locator'
44
import { URL, fileURLToPath } from 'url'
55
import { Settings } from '@tailwindcss/language-service/src/util/state'
66
import { createResolver } from './resolver'
7-
import { css, defineTest, js, json, scss, Storage, TestUtils } from './testing'
7+
import { css, defineTest, html, js, json, scss, Storage, symlinkTo, TestUtils } from './testing'
88
import { normalizePath } from './utils'
99

1010
let settings: Settings = {
@@ -141,58 +141,129 @@ testFixture('v4/workspaces', [
141141
},
142142
])
143143

144-
testFixture('v4/auto-content', [
145-
//
146-
{
147-
config: 'src/app.css',
148-
content: [
149-
'{URL}/*',
150-
'{URL}/package.json',
151-
'{URL}/src/index.html',
152-
'{URL}/src/components/example.html',
153-
'{URL}/src/**/*.{aspx,astro,cjs,cts,eex,erb,gjs,gts,haml,handlebars,hbs,heex,html,jade,js,jsx,liquid,md,mdx,mjs,mts,mustache,njk,nunjucks,php,pug,py,razor,rb,rhtml,rs,slim,svelte,tpl,ts,tsx,twig,vue}',
154-
],
144+
testLocator({
145+
name: 'automatic content detection with Oxide',
146+
fs: {
147+
'package.json': json`
148+
{
149+
"dependencies": {
150+
"tailwindcss": "^4.0.15",
151+
"@tailwindcss/oxide": "^4.0.15"
152+
}
153+
}
154+
`,
155+
'src/index.html': html`<div class="flex">Test</div>`,
156+
'src/app.css': css`
157+
@import 'tailwindcss';
158+
`,
159+
'src/components/example.html': html`<div class="underline">Test</div>`,
155160
},
156-
])
161+
expected: [
162+
{
163+
config: '/src/app.css',
164+
content: [
165+
'/*',
166+
'/package.json',
167+
'/src/**/*.{aspx,astro,cjs,cts,eex,erb,gjs,gts,haml,handlebars,hbs,heex,html,jade,js,jsx,liquid,md,mdx,mjs,mts,mustache,njk,nunjucks,php,pug,py,razor,rb,rhtml,rs,slim,svelte,tpl,ts,tsx,twig,vue}',
168+
'/src/components/example.html',
169+
'/src/index.html',
170+
],
171+
},
172+
],
173+
})
157174

158-
testFixture('v4/auto-content-split', [
159-
{
160-
config: 'src/app.css',
161-
content: [
162-
'{URL}/*',
163-
'{URL}/package.json',
164-
'{URL}/src/index.html',
165-
'{URL}/src/components/example.html',
166-
'{URL}/src/**/*.{aspx,astro,cjs,cts,eex,erb,gjs,gts,haml,handlebars,hbs,heex,html,jade,js,jsx,liquid,md,mdx,mjs,mts,mustache,njk,nunjucks,php,pug,py,razor,rb,rhtml,rs,slim,svelte,tpl,ts,tsx,twig,vue}',
167-
],
175+
testLocator({
176+
name: 'automatic content detection with Oxide using split config',
177+
fs: {
178+
'package.json': json`
179+
{
180+
"dependencies": {
181+
"tailwindcss": "^4.0.15",
182+
"@tailwindcss/oxide": "^4.0.15"
183+
}
184+
}
185+
`,
186+
'src/index.html': html`<div class="flex">Test</div>`,
187+
'src/app.css': css`
188+
@import 'tailwindcss/preflight' layer(base);
189+
@import 'tailwindcss/theme' layer(theme);
190+
@import 'tailwindcss/utilities' layer(utilities);
191+
`,
192+
'src/components/example.html': html`<div class="underline">Test</div>`,
168193
},
169-
])
194+
expected: [
195+
{
196+
config: '/src/app.css',
197+
content: [
198+
'/*',
199+
'/package.json',
200+
'/src/**/*.{aspx,astro,cjs,cts,eex,erb,gjs,gts,haml,handlebars,hbs,heex,html,jade,js,jsx,liquid,md,mdx,mjs,mts,mustache,njk,nunjucks,php,pug,py,razor,rb,rhtml,rs,slim,svelte,tpl,ts,tsx,twig,vue}',
201+
'/src/components/example.html',
202+
'/src/index.html',
203+
],
204+
},
205+
],
206+
})
170207

171-
testFixture('v4/custom-source', [
172-
//
173-
{
174-
config: 'admin/app.css',
175-
content: [
176-
'{URL}/*',
177-
'{URL}/admin/foo.bin',
178-
'{URL}/admin/{**/*.bin,**/*.{aspx,astro,cjs,cts,eex,erb,gjs,gts,haml,handlebars,hbs,heex,html,jade,js,jsx,liquid,md,mdx,mjs,mts,mustache,njk,nunjucks,php,pug,py,razor,rb,rhtml,rs,slim,svelte,tpl,ts,tsx,twig,vue}}',
179-
'{URL}/package.json',
180-
'{URL}/shared.html',
181-
'{URL}/web/**/*.{aspx,astro,cjs,cts,eex,erb,gjs,gts,haml,handlebars,hbs,heex,html,jade,js,jsx,liquid,md,mdx,mjs,mts,mustache,njk,nunjucks,php,pug,py,razor,rb,rhtml,rs,slim,svelte,tpl,ts,tsx,twig,vue}',
182-
],
183-
},
184-
{
185-
config: 'web/app.css',
186-
content: [
187-
'{URL}/*',
188-
'{URL}/admin/**/*.{aspx,astro,cjs,cts,eex,erb,gjs,gts,haml,handlebars,hbs,heex,html,jade,js,jsx,liquid,md,mdx,mjs,mts,mustache,njk,nunjucks,php,pug,py,razor,rb,rhtml,rs,slim,svelte,tpl,ts,tsx,twig,vue}',
189-
'{URL}/package.json',
190-
'{URL}/shared.html',
191-
'{URL}/web/bar.bin',
192-
'{URL}/web/{**/*.{aspx,astro,cjs,cts,eex,erb,gjs,gts,haml,handlebars,hbs,heex,html,jade,js,jsx,liquid,md,mdx,mjs,mts,mustache,njk,nunjucks,php,pug,py,razor,rb,rhtml,rs,slim,svelte,tpl,ts,tsx,twig,vue},*.bin}',
193-
],
208+
testLocator({
209+
name: 'automatic content detection with custom sources',
210+
fs: {
211+
'package.json': json`
212+
{
213+
"dependencies": {
214+
"tailwindcss": "^4.0.15",
215+
"@tailwindcss/oxide": "^4.0.15"
216+
}
217+
}
218+
`,
219+
'admin/app.css': css`
220+
@import './tw.css';
221+
@import './ui.css';
222+
`,
223+
'admin/tw.css': css`
224+
@import 'tailwindcss';
225+
@source './**/*.bin';
226+
`,
227+
'admin/ui.css': css`
228+
@theme {
229+
--color-potato: #907a70;
230+
}
231+
`,
232+
'admin/foo.bin': html`<p class="underline">Admin</p>`,
233+
234+
'web/app.css': css`
235+
@import 'tailwindcss';
236+
@source './*.bin';
237+
`,
238+
'web/bar.bin': html`<p class="underline">Web</p>`,
239+
240+
'shared.html': html`<p>I belong to no one!</p>`,
194241
},
195-
])
242+
expected: [
243+
{
244+
config: '/admin/app.css',
245+
content: [
246+
'/*',
247+
'/admin/foo.bin',
248+
'/admin/{**/*.bin,**/*.{aspx,astro,cjs,cts,eex,erb,gjs,gts,haml,handlebars,hbs,heex,html,jade,js,jsx,liquid,md,mdx,mjs,mts,mustache,njk,nunjucks,php,pug,py,razor,rb,rhtml,rs,slim,svelte,tpl,ts,tsx,twig,vue}}',
249+
'/package.json',
250+
'/shared.html',
251+
'/web/**/*.{aspx,astro,cjs,cts,eex,erb,gjs,gts,haml,handlebars,hbs,heex,html,jade,js,jsx,liquid,md,mdx,mjs,mts,mustache,njk,nunjucks,php,pug,py,razor,rb,rhtml,rs,slim,svelte,tpl,ts,tsx,twig,vue}',
252+
],
253+
},
254+
{
255+
config: '/web/app.css',
256+
content: [
257+
'/*',
258+
'/admin/**/*.{aspx,astro,cjs,cts,eex,erb,gjs,gts,haml,handlebars,hbs,heex,html,jade,js,jsx,liquid,md,mdx,mjs,mts,mustache,njk,nunjucks,php,pug,py,razor,rb,rhtml,rs,slim,svelte,tpl,ts,tsx,twig,vue}',
259+
'/package.json',
260+
'/shared.html',
261+
'/web/bar.bin',
262+
'/web/{**/*.{aspx,astro,cjs,cts,eex,erb,gjs,gts,haml,handlebars,hbs,heex,html,jade,js,jsx,liquid,md,mdx,mjs,mts,mustache,njk,nunjucks,php,pug,py,razor,rb,rhtml,rs,slim,svelte,tpl,ts,tsx,twig,vue},*.bin}',
263+
],
264+
},
265+
],
266+
})
196267

197268
testFixture('v4/missing-files', [
198269
//

0 commit comments

Comments
 (0)