|
| 1 | +import { NotificationIOS } from "./NotificationIOS"; |
| 2 | + |
| 3 | +describe('Notification', () => { |
| 4 | + it('Should create notification with payload', () => { |
| 5 | + const payload = { p: 'p' }; |
| 6 | + const notification = new NotificationIOS(payload); |
| 7 | + expect(notification.payload).toEqual(payload); |
| 8 | + }); |
| 9 | + |
| 10 | + it('Should create notification with valid aps', () => { |
| 11 | + const aps = { alert: {} }; |
| 12 | + const payload = { aps }; |
| 13 | + const notification = new NotificationIOS(payload); |
| 14 | + expect(notification.aps).toEqual(aps); |
| 15 | + }); |
| 16 | + |
| 17 | + it('Should create notification with empy aps', () => { |
| 18 | + const payload = { aps: undefined }; |
| 19 | + const notification = new NotificationIOS(payload); |
| 20 | + expect(notification.aps).toEqual({}); |
| 21 | + }); |
| 22 | + |
| 23 | + it('Should return alert object', () => { |
| 24 | + const payload = { aps: { alert: { title: 'title' } } }; |
| 25 | + const notification = new NotificationIOS(payload); |
| 26 | + expect(notification.alert).toEqual(payload.aps.alert); |
| 27 | + }); |
| 28 | + |
| 29 | + it('Should return alert object when alert is string', () => { |
| 30 | + const payload = { aps: { alert: 'title' } }; |
| 31 | + const notification = new NotificationIOS(payload); |
| 32 | + expect(notification.alert).toEqual({ |
| 33 | + body: 'title' |
| 34 | + }); |
| 35 | + }); |
| 36 | + |
| 37 | + it('Should return title from alert', () => { |
| 38 | + const payload = { aps: { alert: { title: 'title' } } }; |
| 39 | + const notification = new NotificationIOS(payload); |
| 40 | + expect(notification.title).toEqual('title'); |
| 41 | + }); |
| 42 | + |
| 43 | + it('Should return body from alert', () => { |
| 44 | + const payload = { aps: { alert: { title: 'title', body: 'body' } } }; |
| 45 | + const notification = new NotificationIOS(payload); |
| 46 | + expect(notification.body).toEqual('body'); |
| 47 | + }); |
| 48 | + |
| 49 | + it('Should return badge from aps', () => { |
| 50 | + const payload = { aps: { badge: 0 } }; |
| 51 | + const notification = new NotificationIOS(payload); |
| 52 | + expect(notification.badge).toEqual(0); |
| 53 | + }); |
| 54 | + |
| 55 | + it('Should return sound from aps', () => { |
| 56 | + const payload = { aps: { sound: 'sound.wav' } }; |
| 57 | + const notification = new NotificationIOS(payload); |
| 58 | + expect(notification.sound).toEqual('sound.wav'); |
| 59 | + }); |
| 60 | + |
| 61 | + it('Should return thread from aps', () => { |
| 62 | + const payload = { aps: { thread: 'thread' } }; |
| 63 | + const notification = new NotificationIOS(payload); |
| 64 | + expect(notification.thread).toEqual('thread'); |
| 65 | + }); |
| 66 | +}); |
0 commit comments