@@ -302,67 +302,77 @@ describe("useOrganizationConfig", () => {
302302 "#FB3552" ,
303303 ) ;
304304 } ) ;
305- } ) ;
306-
307- it ( "resolves to documented defaults when the hook has not loaded branding yet" , ( ) => {
308- const branding = resolveBranding ( { } ) ;
309305
310- expect ( branding [ OrganizationConfigKey . PrimaryColor ] ) . toBe (
311- DEFAULT_BRANDING [ OrganizationConfigKey . PrimaryColor ] ,
312- ) ;
313- expect ( branding [ OrganizationConfigKey . SecondaryColor ] ) . toBe (
314- DEFAULT_BRANDING [ OrganizationConfigKey . SecondaryColor ] ,
315- ) ;
316- } ) ;
306+ it ( "resolves to documented defaults when the hook has not loaded branding yet" , ( ) => {
307+ const branding = resolveBranding ( { } ) ;
317308
318- it ( "resolves hook results the same way as server defaults for missing branding" , async ( ) => {
319- mockGet . mockImplementation ( ( ) =>
320- Promise . resolve ( {
321- json : ( ) => Promise . resolve ( { } ) ,
322- } ) ,
323- ) ;
324-
325- const keys = [
326- OrganizationConfigKey . PrimaryColor ,
327- OrganizationConfigKey . SecondaryColor ,
328- ] as const ;
329- const { result } = renderHook ( ( ) => useOrganizationConfig ( keys ) ) ;
330-
331- await waitFor ( ( ) => {
332- expect ( mockGet ) . toHaveBeenCalled ( ) ;
333- } ) ;
334-
335- expect ( resolveBranding ( result . current ) ) . toEqual ( {
336- [ OrganizationConfigKey . PrimaryColor ] :
309+ expect ( branding [ OrganizationConfigKey . PrimaryColor ] ) . toBe (
337310 DEFAULT_BRANDING [ OrganizationConfigKey . PrimaryColor ] ,
338- [ OrganizationConfigKey . SecondaryColor ] :
311+ ) ;
312+ expect ( branding [ OrganizationConfigKey . SecondaryColor ] ) . toBe (
339313 DEFAULT_BRANDING [ OrganizationConfigKey . SecondaryColor ] ,
314+ ) ;
340315 } ) ;
341- } ) ;
342316
343- it ( "keeps a configured primary color from the hook and defaults the secondary" , async ( ) => {
344- mockGet . mockImplementation ( ( ) =>
345- Promise . resolve ( {
346- json : ( ) =>
347- Promise . resolve ( {
348- [ OrganizationConfigKey . PrimaryColor ] : "#000000" ,
349- } ) ,
350- } ) ,
351- ) ;
352-
353- const keys = [
354- OrganizationConfigKey . PrimaryColor ,
355- OrganizationConfigKey . SecondaryColor ,
356- ] as const ;
357- const { result } = renderHook ( ( ) => useOrganizationConfig ( keys ) ) ;
358-
359- await waitFor ( ( ) => {
360- expect ( result . current [ OrganizationConfigKey . PrimaryColor ] ) . toBe ( "#000000" ) ;
317+ it ( "resolves hook results the same way as server defaults for missing branding" , async ( ) => {
318+ mockGet . mockImplementation ( ( ) =>
319+ Promise . resolve ( {
320+ ok : true ,
321+ status : 200 ,
322+ json : ( ) =>
323+ Promise . resolve ( { primary_color : null , secondary_color : null } ) ,
324+ } ) ,
325+ ) ;
326+
327+ const keys = [
328+ OrganizationConfigKey . PrimaryColor ,
329+ OrganizationConfigKey . SecondaryColor ,
330+ ] as const ;
331+ const { result } = renderHook ( ( ) => useOrganizationConfig ( keys ) ) ;
332+
333+ await waitFor ( ( ) => {
334+ expect ( result . current [ OrganizationConfigKey . PrimaryColor ] ) . toBeNull ( ) ;
335+ expect ( result . current [ OrganizationConfigKey . SecondaryColor ] ) . toBeNull ( ) ;
336+ expect ( result . current . status ) . toBe ( "ok" ) ;
337+ } ) ;
338+
339+ expect ( resolveBranding ( result . current ) ) . toEqual ( {
340+ [ OrganizationConfigKey . PrimaryColor ] :
341+ DEFAULT_BRANDING [ OrganizationConfigKey . PrimaryColor ] ,
342+ [ OrganizationConfigKey . SecondaryColor ] :
343+ DEFAULT_BRANDING [ OrganizationConfigKey . SecondaryColor ] ,
344+ } ) ;
361345 } ) ;
362346
363- expect ( resolveBranding ( result . current ) ) . toEqual ( {
364- [ OrganizationConfigKey . PrimaryColor ] : "#000000" ,
365- [ OrganizationConfigKey . SecondaryColor ] :
366- DEFAULT_BRANDING [ OrganizationConfigKey . SecondaryColor ] ,
347+ it ( "keeps a configured primary color from the hook and defaults the secondary" , async ( ) => {
348+ mockGet . mockImplementation ( ( ) =>
349+ Promise . resolve ( {
350+ ok : true ,
351+ status : 200 ,
352+ json : ( ) =>
353+ Promise . resolve ( {
354+ [ OrganizationConfigKey . PrimaryColor ] : "#000000" ,
355+ } ) ,
356+ } ) ,
357+ ) ;
358+
359+ const keys = [
360+ OrganizationConfigKey . PrimaryColor ,
361+ OrganizationConfigKey . SecondaryColor ,
362+ ] as const ;
363+ const { result } = renderHook ( ( ) => useOrganizationConfig ( keys ) ) ;
364+
365+ await waitFor ( ( ) => {
366+ expect ( result . current [ OrganizationConfigKey . PrimaryColor ] ) . toBe (
367+ "#000000" ,
368+ ) ;
369+ expect ( result . current . status ) . toBe ( "ok" ) ;
370+ } ) ;
371+
372+ expect ( resolveBranding ( result . current ) ) . toEqual ( {
373+ [ OrganizationConfigKey . PrimaryColor ] : "#000000" ,
374+ [ OrganizationConfigKey . SecondaryColor ] :
375+ DEFAULT_BRANDING [ OrganizationConfigKey . SecondaryColor ] ,
376+ } ) ;
367377 } ) ;
368378} ) ;
0 commit comments