@quatrain/messaging-firebase 1.1.1 → 1.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quatrain/messaging-firebase",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.3",
|
|
4
4
|
"license": "AGPL-3.0-only",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -19,10 +19,10 @@
|
|
|
19
19
|
},
|
|
20
20
|
"author": "Quatrain Développement SAS <developers@quatrain.com>",
|
|
21
21
|
"peerDependencies": {
|
|
22
|
-
"@quatrain/core": "^1.2.
|
|
22
|
+
"@quatrain/core": "^1.2.9"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@quatrain/core": "^1.2.
|
|
25
|
+
"@quatrain/core": "^1.2.9",
|
|
26
26
|
"@quatrain/messaging": "^1.1.3",
|
|
27
27
|
"firebase-admin": "^13.0.1"
|
|
28
28
|
},
|
|
@@ -2,6 +2,12 @@ import { FirebaseMessagingAdapter } from '../FirebaseMessagingAdapter'
|
|
|
2
2
|
import { MessagingRecipient, NotificationMessage } from '@quatrain/messaging'
|
|
3
3
|
|
|
4
4
|
// Mock Firebase Admin SDK
|
|
5
|
+
jest.mock('firebase-admin', () => ({
|
|
6
|
+
credential: {
|
|
7
|
+
cert: jest.fn(() => ({})),
|
|
8
|
+
},
|
|
9
|
+
}))
|
|
10
|
+
|
|
5
11
|
jest.mock('firebase-admin/app', () => ({
|
|
6
12
|
getApps: jest.fn(() => []),
|
|
7
13
|
initializeApp: jest.fn()
|
|
@@ -83,14 +89,14 @@ describe('FirebaseMessagingAdapter', () => {
|
|
|
83
89
|
})
|
|
84
90
|
|
|
85
91
|
test('should handle empty body gracefully', async () => {
|
|
86
|
-
const messageWithoutBody = { ...mockMessage, body: undefined }
|
|
92
|
+
const messageWithoutBody = { ...mockMessage, body: undefined } as unknown as NotificationMessage
|
|
87
93
|
|
|
88
94
|
const result = await adapter.sendNotification(mockRecipient, messageWithoutBody)
|
|
89
95
|
expect(result).toBe('message-id-123')
|
|
90
96
|
})
|
|
91
97
|
})
|
|
92
98
|
|
|
93
|
-
|
|
99
|
+
describe('sendNotifications', () => {
|
|
94
100
|
const mockRecipients: MessagingRecipient[] = [
|
|
95
101
|
{
|
|
96
102
|
firstname: 'John',
|
|
@@ -112,7 +118,7 @@ describe('FirebaseMessagingAdapter', () => {
|
|
|
112
118
|
}
|
|
113
119
|
|
|
114
120
|
test('should send multicast notification successfully', async () => {
|
|
115
|
-
const result = await adapter.
|
|
121
|
+
const result = await adapter.sendNotifications(mockRecipients, mockMessage)
|
|
116
122
|
|
|
117
123
|
expect(result.successCount).toBe(2)
|
|
118
124
|
expect(result.failureCount).toBe(0)
|
|
@@ -130,7 +136,7 @@ describe('FirebaseMessagingAdapter', () => {
|
|
|
130
136
|
}
|
|
131
137
|
]
|
|
132
138
|
|
|
133
|
-
const result = await adapter.
|
|
139
|
+
const result = await adapter.sendNotifications(recipientsWithMissingTokens, mockMessage)
|
|
134
140
|
expect(result.successCount).toBe(2)
|
|
135
141
|
})
|
|
136
142
|
|
|
@@ -141,7 +147,7 @@ describe('FirebaseMessagingAdapter', () => {
|
|
|
141
147
|
}))
|
|
142
148
|
|
|
143
149
|
await expect(
|
|
144
|
-
adapter.
|
|
150
|
+
adapter.sendNotifications(recipientsWithoutTokens, mockMessage)
|
|
145
151
|
).rejects.toThrow('No valid message tokens found')
|
|
146
152
|
})
|
|
147
153
|
})
|