|
1 | 1 | import { test } from 'vitest'
|
2 | 2 | import { findClassListsInHtmlRange } from './find'
|
3 |
| -import { js, html, createDocument } from './test-utils' |
| 3 | +import { js, html, pug, createDocument } from './test-utils' |
4 | 4 |
|
5 | 5 | test('class regex works in astro', async ({ expect }) => {
|
6 | 6 | let file = createDocument({
|
@@ -735,3 +735,59 @@ test('classAttributes find class lists inside variables in JS(X)/TS(X)', async (
|
735 | 735 | },
|
736 | 736 | ])
|
737 | 737 | })
|
| 738 | + |
| 739 | +test('classAttributes find class lists inside pug', async ({ expect }) => { |
| 740 | + let file = createDocument({ |
| 741 | + name: 'file.pug', |
| 742 | + lang: 'pug', |
| 743 | + settings: { |
| 744 | + tailwindCSS: { |
| 745 | + classAttributes: ['className'], |
| 746 | + }, |
| 747 | + }, |
| 748 | + content: pug` |
| 749 | + div(classNAme="relative flex") |
| 750 | + `, |
| 751 | + }) |
| 752 | + |
| 753 | + let classLists = await findClassListsInHtmlRange(file.state, file.doc, 'js') |
| 754 | + |
| 755 | + expect(classLists).toEqual([ |
| 756 | + { |
| 757 | + classList: 'relative flex', |
| 758 | + range: { |
| 759 | + start: { line: 0, character: 15 }, |
| 760 | + end: { line: 0, character: 28 }, |
| 761 | + }, |
| 762 | + }, |
| 763 | + ]) |
| 764 | +}) |
| 765 | + |
| 766 | +test('classAttributes find class lists inside Vue bindings', async ({ expect }) => { |
| 767 | + let file = createDocument({ |
| 768 | + name: 'file.pug', |
| 769 | + lang: 'vue', |
| 770 | + settings: { |
| 771 | + tailwindCSS: { |
| 772 | + classAttributes: ['class'], |
| 773 | + }, |
| 774 | + }, |
| 775 | + content: html` |
| 776 | + <template> |
| 777 | + <div :class="{'relative flex': true}"></div> |
| 778 | + </template> |
| 779 | + `, |
| 780 | + }) |
| 781 | + |
| 782 | + let classLists = await findClassListsInHtmlRange(file.state, file.doc, 'js') |
| 783 | + |
| 784 | + expect(classLists).toEqual([ |
| 785 | + { |
| 786 | + classList: 'relative flex', |
| 787 | + range: { |
| 788 | + start: { line: 1, character: 17 }, |
| 789 | + end: { line: 1, character: 30 }, |
| 790 | + }, |
| 791 | + }, |
| 792 | + ]) |
| 793 | +}) |
0 commit comments