@@ -3,11 +3,53 @@ import { renderHook } from '@testing-library/react';
3
3
import useParagonThemeUrls from './useParagonThemeUrls' ;
4
4
import { mergeConfig } from '../../../config' ;
5
5
6
+ Object . defineProperty ( global , 'PARAGON_THEME' , {
7
+ value : {
8
+ paragon : {
9
+ version : '1.0.0' ,
10
+ themeUrls : {
11
+ core : {
12
+ fileName : 'local-core.min.css' ,
13
+ } ,
14
+ defaults : {
15
+ light : 'light' ,
16
+ } ,
17
+ variants : {
18
+ light : {
19
+ fileName : 'local-light.min.css' ,
20
+ } ,
21
+ } ,
22
+ } ,
23
+ } ,
24
+ brand : {
25
+ version : '1.0.0' ,
26
+ themeUrls : {
27
+ core : {
28
+ fileName : 'brand-local-core.min.css' ,
29
+ } ,
30
+ defaults : {
31
+ light : 'light' ,
32
+ } ,
33
+ variants : {
34
+ light : {
35
+ fileName : 'brand-local-light.min.css' ,
36
+ } ,
37
+ } ,
38
+ } ,
39
+ } ,
40
+ } ,
41
+ writable : true ,
42
+ } ) ;
43
+
6
44
describe ( 'useParagonThemeUrls' , ( ) => {
7
45
beforeEach ( ( ) => { jest . resetAllMocks ( ) ; } ) ;
8
46
it . each ( [
9
47
[ undefined , undefined ] ,
10
- [ { } , { core : { urls : { default : '//localhost:8080/core.min.css' , brandOverride : undefined } } , defaults : { light : 'light' } , variants : { light : { urls : { default : '//localhost:8080/light.min.css' } } } } ] ,
48
+ [ { } , {
49
+ core : { urls : { default : '//localhost:8080/local-core.min.css' , brandOverride : '//localhost:8080/brand-local-core.min.css' } } ,
50
+ defaults : { light : 'light' } ,
51
+ variants : { light : { urls : { default : '//localhost:8080/local-light.min.css' , brandOverride : '//localhost:8080/brand-local-light.min.css' } } } ,
52
+ } ] ,
11
53
] ) ( 'handles when `config.PARAGON_THEME_URLS` is not present (%s)' , ( paragonThemeUrls , expectedURLConfig ) => {
12
54
mergeConfig ( { PARAGON_THEME_URLS : paragonThemeUrls } ) ;
13
55
const { result } = renderHook ( ( ) => useParagonThemeUrls ( ) ) ;
@@ -122,7 +164,7 @@ describe('useParagonThemeUrls', () => {
122
164
expect . objectContaining ( {
123
165
core : {
124
166
urls : {
125
- default : '//localhost:8080/core.min.css' ,
167
+ default : '//localhost:8080/local- core.min.css' ,
126
168
brandOverride : 'brand-core.css' ,
127
169
} ,
128
170
} ,
@@ -132,7 +174,8 @@ describe('useParagonThemeUrls', () => {
132
174
variants : {
133
175
light : {
134
176
urls : {
135
- default : '//localhost:8080/light.min.css' ,
177
+ default : '//localhost:8080/local-light.min.css' ,
178
+ brandOverride : '//localhost:8080/brand-local-light.min.css' ,
136
179
} ,
137
180
} ,
138
181
} ,
@@ -155,7 +198,7 @@ describe('useParagonThemeUrls', () => {
155
198
} ;
156
199
const originalParagonTheme = global . PARAGON_THEME ;
157
200
Object . defineProperty ( global , 'PARAGON_THEME' , {
158
- value : 'mocked-theme' ,
201
+ value : undefined ,
159
202
writable : true ,
160
203
} ) ;
161
204
mergeConfig ( config ) ;
0 commit comments