@@ -918,6 +918,22 @@ describe('metrics effects', () => {
918
918
expect ( saveScalarPinSpy ) . not . toHaveBeenCalled ( ) ;
919
919
expect ( removeScalarPinSpy ) . not . toHaveBeenCalled ( ) ;
920
920
} ) ;
921
+
922
+ it ( 'does not pin the card if getMetricsSavingPinsEnabled is false' , ( ) => {
923
+ store . overrideSelector ( selectors . getMetricsSavingPinsEnabled , false ) ;
924
+ store . refreshState ( ) ;
925
+
926
+ actions$ . next (
927
+ actions . cardPinStateToggled ( {
928
+ cardId : 'card1' ,
929
+ wasPinned : false ,
930
+ canCreateNewPins : true ,
931
+ } )
932
+ ) ;
933
+
934
+ expect ( saveScalarPinSpy ) . not . toHaveBeenCalled ( ) ;
935
+ expect ( removeScalarPinSpy ) . not . toHaveBeenCalled ( ) ;
936
+ } ) ;
921
937
} ) ;
922
938
923
939
describe ( 'loadSavedPins' , ( ) => {
@@ -984,6 +1000,19 @@ describe('metrics effects', () => {
984
1000
985
1001
expect ( actualActions ) . toEqual ( [ ] ) ;
986
1002
} ) ;
1003
+
1004
+ it ( 'does not load saved pins if getMetricsSavingPinsEnabled is false' , ( ) => {
1005
+ getSavedScalarPinsSpy = spyOn (
1006
+ savedPinsDataSource ,
1007
+ 'getSavedScalarPins'
1008
+ ) . and . returnValue ( [ 'tagA' , 'tagB' ] ) ;
1009
+ store . overrideSelector ( selectors . getMetricsSavingPinsEnabled , false ) ;
1010
+ store . refreshState ( ) ;
1011
+
1012
+ actions$ . next ( TEST_ONLY . initAction ( ) ) ;
1013
+
1014
+ expect ( actualActions ) . toEqual ( [ ] ) ;
1015
+ } ) ;
987
1016
} ) ;
988
1017
989
1018
describe ( 'removeAllPins' , ( ) => {
@@ -1021,6 +1050,62 @@ describe('metrics effects', () => {
1021
1050
1022
1051
expect ( removeAllScalarPinsSpy ) . not . toHaveBeenCalled ( ) ;
1023
1052
} ) ;
1053
+
1054
+ it ( 'does not remove pins if getMetricsSavingPinsEnabled is false' , ( ) => {
1055
+ store . overrideSelector ( selectors . getMetricsSavingPinsEnabled , false ) ;
1056
+ store . refreshState ( ) ;
1057
+
1058
+ actions$ . next ( actions . metricsClearAllPinnedCards ( ) ) ;
1059
+
1060
+ expect ( removeAllScalarPinsSpy ) . not . toHaveBeenCalled ( ) ;
1061
+ } ) ;
1062
+ } ) ;
1063
+
1064
+ describe ( 'removeSavedPinsOnDisable' , ( ) => {
1065
+ let removeAllScalarPinsSpy : jasmine . Spy ;
1066
+
1067
+ beforeEach ( ( ) => {
1068
+ removeAllScalarPinsSpy = spyOn (
1069
+ savedPinsDataSource ,
1070
+ 'removeAllScalarPins'
1071
+ ) ;
1072
+ store . overrideSelector ( selectors . getEnableGlobalPins , true ) ;
1073
+ store . overrideSelector ( selectors . getMetricsSavingPinsEnabled , false ) ;
1074
+ store . refreshState ( ) ;
1075
+ } ) ;
1076
+
1077
+ it ( 'removes all pins by calling metricsEnableSavingPinsToggled method' , ( ) => {
1078
+ actions$ . next ( actions . metricsEnableSavingPinsToggled ( ) ) ;
1079
+
1080
+ expect ( removeAllScalarPinsSpy ) . toHaveBeenCalled ( ) ;
1081
+ } ) ;
1082
+
1083
+ it ( 'does not remove pins if getEnableGlobalPins is false' , ( ) => {
1084
+ store . overrideSelector ( selectors . getEnableGlobalPins , false ) ;
1085
+ store . refreshState ( ) ;
1086
+
1087
+ actions$ . next ( actions . metricsEnableSavingPinsToggled ( ) ) ;
1088
+
1089
+ expect ( removeAllScalarPinsSpy ) . not . toHaveBeenCalled ( ) ;
1090
+ } ) ;
1091
+
1092
+ it ( 'does not remove pins if getShouldPersistSettings is false' , ( ) => {
1093
+ store . overrideSelector ( selectors . getShouldPersistSettings , false ) ;
1094
+ store . refreshState ( ) ;
1095
+
1096
+ actions$ . next ( actions . metricsEnableSavingPinsToggled ( ) ) ;
1097
+
1098
+ expect ( removeAllScalarPinsSpy ) . not . toHaveBeenCalled ( ) ;
1099
+ } ) ;
1100
+
1101
+ it ( 'does not remove pins if getMetricsSavingPinsEnabled is true' , ( ) => {
1102
+ store . overrideSelector ( selectors . getMetricsSavingPinsEnabled , true ) ;
1103
+ store . refreshState ( ) ;
1104
+
1105
+ actions$ . next ( actions . metricsEnableSavingPinsToggled ( ) ) ;
1106
+
1107
+ expect ( removeAllScalarPinsSpy ) . not . toHaveBeenCalled ( ) ;
1108
+ } ) ;
1024
1109
} ) ;
1025
1110
} ) ;
1026
1111
} ) ;
0 commit comments