Skip to content

Commit 93aa28d

Browse files
committed
Add a test that invalid or wrong properties are ignored
1 parent 9a4b643 commit 93aa28d

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

test/unit/senderSpec.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,31 @@ describe('UNIT Sender', function () {
178178
}, 10);
179179
});
180180

181+
it('should ignore properties of body that are unknown or invalid types', function(done) {
182+
var mess = {
183+
delay_while_idle: "a string",
184+
collapse_key: true,
185+
time_to_live: 100,
186+
dry_run: true,
187+
data: {
188+
name: 'Matt'
189+
},
190+
unknown_property: "hello"
191+
};
192+
var sender = new Sender('mykey');
193+
sender.sendNoRetry(mess, '', function () {});
194+
setTimeout(function() {
195+
var body = args.options.json;
196+
expect(body.delay_while_idle).to.equal(undefined);
197+
expect(body.collapse_key).to.equal(undefined);
198+
expect(body.time_to_live).to.equal(mess.time_to_live);
199+
expect(body.dry_run).to.equal(mess.dry_run);
200+
expect(body.data).to.deep.equal(mess.data);
201+
expect(body.unknown_property).to.equal(undefined);
202+
done();
203+
}, 10);
204+
});
205+
181206
it('should set the registration_ids to reg tokens implicitly passed in', function (done) {
182207
var sender = new Sender('myKey');
183208
var m = { data: {} };

0 commit comments

Comments
 (0)