4
4
type CustomizationFontDefinition ,
5
5
generateFontFacesCSS ,
6
6
getFontSourcesToPreload ,
7
- } from './customFonts ' ;
7
+ } from './custom ' ;
8
8
9
9
const TEST_FONTS = {
10
10
basic : {
@@ -15,7 +15,7 @@ const TEST_FONTS = {
15
15
weight : 400 ,
16
16
sources : [
17
17
{
18
- url : new URL ( 'https://example.com/fonts/opensans-regular.woff2' ) ,
18
+ url : 'https://example.com/fonts/opensans-regular.woff2' ,
19
19
format : 'woff2' ,
20
20
} ,
21
21
] ,
@@ -24,7 +24,7 @@ const TEST_FONTS = {
24
24
weight : 700 ,
25
25
sources : [
26
26
{
27
- url : new URL ( 'https://example.com/fonts/opensans-bold.woff2' ) ,
27
+ url : 'https://example.com/fonts/opensans-bold.woff2' ,
28
28
format : 'woff2' ,
29
29
} ,
30
30
] ,
@@ -40,7 +40,7 @@ const TEST_FONTS = {
40
40
weight : 300 ,
41
41
sources : [
42
42
{
43
- url : new URL ( 'https://example.com/fonts/roboto-light.woff2' ) ,
43
+ url : 'https://example.com/fonts/roboto-light.woff2' ,
44
44
format : 'woff2' ,
45
45
} ,
46
46
] ,
@@ -49,7 +49,7 @@ const TEST_FONTS = {
49
49
weight : 400 ,
50
50
sources : [
51
51
{
52
- url : new URL ( 'https://example.com/fonts/roboto-regular.woff2' ) ,
52
+ url : 'https://example.com/fonts/roboto-regular.woff2' ,
53
53
format : 'woff2' ,
54
54
} ,
55
55
] ,
@@ -58,7 +58,7 @@ const TEST_FONTS = {
58
58
weight : 500 ,
59
59
sources : [
60
60
{
61
- url : new URL ( 'https://example.com/fonts/roboto-medium.woff2' ) ,
61
+ url : 'https://example.com/fonts/roboto-medium.woff2' ,
62
62
format : 'woff2' ,
63
63
} ,
64
64
] ,
@@ -67,7 +67,7 @@ const TEST_FONTS = {
67
67
weight : 700 ,
68
68
sources : [
69
69
{
70
- url : new URL ( 'https://example.com/fonts/roboto-bold.woff2' ) ,
70
+ url : 'https://example.com/fonts/roboto-bold.woff2' ,
71
71
format : 'woff2' ,
72
72
} ,
73
73
] ,
@@ -76,7 +76,7 @@ const TEST_FONTS = {
76
76
weight : 900 ,
77
77
sources : [
78
78
{
79
- url : new URL ( 'https://example.com/fonts/roboto-black.woff2' ) ,
79
+ url : 'https://example.com/fonts/roboto-black.woff2' ,
80
80
format : 'woff2' ,
81
81
} ,
82
82
] ,
@@ -92,10 +92,10 @@ const TEST_FONTS = {
92
92
weight : 400 ,
93
93
sources : [
94
94
{
95
- url : new URL ( 'https://example.com/fonts/lato-regular.woff2' ) ,
95
+ url : 'https://example.com/fonts/lato-regular.woff2' ,
96
96
format : 'woff2' ,
97
97
} ,
98
- { url : new URL ( 'https://example.com/fonts/lato-regular.woff' ) , format : 'woff' } ,
98
+ { url : 'https://example.com/fonts/lato-regular.woff' , format : 'woff' } ,
99
99
] ,
100
100
} ,
101
101
] ,
@@ -108,9 +108,9 @@ const TEST_FONTS = {
108
108
{
109
109
weight : 400 ,
110
110
sources : [
111
- { url : new URL ( 'https://example.com/fonts/sourcesans-regular.woff2' ) } ,
111
+ { url : 'https://example.com/fonts/sourcesans-regular.woff2' } ,
112
112
{
113
- url : new URL ( 'https://example.com/fonts/sourcesans-regular.woff' ) ,
113
+ url : 'https://example.com/fonts/sourcesans-regular.woff' ,
114
114
format : 'woff' ,
115
115
} ,
116
116
] ,
@@ -130,9 +130,7 @@ const TEST_FONTS = {
130
130
fontFaces : [
131
131
{
132
132
weight : 400 ,
133
- sources : [
134
- { url : new URL ( 'https://example.com/fonts/special.woff2' ) , format : 'woff2' } ,
135
- ] ,
133
+ sources : [ { url : 'https://example.com/fonts/special.woff2' , format : 'woff2' } ] ,
136
134
} ,
137
135
] ,
138
136
} as CustomizationFontDefinition ,
@@ -144,15 +142,15 @@ const TEST_FONTS = {
144
142
{
145
143
weight : 400 ,
146
144
sources : [
147
- { url : new URL ( 'https://example.com/fonts/regular.woff2' ) } ,
148
- { url : new URL ( 'https://example.com/fonts/regular.woff' ) } ,
145
+ { url : 'https://example.com/fonts/regular.woff2' } ,
146
+ { url : 'https://example.com/fonts/regular.woff' } ,
149
147
] ,
150
148
} ,
151
149
{
152
150
weight : 700 ,
153
151
sources : [
154
- { url : new URL ( 'https://example.com/fonts/bold.woff2' ) } ,
155
- { url : new URL ( 'https://example.com/fonts/bold.woff' ) } ,
152
+ { url : 'https://example.com/fonts/bold.woff2' } ,
153
+ { url : 'https://example.com/fonts/bold.woff' } ,
156
154
] ,
157
155
} ,
158
156
] ,
@@ -165,9 +163,9 @@ const TEST_FONTS = {
165
163
{
166
164
weight : 400 ,
167
165
sources : [
168
- { url : new URL ( 'https://example.com/fonts/absolute .woff2' ) } ,
169
- { url : new URL ( '/fonts/relative.woff2' , ' https://example.com' ) } ,
170
- { url : new URL ( './fonts/path-relative.woff2' , ' https://example.com' ) } ,
166
+ { url : 'https://example.com/fonts/1 .woff2' } ,
167
+ { url : ' https://example.com/fonts/2.woff2' } ,
168
+ { url : ' https://example.com/fonts/3.woff2' } ,
171
169
] ,
172
170
} ,
173
171
] ,
@@ -292,8 +290,8 @@ describe('getCustomFontPreloadLinks', () => {
292
290
293
291
expect ( result ) . toBeArray ( ) ;
294
292
expect ( result . length ) . toBe ( 3 ) ;
295
- expect ( result ) . toContain ( 'https://example.com/fonts/absolute .woff2' ) ;
296
- expect ( result ) . toContain ( 'https://example.com/fonts/relative .woff2' ) ;
297
- expect ( result ) . toContain ( 'https://example.com/fonts/path-relative .woff2' ) ;
293
+ expect ( result ) . toContain ( 'https://example.com/fonts/1 .woff2' ) ;
294
+ expect ( result ) . toContain ( 'https://example.com/fonts/2 .woff2' ) ;
295
+ expect ( result ) . toContain ( 'https://example.com/fonts/3 .woff2' ) ;
298
296
} ) ;
299
297
} ) ;
0 commit comments