Skip to content

Commit aee968a

Browse files
committed
Add duplicate device token test
1 parent 49b01c9 commit aee968a

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

spec/ParseInstallation.spec.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,52 @@ describe('Installations', () => {
445445
});
446446
});
447447

448+
it('update android device token with duplicate device token', (done) => {
449+
var installId1 = '11111111-abcd-abcd-abcd-123456789abc';
450+
var installId2 = '22222222-abcd-abcd-abcd-123456789abc';
451+
var t = '0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef';
452+
var input = {
453+
'installationId': installId1,
454+
'deviceToken': t,
455+
'deviceType': 'android'
456+
};
457+
var firstObject;
458+
var secondObject;
459+
rest.create(config, auth.nobody(config), '_Installation', input)
460+
.then(() => {
461+
input = {
462+
'installationId': installId2,
463+
'deviceType': 'android'
464+
};
465+
return rest.create(config, auth.nobody(config), '_Installation', input);
466+
}).then(() => {
467+
return database.mongoFind('_Installation',
468+
{installationId: installId1}, {});
469+
}).then((results) => {
470+
expect(results.length).toEqual(1);
471+
firstObject = results[0];
472+
return database.mongoFind('_Installation',
473+
{installationId: installId2}, {});
474+
}).then((results) => {
475+
expect(results.length).toEqual(1);
476+
secondObject = results[0];
477+
// Update second installation to conflict with first installation
478+
input = {
479+
'objectId': secondObject._id,
480+
'deviceToken': t
481+
};
482+
return rest.update(config, auth.nobody(config), '_Installation',
483+
secondObject._id, input);
484+
}).then(() => {
485+
// The first object should have been deleted
486+
return database.mongoFind('_Installation', {_id: firstObject._id}, {});
487+
}).then((results) => {
488+
expect(results.length).toEqual(0);
489+
done();
490+
}).catch((error) => { console.log(error); });
491+
});
492+
493+
448494
it('update ios device token with duplicate device token', (done) => {
449495
var installId1 = '11111111-abcd-abcd-abcd-123456789abc';
450496
var installId2 = '22222222-abcd-abcd-abcd-123456789abc';

0 commit comments

Comments
 (0)