Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
add failing tests
  • Loading branch information
RobinMalfait committed Jan 23, 2025
commit f64cbcf57949e6c5d5bcdef69f7737f277d2cc85
16 changes: 16 additions & 0 deletions packages/tailwindcss/src/candidate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,13 @@ it('should parse a utility with an arbitrary value with parens', () => {
`)
})

it('should not parse a utility with an arbitrary value with parens that does not start with --', () => {
let utilities = new Utilities()
utilities.functional('bg', () => [])

expect(run('bg-(my-color)', { utilities })).toMatchInlineSnapshot(`[]`)
})

it('should parse a utility with an arbitrary value including a typehint', () => {
let utilities = new Utilities()
utilities.functional('bg', () => [])
Expand Down Expand Up @@ -616,6 +623,13 @@ it('should parse a utility with an arbitrary value with parens including a typeh
`)
})

it('should not parse a utility with an arbitrary value with parens including a typehint that does not start with --', () => {
let utilities = new Utilities()
utilities.functional('bg', () => [])

expect(run('bg-(color:my-color)', { utilities })).toMatchInlineSnapshot(`[]`)
})

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add tests for stuff like bg-foo/(bar) to make sure it's thrown out too

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah good call!

it('should parse a utility with an arbitrary value with parens and a fallback', () => {
let utilities = new Utilities()
utilities.functional('bg', () => [])
Expand Down Expand Up @@ -888,6 +902,8 @@ it('should not parse invalid arbitrary values in variants', () => {

'data-foo-(--value)/(number:--mod):flex',
'data-foo(--value)/(number:--mod):flex',

'data-(value):flex',
]) {
expect(run(candidate, { utilities, variants })).toEqual([])
}
Expand Down