@@ -3,11 +3,53 @@ import { renderHook } from '@testing-library/react';
33import useParagonThemeUrls from './useParagonThemeUrls' ;
44import { mergeConfig } from '../../../config' ;
55
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+
644describe ( 'useParagonThemeUrls' , ( ) => {
745 beforeEach ( ( ) => { jest . resetAllMocks ( ) ; } ) ;
846 it . each ( [
947 [ 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+ } ] ,
1153 ] ) ( 'handles when `config.PARAGON_THEME_URLS` is not present (%s)' , ( paragonThemeUrls , expectedURLConfig ) => {
1254 mergeConfig ( { PARAGON_THEME_URLS : paragonThemeUrls } ) ;
1355 const { result } = renderHook ( ( ) => useParagonThemeUrls ( ) ) ;
@@ -122,7 +164,7 @@ describe('useParagonThemeUrls', () => {
122164 expect . objectContaining ( {
123165 core : {
124166 urls : {
125- default : '//localhost:8080/core.min.css' ,
167+ default : '//localhost:8080/local- core.min.css' ,
126168 brandOverride : 'brand-core.css' ,
127169 } ,
128170 } ,
@@ -132,7 +174,8 @@ describe('useParagonThemeUrls', () => {
132174 variants : {
133175 light : {
134176 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' ,
136179 } ,
137180 } ,
138181 } ,
@@ -155,7 +198,7 @@ describe('useParagonThemeUrls', () => {
155198 } ;
156199 const originalParagonTheme = global . PARAGON_THEME ;
157200 Object . defineProperty ( global , 'PARAGON_THEME' , {
158- value : 'mocked-theme' ,
201+ value : undefined ,
159202 writable : true ,
160203 } ) ;
161204 mergeConfig ( config ) ;
0 commit comments