-
-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #214 from dcastil/feature/211/add-support-for-post…
…fix-modifier Add support for postfix modifier
- Loading branch information
Showing
11 changed files
with
163 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,38 @@ | ||
import { twMerge } from '../src' | ||
import { createTailwindMerge, twMerge } from '../src' | ||
|
||
test('conflicts across modifiers', () => { | ||
test('conflicts across prefix modifiers', () => { | ||
expect(twMerge('hover:block hover:inline')).toBe('hover:inline') | ||
expect(twMerge('hover:block hover:focus:inline')).toBe('hover:block hover:focus:inline') | ||
expect(twMerge('hover:block hover:focus:inline focus:hover:inline')).toBe( | ||
'hover:block focus:hover:inline', | ||
) | ||
expect(twMerge('focus-within:inline focus-within:block')).toBe('focus-within:block') | ||
}) | ||
|
||
test('conflicts across postfix modifiers', () => { | ||
expect(twMerge('text-lg/7 text-lg/8')).toBe('text-lg/8') | ||
expect(twMerge('text-lg/none leading-9')).toBe('text-lg/none leading-9') | ||
expect(twMerge('leading-9 text-lg/none')).toBe('text-lg/none') | ||
expect(twMerge('w-full w-1/2')).toBe('w-1/2') | ||
|
||
const customTwMerge = createTailwindMerge(() => ({ | ||
cacheSize: 10, | ||
theme: {}, | ||
classGroups: { | ||
foo: ['foo-1/2', 'foo-2/3'], | ||
bar: ['bar-1', 'bar-2'], | ||
baz: ['baz-1', 'baz-2'], | ||
}, | ||
conflictingClassGroups: {}, | ||
conflictingClassGroupModifiers: { | ||
baz: ['bar'], | ||
}, | ||
})) | ||
|
||
expect(customTwMerge('foo-1/2 foo-2/3')).toBe('foo-2/3') | ||
expect(customTwMerge('bar-1 bar-2')).toBe('bar-2') | ||
expect(customTwMerge('bar-1 baz-1')).toBe('bar-1 baz-1') | ||
expect(customTwMerge('bar-1/2 bar-2')).toBe('bar-2') | ||
expect(customTwMerge('bar-2 bar-1/2')).toBe('bar-1/2') | ||
expect(customTwMerge('bar-1 baz-1/2')).toBe('baz-1/2') | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters