Skip to content

Commit d51babe

Browse files
Update tests
1 parent 0e131d4 commit d51babe

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

packages/tailwindcss/src/css-functions.test.ts

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ describe('--theme(…)', () => {
218218
`)
219219
})
220220

221-
test('--theme(…) contains the fallback when the default namespace is unset and a prior `--theme(…)` function contains `initial`', async () => {
221+
test('--theme(…) injects the fallback when the value it refers is set to a `--theme(…)` function containing `initial`', async () => {
222222
expect(
223223
await compileCss(css`
224224
@theme prefix(tw) {
@@ -235,7 +235,7 @@ describe('--theme(…)', () => {
235235
`)
236236
})
237237

238-
test('--theme(…) contains the fallback when the default namespace is unset and a prior `--theme(…)` function contains `initial` in @reference', async () => {
238+
test('--theme(…) injects the fallback when the value it refers is set to a `--theme(…)` function containing `initial` in @reference mode', async () => {
239239
expect(
240240
await compileCss(css`
241241
@theme reference prefix(tw) {
@@ -252,7 +252,7 @@ describe('--theme(…)', () => {
252252
`)
253253
})
254254

255-
test('--theme(…) returns the fallback when the default namespace is unset and a prior `--theme(…)` function returns `initial` as inline value', async () => {
255+
test('--theme(…) returns the fallback when the value it refers is set to a `--theme(…)` function that returns `initial` as inline value', async () => {
256256
expect(
257257
await compileCss(css`
258258
@theme prefix(tw) {
@@ -269,7 +269,7 @@ describe('--theme(…)', () => {
269269
`)
270270
})
271271

272-
test('--theme(…) returns the fallback when the default namespace is unset in @reference mode', async () => {
272+
test('--theme(…) returns the fallback when the value it refers is set to a `--theme(…)` function that returns `initial` as inline value in @reference mode', async () => {
273273
expect(
274274
await compileCss(css`
275275
@theme reference prefix(tw) {
@@ -286,7 +286,7 @@ describe('--theme(…)', () => {
286286
`)
287287
})
288288

289-
test.only('--theme(…) does not inject the fallback if the fallback is `initial`', async () => {
289+
test('--theme(…) does not inject the fallback if the fallback is `initial`', async () => {
290290
expect(
291291
await compileCss(
292292
css`
@@ -323,7 +323,7 @@ describe('--theme(…)', () => {
323323
`)
324324
})
325325

326-
test('--theme(…) forces the value to be retrieved as inline when used inside an at rule', async () => {
326+
test('--theme(…) forces the value to be retrieved as inline when used inside an at-rule', async () => {
327327
expect(
328328
await compileCss(css`
329329
@theme {
@@ -357,7 +357,7 @@ describe('--theme(…)', () => {
357357
`)
358358
})
359359

360-
test('--theme(…) can only be used with CSS variables from your theme', async () => {
360+
test('--theme(…) can only be used with CSS variables from your @theme', async () => {
361361
expect(() =>
362362
compileCss(css`
363363
@theme {
@@ -370,6 +370,19 @@ describe('--theme(…)', () => {
370370
).rejects.toThrowErrorMatchingInlineSnapshot(
371371
`[Error: The --theme(…) function can only be used with CSS variables from your theme.]`,
372372
)
373+
374+
expect(() =>
375+
compileCss(css`
376+
@theme {
377+
--color-red-500: #f00;
378+
}
379+
.red {
380+
color: --theme(--color-green-500);
381+
}
382+
`),
383+
).rejects.toThrowErrorMatchingInlineSnapshot(
384+
`[Error: Could not resolve value for theme function: \`theme(--color-green-500)\`. Consider checking if the variable name is correct or provide a fallback value to silence this error.]`,
385+
)
373386
})
374387
})
375388

0 commit comments

Comments
 (0)