habitica/test/api/unit/models/pushDevice.test.js

20 lines
733 B
JavaScript
Raw Normal View History

2020-03-01 20:49:52 +00:00
import { model as PushDevice } from '../../../../website/server/models/pushDevice';
describe('PushDevice Model', () => {
context('cleanupCorruptData', () => {
it('converts an array of push devices to a safe version', () => {
const pushDevices = [
null, // invalid, not an object
{ regId: '123' }, // invalid, no type
{ type: 'android' }, // invalid, no regId
new PushDevice({ type: 'android', regId: '1234' }), // valid
];
const safePushDevices = PushDevice.cleanupCorruptData(pushDevices);
expect(safePushDevices.length).to.equal(1);
expect(safePushDevices[0].type).to.equal('android');
expect(safePushDevices[0].regId).to.equal('1234');
});
});
});