@@ -389,6 +389,85 @@ describe('Connect redux store', () => {
389389 STEPS . ENTER_CREDENTIALS ,
390390 )
391391 } )
392+
393+ it ( 'should set the step to DEMO_CONNECT_GUARD when launching with current_institution_guid and user is demo but institution is not' , ( ) => {
394+ const institution = { guid : 'INS-1' , is_demo : false , credentials }
395+ const user = { guid : 'USR-1' , is_demo : true }
396+ const config = { current_institution_guid : 'INS-1' }
397+ const afterState = reducer (
398+ defaultState ,
399+ loadConnectSuccess ( { institution, config, widgetProfile, user } ) ,
400+ )
401+
402+ expect ( afterState . location [ afterState . location . length - 1 ] . step ) . toEqual (
403+ STEPS . DEMO_CONNECT_GUARD ,
404+ )
405+ } )
406+
407+ it ( 'should set the step to DEMO_CONNECT_GUARD when launching with current_institution_code and user is demo but institution is not' , ( ) => {
408+ const institution = { guid : 'INS-1' , code : 'bank_code' , is_demo : false , credentials }
409+ const user = { guid : 'USR-1' , is_demo : true }
410+ const config = { current_institution_code : 'bank_code' }
411+ const afterState = reducer (
412+ defaultState ,
413+ loadConnectSuccess ( { institution, config, widgetProfile, user } ) ,
414+ )
415+
416+ expect ( afterState . location [ afterState . location . length - 1 ] . step ) . toEqual (
417+ STEPS . DEMO_CONNECT_GUARD ,
418+ )
419+ } )
420+
421+ it ( 'should set the step to DEMO_CONNECT_GUARD when launching with current_member_guid and user is demo but institution is not' , ( ) => {
422+ const institution = { guid : 'INS-1' , is_demo : false , credentials }
423+ const user = { guid : 'USR-1' , is_demo : true }
424+ const member = genMember ( { guid : 'MBR-1' , connection_status : ReadableStatuses . CONNECTED } )
425+ const config = { current_member_guid : 'MBR-1' }
426+ const afterState = reducer (
427+ defaultState ,
428+ loadConnectSuccess ( { member, institution, config, widgetProfile, user } ) ,
429+ )
430+
431+ expect ( afterState . location [ afterState . location . length - 1 ] . step ) . toEqual (
432+ STEPS . DEMO_CONNECT_GUARD ,
433+ )
434+ } )
435+
436+ it ( 'should NOT set the step to DEMO_CONNECT_GUARD when launching with current_institution_guid but user is not demo' , ( ) => {
437+ const institution = { guid : 'INS-1' , is_demo : false , credentials }
438+ const user = { guid : 'USR-1' , is_demo : false }
439+ const config = { current_institution_guid : 'INS-1' }
440+ const afterState = reducer (
441+ defaultState ,
442+ loadConnectSuccess ( { institution, config, widgetProfile, user } ) ,
443+ )
444+
445+ expect ( afterState . location [ afterState . location . length - 1 ] . step ) . toEqual (
446+ STEPS . ENTER_CREDENTIALS ,
447+ )
448+ } )
449+
450+ it ( 'should NOT set the step to DEMO_CONNECT_GUARD when launching with current_institution_guid and both user and institution are demo' , ( ) => {
451+ const institution = { guid : 'INS-1' , is_demo : true , credentials }
452+ const user = { guid : 'USR-1' , is_demo : true }
453+ const config = { current_institution_guid : 'INS-1' }
454+ const afterState = reducer (
455+ defaultState ,
456+ loadConnectSuccess ( { institution, config, widgetProfile, user } ) ,
457+ )
458+
459+ expect ( afterState . location [ afterState . location . length - 1 ] . step ) . toEqual (
460+ STEPS . ENTER_CREDENTIALS ,
461+ )
462+ } )
463+
464+ it ( 'should NOT set the step to DEMO_CONNECT_GUARD when user is demo but no institution parameters are provided' , ( ) => {
465+ const user = { guid : 'USR-1' , is_demo : true }
466+ const config = { }
467+ const afterState = reducer ( defaultState , loadConnectSuccess ( { config, widgetProfile, user } ) )
468+
469+ expect ( afterState . location [ afterState . location . length - 1 ] . step ) . toEqual ( STEPS . SEARCH )
470+ } )
392471 } )
393472
394473 describe ( 'loadConnectError' , ( ) => {
@@ -455,10 +534,7 @@ describe('Connect redux store', () => {
455534 const config = { mode : VERIFY_MODE }
456535 const afterState = reducer (
457536 { ...defaultState , isComponentLoading : true } ,
458- {
459- type : ActionTypes . LOAD_CONNECT_SUCCESS ,
460- payload : { config, members : [ ] , widgetProfile } ,
461- } ,
537+ loadConnectSuccess ( { config, members : [ ] , widgetProfile } ) ,
462538 )
463539 expect ( afterState . location [ afterState . location . length - 1 ] . step ) . toEqual ( STEPS . SEARCH )
464540 } )
@@ -473,10 +549,7 @@ describe('Connect redux store', () => {
473549 const members = [ member ]
474550 const afterState = reducer (
475551 { ...defaultState , isComponentLoading : true } ,
476- {
477- type : ActionTypes . LOAD_CONNECT_SUCCESS ,
478- payload : { config, member, members, widgetProfile } ,
479- } ,
552+ loadConnectSuccess ( { config, member, members, widgetProfile } ) ,
480553 )
481554 expect ( afterState . location [ afterState . location . length - 1 ] . step ) . toEqual (
482555 STEPS . ACTIONABLE_ERROR ,
@@ -500,10 +573,7 @@ describe('Connect redux store', () => {
500573 const members = [ member ]
501574 const afterState = reducer (
502575 { ...defaultState , isComponentLoading : true } ,
503- {
504- type : ActionTypes . LOAD_CONNECT_SUCCESS ,
505- payload : { config, member, members, widgetProfile } ,
506- } ,
576+ loadConnectSuccess ( { config, member, members, widgetProfile } ) ,
507577 )
508578 expect ( afterState . location [ afterState . location . length - 1 ] . step ) . toEqual (
509579 STEPS . ACTIONABLE_ERROR ,
@@ -527,10 +597,7 @@ describe('Connect redux store', () => {
527597 const members = [ member ]
528598 const afterState = reducer (
529599 { ...defaultState , isComponentLoading : true } ,
530- {
531- type : ActionTypes . LOAD_CONNECT_SUCCESS ,
532- payload : { config, member, members, widgetProfile } ,
533- } ,
600+ loadConnectSuccess ( { config, member, members, widgetProfile } ) ,
534601 )
535602 expect ( afterState . location [ afterState . location . length - 1 ] . step ) . toEqual (
536603 STEPS . ENTER_CREDENTIALS ,
@@ -554,10 +621,7 @@ describe('Connect redux store', () => {
554621 const members = [ member ]
555622 const afterState = reducer (
556623 { ...defaultState , isComponentLoading : true } ,
557- {
558- type : ActionTypes . LOAD_CONNECT_SUCCESS ,
559- payload : { config, member, members, widgetProfile } ,
560- } ,
624+ loadConnectSuccess ( { config, member, members, widgetProfile } ) ,
561625 )
562626 expect ( afterState . location [ afterState . location . length - 1 ] . step ) . toEqual ( STEPS . MFA )
563627 } )
@@ -578,10 +642,7 @@ describe('Connect redux store', () => {
578642 const members = [ member ]
579643 const afterState = reducer (
580644 { ...defaultState , isComponentLoading : true } ,
581- {
582- type : ActionTypes . LOAD_CONNECT_SUCCESS ,
583- payload : { config, member, members, accounts : [ ] , widgetProfile } ,
584- } ,
645+ loadConnectSuccess ( { config, member, members, accounts : [ ] , widgetProfile } ) ,
585646 )
586647 expect ( afterState . location [ afterState . location . length - 1 ] . step ) . toEqual (
587648 STEPS . ACTIONABLE_ERROR ,
0 commit comments