-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpreset-px-to-rem.test.ts
42 lines (38 loc) · 1.28 KB
/
preset-px-to-rem.test.ts
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
import { expect, test } from 'vitest'
import { createGenerator } from '@unocss/core'
import pxToVwPreset from './src/index'
import presetMini from '@unocss/preset-mini'
import presetRemToPx from '@unocss/preset-rem-to-px'
const fixture = `<div class="text-red text-12px">hello</div>`
const uno = createGenerator({
presets: [
presetMini(),
presetRemToPx(),
pxToVwPreset({
viewportWidth: 1920,
})
]
})
test('should works', async () => {
expect((await uno.generate(new Set(['m4', 'mx2', '-p2', 'gap2', '-w-0.5px', 'w-1']), { preflights: false })).css)
.toMatchInlineSnapshot(`
"/* layer: default */
.-p2{padding:-0.417vw;}
.m4{margin:0.833vw;}
.mx2{margin-left:0.417vw;margin-right:0.417vw;}
.gap2{gap:0.417vw;}
.-w-0\\\\.5px{width:-0.5px;}
.w-1{width:0.208vw;}"
`)
})
test('important prefix should works', async () => {
expect((await uno.generate(new Set(['!m4', '!mx2', '!-p2', '!gap2', '!w-0.5px',]), { preflights: false })).css)
.toMatchInlineSnapshot(`
"/* layer: default */
.\\\\!-p2{padding:-0.417vw !important;}
.\\\\!m4{margin:0.833vw !important;}
.\\\\!mx2{margin-left:0.417vw !important;margin-right:0.417vw !important;}
.\\\\!gap2{gap:0.417vw !important;}
.\\\\!w-0\\\\.5px{width:0.5px !important;}"
`)
})