Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/messaging/messaging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ export class Messaging {

return this.getUrlPath()
.then((urlPath) => {
const requests: Promise<SendResponse>[] = copy.map((message) => {
const requests: Promise<SendResponse>[] = copy.map(async (message) => {
validateMessage(message);
const request: { message: Message; validate_only?: boolean } = { message };
if (dryRun) {
Expand Down
13 changes: 13 additions & 0 deletions test/unit/messaging/messaging.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,19 @@ describe('Messaging', () => {
.should.eventually.be.rejectedWith('Exactly one of topic, token or condition is required');
});

it('should reject a message when it does not pass local validation, but still try the other messages', () => {
const invalidMessage: Message = { token: 'a', notification: { imageUrl: 'abc' } };
const messageIds = [
'projects/projec_id/messages/1',
];
messageIds.forEach(id => mockedRequests.push(mockSendRequest(id)))
return messaging.sendEach([invalidMessage, validMessage])
.then((response: BatchResponse) => {
expect(response.successCount).to.equal(1);
expect(response.failureCount).to.equal(1);
});
});

const invalidDryRun = [null, NaN, 0, 1, '', 'a', [], [1, 'a'], {}, { a: 1 }, _.noop];
invalidDryRun.forEach((dryRun) => {
it(`should throw given invalid dryRun parameter: ${JSON.stringify(dryRun)}`, () => {
Expand Down