-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
44 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import ClassUtils from '../../src/utils/class' | ||
|
||
import { IHtmlNode } from '../../src/interfaces/html-node' | ||
import { ITwToSassOptions } from '../../src/interfaces/tw-to-sass-options' | ||
|
||
test('class utility get class name', () => { | ||
const node = <IHtmlNode>{ | ||
tagName: 'div', | ||
comment: 'Some Div', | ||
hasElementChildren: false, | ||
}, | ||
expected = '.pre_some_div_suf' | ||
|
||
const converterConfigs = <ITwToSassOptions>{ | ||
useCommentBlocksAsClassName: true, | ||
printSassComments: true, | ||
orderByTailwindClasses: false, | ||
classNameOptions: { | ||
lowercase: true, | ||
replacement: '_', | ||
prefix: 'pre_', | ||
suffix: '_suf', | ||
}, | ||
} | ||
|
||
const result = ClassUtils.getClassName(node, 1, converterConfigs) | ||
|
||
expect(expected).toBe(result) | ||
}) | ||
|
||
test('class utility order utility classes', () => { | ||
const content = | ||
'flex items-center justify-center w-full px-4 py-2 space-x-1 font-medium tracking-wider uppercase bg-gray-100 border rounded-md focus:outline-none focus:ring', | ||
result = | ||
'bg-gray-100 border flex focus:outline-none focus:ring font-medium items-center justify-center px-4 py-2 rounded-md space-x-1 tracking-wider uppercase w-full' | ||
|
||
expect(ClassUtils.orderClasses(content)).toBe(result) | ||
}) |