-
Notifications
You must be signed in to change notification settings - Fork 3
/
test.tsx
66 lines (54 loc) · 1.41 KB
/
test.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import { suite } from 'uvu'
import * as assert from 'uvu/assert'
import type { Instance } from 'twind'
import type { VirtualSheet } from 'twind/sheets'
import * as React from 'react'
import { renderToStaticMarkup as render } from 'react-dom/server'
import { virtualSheet } from 'twind/sheets'
import { create, styled } from '.'
const test = suite<{
sheet: VirtualSheet
tw: Instance['tw']
styled: typeof styled
}>('@twind/react')
test.before((context) => {
context.sheet = virtualSheet()
const { tw } = create({
sheet: context.sheet,
mode: 'strict',
preflight: false,
prefix: false,
})
context.tw = tw
context.styled = styled.bind(tw) as typeof styled
})
test.after.each(({ sheet }) => {
sheet.reset()
})
test('styled', ({ sheet, styled }) => {
const Button = styled('button', {
variants: {
size: {
sm: `text-sm`,
lg: `text-lg`,
},
},
})
assert.equal(sheet.target, [])
const markup = render(
<Button size="lg" class="x" type="button">
Click Me
</Button>,
)
assert.is(markup, '<button type="button" class="tw-xz6gsm tw-jo04kc x">Click Me</button>')
assert.equal(sheet.target, ['.tw-xz6gsm{font-size:1.125rem;line-height:1.75rem}'])
// const ExtendedButton = styled(Button, {
// variants: {
// rounded: {
// true: `rounded-full`,
// },
// },
// })
// ExtendedButton({ as: 'button', })
})
test.run()