@@ -21,8 +21,6 @@ import Optimizely, {
21
21
// @ts -expect-error
22
22
isFeatureEnabledMock ,
23
23
// @ts -expect-error
24
- activateMock ,
25
- // @ts -expect-error
26
24
decideMock ,
27
25
// @ts -expect-error
28
26
optimizelyUserContextMock
@@ -44,16 +42,12 @@ const testAudienceSegmentationCacheBusting = (toggleFn, fn) => {
44
42
45
43
toggleFn ( 'foo' , 'a' , 'b' , 'c' ) // call 1
46
44
expect ( fn ) . toHaveBeenCalledTimes ( 1 )
47
- expect ( fn ) . toHaveBeenCalledWith ( 'foo' , 'fooBSide' , {
48
- foo : 'baz'
49
- } )
45
+ expect ( fn ) . toHaveBeenCalledWith ( 'foo' )
50
46
toggleFn ( 'foo' , 'a' , 'b' , 'c' ) // cached
51
47
toggleFn ( 'bar' , 'a' , 'b' , 'c' ) // call 2
52
48
toggleFn ( 'bar' , 'a' , 'b' , 'c' ) // cached
53
49
expect ( fn ) . toHaveBeenCalledTimes ( 2 )
54
- expect ( fn ) . toHaveBeenCalledWith ( 'bar' , 'fooBSide' , {
55
- foo : 'baz'
56
- } )
50
+ expect ( fn ) . toHaveBeenCalledWith ( 'bar' )
57
51
} )
58
52
}
59
53
@@ -82,7 +76,7 @@ describe('Optimizely Integration', () => {
82
76
expect ( addNotificationListenerMock ) . toHaveBeenCalledWith (
83
77
NOTIFICATION_TYPES . DECISION ,
84
78
// 'DECISION:type, userId, attributes, decisionInfo',
85
- activateHandler
79
+ expect . any ( Function )
86
80
)
87
81
} )
88
82
} )
@@ -141,14 +135,9 @@ describe('Optimizely Integration', () => {
141
135
142
136
it ( 'Forwards toggle reading and audienceSegmentationAttributes to Optimizely' , ( ) => {
143
137
toggle ( 'foo' , 'a' , 'b' , 'c' )
144
- expect ( activateMock ) . toHaveBeenCalledWith ( 'foo' , 'fooBSide' , { } )
145
138
toggle ( 'foo' )
146
- expect ( decideMock ) . toHaveBeenCalledWith (
147
- 'foo'
148
- )
149
- expect ( optimizelyUserContextMock ) . toHaveBeenCalledWith (
150
- 'fooBSide' , { }
151
- )
139
+ expect ( decideMock ) . toHaveBeenCalledWith ( 'foo' )
140
+ expect ( optimizelyUserContextMock ) . toHaveBeenCalledWith ( 'fooBSide' , { } )
152
141
} )
153
142
} )
154
143
@@ -166,15 +155,6 @@ describe('Optimizely Integration', () => {
166
155
167
156
it ( 'Forwards toggle reading and audienceSegmentationAttributes to Optimizely' , ( ) => {
168
157
toggle ( 'foo' , 'a' , 'b' , 'c' )
169
- expect ( activateMock ) . toHaveBeenCalledWith ( 'foo' , 'fooBSide' , {
170
- thisWillNotBeOverwritten : 'foo' ,
171
- deviceType : 'mobile' ,
172
- isLoggedIn : false
173
- } )
174
- } )
175
-
176
- it ( 'Forwards toggle reading and audienceSegmentationAttributes to Optimizely' , ( ) => {
177
- toggle ( 'foo' )
178
158
expect ( optimizelyUserContextMock ) . toHaveBeenCalledWith ( 'fooBSide' , {
179
159
thisWillNotBeOverwritten : 'foo' ,
180
160
deviceType : 'mobile' ,
@@ -192,7 +172,8 @@ describe('Optimizely Integration', () => {
192
172
193
173
it ( 'Forwards correct audience segmentation attributes' , ( ) => {
194
174
toggle ( 'foo' , 'a' , 'b' , 'c' )
195
- expect ( activateMock ) . toHaveBeenCalledWith ( 'foo' , 'fooBSide' , {
175
+
176
+ expect ( optimizelyUserContextMock ) . toHaveBeenCalledWith ( 'fooBSide' , {
196
177
valueAfterReset : true
197
178
} )
198
179
@@ -208,7 +189,7 @@ describe('Optimizely Integration', () => {
208
189
} )
209
190
} )
210
191
211
- testAudienceSegmentationCacheBusting ( toggle , activateMock )
192
+ testAudienceSegmentationCacheBusting ( toggle , decideMock )
212
193
213
194
it ( "Returns Optimizely's value when no arguments supplied" , ( ) => {
214
195
// maps to a, b, c
@@ -252,7 +233,7 @@ describe('Optimizely Integration', () => {
252
233
} )
253
234
254
235
it ( 'makes sure Toggles return defaults if forced values are of wrong type' , ( ) => {
255
- expect ( toggle ( 'baz ' , 'a' , 'b' , 'c' ) ) . toEqual ( 'a' )
236
+ expect ( toggle ( 'boz ' , 'a' , 'b' , 'c' ) ) . toEqual ( 'a' )
256
237
} )
257
238
258
239
describe ( 'Clearing forced toggles' , ( ) => {
0 commit comments