Skip to content

Commit 7dda492

Browse files
committed
Adding test for checking sending / receiving extra header
1 parent 98b5c19 commit 7dda492

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

test/testSendNotification.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,14 @@ suite('sendNotification', function() {
191191
assert.equal(requestDetails.headers.authorization, 'key=my_gcm_key', 'Check GCM Authorization header');
192192
}
193193
}
194+
195+
const extraHeaders = options.extraOptions && options.extraOptions.headers;
196+
if (extraHeaders) {
197+
Object.keys(extraHeaders).forEach(function (header) {
198+
const normalizedName = header.toLowerCase();
199+
assert.equal(requestDetails.headers[normalizedName], extraHeaders[header], 'Check presence of header ' + header);
200+
});
201+
}
194202
}
195203

196204
const validRequests = [
@@ -284,6 +292,19 @@ suite('sendNotification', function() {
284292
TTL: 5
285293
}
286294
}
295+
}, {
296+
testTitle: 'send/receive extra headers',
297+
requestOptions: {
298+
subscription: {
299+
// The default endpoint will be added by the test
300+
},
301+
extraOptions: {
302+
headers: {
303+
Extra: 'extra',
304+
'extra-2': 'extra-2'
305+
}
306+
}
307+
}
287308
}
288309
];
289310

0 commit comments

Comments
 (0)