forked from unjs/unifont
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathextract.test.ts
61 lines (60 loc) · 1.78 KB
/
extract.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import { describe, expect, it } from 'vitest'
import { extractFontFaceData } from '../src/css/parse'
describe('extract font face from CSS', () => {
it('should add declarations for `font-family`', async () => {
expect(extractFontFaceData(`
@font-face {
font-family: 'Open Sans';
font-style: normal;
font-display: swap;
font-weight: 500;
src: local("Open Sans"), url(./files/open-sans-latin-500-normal.woff2) format('woff2'), url(./files/open-sans-latin-500-normal.woff) format('woff');
unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+2074,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}
`))
.toMatchInlineSnapshot(`
[
{
"display": "swap",
"src": [
{
"name": "Open Sans",
},
{
"format": "woff2",
"url": "./files/open-sans-latin-500-normal.woff2",
},
{
"format": "woff",
"url": "./files/open-sans-latin-500-normal.woff",
},
],
"style": "normal",
"unicodeRange": [
"U+0000-00FF",
"U+0131",
"U+0152-0153",
"U+02BB-02BC",
"U+02C6",
"U+02DA",
"U+02DC",
"U+0304",
"U+0308",
"U+0329",
"U+2000-206F",
"U+2074",
"U+20AC",
"U+2122",
"U+2191",
"U+2193",
"U+2212",
"U+2215",
"U+FEFF",
"U+FFFD",
],
"weight": 500,
},
]
`)
})
})