Skip to content

Commit e15e4ff

Browse files
committed
refactor: move to packages
1 parent 5a81ec6 commit e15e4ff

2 files changed

Lines changed: 26 additions & 19 deletions

File tree

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { createGenerator } from '@unocss/core'
2+
import MagicString from 'magic-string'
3+
import { describe, expect, it } from 'vitest'
4+
import { attributifyJsxOxcResolver } from '../src/resolver/oxc'
5+
6+
describe('resolver-oxc', async () => {
7+
const uno = await createGenerator()
8+
9+
it('error', async () => {
10+
const errorCode = '<d iv></div>'
11+
const code = new MagicString(errorCode)
12+
const transform = attributifyJsxOxcResolver({ code, id: 'app.tsx', uno: { uno, tokens: new Set() } as any, isBlocked: () => false })
13+
await expect(transform).rejects.toThrowErrorMatchingInlineSnapshot(`
14+
[Error: Oxc parse errors:
15+
16+
x Expected corresponding JSX closing tag for 'd'.
17+
,-[app.tsx:1:9]
18+
1 | <d iv></div>
19+
: | ^|^
20+
: | \`-- Expected \`</d>\`
21+
: \`-- Opened here
22+
\`----
23+
]
24+
`)
25+
})
26+
})

test/transformer-attributify-jsx.test.ts

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import presetWind3 from '@unocss/preset-wind3'
44
import transformerAttributifyJsx from '@unocss/transformer-attributify-jsx'
55
import MagicString from 'magic-string'
66
import { describe, expect, it } from 'vitest'
7-
import { attributifyJsxOxcResolver } from '../packages-presets/transformer-attributify-jsx/src/resolver/oxc'
87

98
const originalCode = `
109
<div h-full text-center flex select-none className={red ? 'text-red': 'text-green'}>
@@ -284,22 +283,4 @@ describe('transformerAttributifyJsx', async () => {
284283
/>"
285284
`)
286285
})
287-
288-
it('oxc error', async () => {
289-
const errorCode = '<d iv></div>'
290-
const code = new MagicString(errorCode)
291-
const transform = attributifyJsxOxcResolver({ code, id: 'app.tsx', uno: { uno, tokens: new Set() } as any, isBlocked: () => false })
292-
await expect(transform).rejects.toThrowErrorMatchingInlineSnapshot(`
293-
[Error: Oxc parse errors:
294-
295-
x Expected corresponding JSX closing tag for 'd'.
296-
,-[app.tsx:1:9]
297-
1 | <d iv></div>
298-
: | ^|^
299-
: | \`-- Expected \`</d>\`
300-
: \`-- Opened here
301-
\`----
302-
]
303-
`)
304-
})
305286
})

0 commit comments

Comments
 (0)