@@ -255,7 +255,7 @@ def call; end
255
255
256
256
it 'should not remove notifications for an invalid notification type' do
257
257
invalid_type = 'Invalid notification'
258
- expect { @inner_notification_center . clear_notifications ( invalid_type ) }
258
+ expect { @inner_notification_center . clear_notification_listeners ( invalid_type ) }
259
259
. to raise_error ( Optimizely ::InvalidNotificationType )
260
260
expect ( spy_logger ) . to have_received ( :log ) . once
261
261
. with ( Logger ::ERROR , 'Invalid notification type.' )
@@ -273,7 +273,7 @@ def call; end
273
273
274
274
it 'should remove all notifications for a valid notification type' do
275
275
notification_type = Optimizely ::NotificationCenter ::NOTIFICATION_TYPES [ :ACTIVATE ]
276
- @inner_notification_center . clear_notifications ( notification_type )
276
+ @inner_notification_center . clear_notification_listeners ( notification_type )
277
277
expect ( spy_logger ) . to have_received ( :log ) . once
278
278
. with ( Logger ::INFO , "All callbacks for notification type #{ notification_type } have been removed." )
279
279
expect (
@@ -288,10 +288,19 @@ def call; end
288
288
) . to eq ( 1 )
289
289
end
290
290
291
- it 'should not throw an error when clear_notifications is called again for the same notification type ' do
291
+ it 'should call clear_notification_listeners and log depreciation message ' do
292
292
notification_type = Optimizely ::NotificationCenter ::NOTIFICATION_TYPES [ :ACTIVATE ]
293
+ expect ( @inner_notification_center ) . to receive ( :clear_notification_listeners ) . once . with ( notification_type )
293
294
@inner_notification_center . clear_notifications ( notification_type )
294
- expect { @inner_notification_center . clear_notifications ( notification_type ) }
295
+ expect ( spy_logger ) . to have_received ( :log ) . once . with (
296
+ Logger ::WARN , "'clear_notifications' is deprecated. Call 'clear_notification_listeners' instead."
297
+ )
298
+ end
299
+
300
+ it 'should not throw an error when clear_notification_listeners is called again for the same notification type' do
301
+ notification_type = Optimizely ::NotificationCenter ::NOTIFICATION_TYPES [ :ACTIVATE ]
302
+ @inner_notification_center . clear_notification_listeners ( notification_type )
303
+ expect { @inner_notification_center . clear_notification_listeners ( notification_type ) }
295
304
. to_not raise_error ( Optimizely ::InvalidNotificationType )
296
305
expect (
297
306
@inner_notification_center . notifications [
@@ -361,17 +370,25 @@ def call; end
361
370
end
362
371
363
372
it 'should remove all notifications for each notification type' do
364
- @inner_notification_center . clean_all_notifications
373
+ @inner_notification_center . clear_all_notification_listeners
365
374
@inner_notification_center . notifications . each_key do |key |
366
375
expect ( @inner_notification_center . notifications [ key ] ) . to be_empty
367
376
end
368
377
end
369
378
370
- it 'clean_all_notifications does not throw an error when called again' do
371
- @inner_notification_center . clean_all_notifications
372
- expect { @inner_notification_center . clean_all_notifications }
379
+ it 'clear_all_notification_listeners does not throw an error when called again' do
380
+ @inner_notification_center . clear_all_notification_listeners
381
+ expect { @inner_notification_center . clear_all_notification_listeners }
373
382
. to_not raise_error
374
383
end
384
+
385
+ it 'should call clear_all_notification_listeners and log depreciation message' do
386
+ expect ( @inner_notification_center ) . to receive ( :clear_all_notification_listeners ) . once
387
+ @inner_notification_center . clean_all_notifications
388
+ expect ( spy_logger ) . to have_received ( :log ) . once . with (
389
+ Logger ::WARN , "'clean_all_notifications' is deprecated. Call 'clear_all_notification_listeners' instead."
390
+ )
391
+ end
375
392
end
376
393
377
394
describe '.send_notifications' do
0 commit comments