@@ -255,7 +255,7 @@ def call; end
255255
256256 it 'should not remove notifications for an invalid notification type' do
257257 invalid_type = 'Invalid notification'
258- expect { @inner_notification_center . clear_notifications ( invalid_type ) }
258+ expect { @inner_notification_center . clear_notification_listeners ( invalid_type ) }
259259 . to raise_error ( Optimizely ::InvalidNotificationType )
260260 expect ( spy_logger ) . to have_received ( :log ) . once
261261 . with ( Logger ::ERROR , 'Invalid notification type.' )
@@ -273,7 +273,7 @@ def call; end
273273
274274 it 'should remove all notifications for a valid notification type' do
275275 notification_type = Optimizely ::NotificationCenter ::NOTIFICATION_TYPES [ :ACTIVATE ]
276- @inner_notification_center . clear_notifications ( notification_type )
276+ @inner_notification_center . clear_notification_listeners ( notification_type )
277277 expect ( spy_logger ) . to have_received ( :log ) . once
278278 . with ( Logger ::INFO , "All callbacks for notification type #{ notification_type } have been removed." )
279279 expect (
@@ -288,10 +288,19 @@ def call; end
288288 ) . to eq ( 1 )
289289 end
290290
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
292292 notification_type = Optimizely ::NotificationCenter ::NOTIFICATION_TYPES [ :ACTIVATE ]
293+ expect ( @inner_notification_center ) . to receive ( :clear_notification_listeners ) . once . with ( notification_type )
293294 @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 ) }
295304 . to_not raise_error ( Optimizely ::InvalidNotificationType )
296305 expect (
297306 @inner_notification_center . notifications [
@@ -361,17 +370,25 @@ def call; end
361370 end
362371
363372 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
365374 @inner_notification_center . notifications . each_key do |key |
366375 expect ( @inner_notification_center . notifications [ key ] ) . to be_empty
367376 end
368377 end
369378
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 }
373382 . to_not raise_error
374383 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
375392 end
376393
377394 describe '.send_notifications' do
0 commit comments