import { NotificationPermission } from '../lib/notification-permission' ; import { NotificationPermissionStatus } from '../lib/notification' ; describe ( 'Notification Permission' , function ( ) { it ( 'should complete with a denied status if there is not Notification support' , function ( done ) { new NotificationPermission ( ) . subscribe ( { next ( permission ) { expect ( permission ) . toBe ( false ) ; } , error : done , complete : done } ) ; } ) ; it ( 'should complete with a denied status if the permission type is "denied"' , function ( done ) { const permission = 'denied' ; const notification = { permission } ; new NotificationPermission ( notification ) . subscribe ( { next ( permission ) { expect ( permission ) . toBe ( false ) ; } , error : done , complete : done } ) ; } ) ; it ( 'should complete with a granted status if the permission type is "granted"' , function ( done ) { const permission = 'granted' ; const notification = { permission } ; new NotificationPermission ( notification ) . subscribe ( { next ( permission ) { expect ( permission ) . toBe ( true ) ; } , error : done , complete : done } ) ; } ) ; it ( 'should request permission if the permission type is "default"' , function ( done ) { const permission = 'default' ; const resolvedPermission = Promise . resolve ( 'granted' ) ; const requestPermission = jasmine . createSpy ( 'requestPermission' ) . and . returnValue ( resolvedPermission ) ; const notification = { permission , requestPermission } ; new NotificationPermission ( notification ) . subscribe ( { next ( permission ) { expect ( permission ) . toBe ( true ) ; expect ( requestPermission ) . toHaveBeenCalled ( ) ; } , error : done , complete : done } ) ; } ) ; } ) ;