@@ -527,6 +527,15 @@ describe('reducer', () => {
527527 } )
528528 } )
529529
530+ describe ( 'PROFILE_UPDATE_SUCCESS action -' , ( ) => {
531+ it ( 'sets auth state to isLoaded: true, isEmpty: false' , ( ) => {
532+ const payload = { some : 'value' }
533+ action = { type : actionTypes . PROFILE_UPDATE_SUCCESS , payload }
534+ const currentState = firebaseReducer ( { } , action )
535+ expect ( currentState ) . to . have . deep . property ( 'profile.some' , payload . some )
536+ } )
537+ } )
538+
530539 describe ( 'LOGIN action -' , ( ) => {
531540 it ( 'sets auth state to isLoaded: true, isEmpty: false' , ( ) => {
532541 const auth = { some : 'value' }
@@ -552,6 +561,103 @@ describe('reducer', () => {
552561 true
553562 )
554563 } )
564+
565+ describe ( 'preserve parameter' , ( ) => {
566+ describe ( 'profile state is preserved when provided' , ( ) => {
567+ it ( 'an array of keys' , ( ) => {
568+ const payload = { some : 'other' }
569+ const initialState = { profile : { some : 'value' } }
570+ action = {
571+ type : actionTypes . LOGIN ,
572+ preserve : { profile : [ 'some' ] } ,
573+ payload
574+ }
575+ expect ( firebaseReducer ( initialState , action ) ) . to . have . deep . property (
576+ 'profile.some' ,
577+ 'value'
578+ )
579+ } )
580+
581+ it ( 'a boolean (true)' , ( ) => {
582+ const payload = { some : 'other' }
583+ const initialState = { profile : { some : 'value' } }
584+ action = {
585+ type : actionTypes . LOGIN ,
586+ preserve : { profile : true } ,
587+ payload
588+ }
589+ expect ( firebaseReducer ( initialState , action ) ) . to . have . deep . property (
590+ 'profile.some' ,
591+ 'value'
592+ )
593+ } )
594+ } )
595+
596+ describe ( 'profile state is updated when is already exists and is provided' , ( ) => {
597+ it ( 'a boolean (true)' , ( ) => {
598+ const payload = { some : 'other' }
599+ const initialState = { profile : { some : 'value' } }
600+ action = {
601+ type : actionTypes . LOGIN ,
602+ preserve : { profile : true } ,
603+ payload
604+ }
605+ expect ( firebaseReducer ( initialState , action ) ) . to . have . deep . property (
606+ 'profile.some' ,
607+ 'value'
608+ )
609+ } )
610+ } )
611+
612+ describe ( 'auth state is preserved when provided' , ( ) => {
613+ it ( 'an array of keys' , ( ) => {
614+ const payload = { some : 'other' }
615+ const initialState = { auth : { some : 'value' } }
616+ action = {
617+ type : actionTypes . LOGIN ,
618+ preserve : { auth : [ 'some' ] } ,
619+ auth : payload
620+ }
621+ expect ( firebaseReducer ( initialState , action ) ) . to . have . deep . property (
622+ 'auth.some' ,
623+ 'value'
624+ )
625+ } )
626+
627+ it ( 'a boolean (true)' , ( ) => {
628+ const initialState = { auth : { some : 'value' } }
629+ action = {
630+ type : actionTypes . LOGIN ,
631+ preserve : { auth : true } ,
632+ auth : { }
633+ }
634+ expect ( firebaseReducer ( initialState , action ) ) . to . have . deep . property (
635+ 'auth.some' ,
636+ 'value'
637+ )
638+ } )
639+ } )
640+
641+ describe ( 'auth state is updated when is already exists and is provided' , ( ) => {
642+ it ( 'a boolean (true)' , ( ) => {
643+ const payload = { some : 'other' , another : 'thing' }
644+ const initialState = { auth : { some : 'value' } }
645+ action = {
646+ type : actionTypes . LOGIN ,
647+ preserve : { auth : true } ,
648+ auth : payload
649+ }
650+ expect ( firebaseReducer ( initialState , action ) ) . to . have . deep . property (
651+ 'auth.some' ,
652+ payload . some
653+ )
654+ expect ( firebaseReducer ( initialState , action ) ) . to . have . deep . property (
655+ 'auth.another' ,
656+ payload . another
657+ )
658+ } )
659+ } )
660+ } )
555661 } )
556662
557663 describe ( 'REMOVE action -' , ( ) => {
0 commit comments