fix(prettier): Properly handle lint-stage files (#6970)
Now handles top level files and recursive files in folders. Set max line length to be 100
This commit is contained in:
@@ -10,19 +10,14 @@ const request = require('../lib/request');
|
||||
|
||||
let config;
|
||||
let database;
|
||||
const defaultColumns = require('../lib/Controllers/SchemaController')
|
||||
.defaultColumns;
|
||||
const defaultColumns = require('../lib/Controllers/SchemaController').defaultColumns;
|
||||
|
||||
const delay = function delay(delay) {
|
||||
return new Promise(resolve => setTimeout(resolve, delay));
|
||||
};
|
||||
|
||||
const installationSchema = {
|
||||
fields: Object.assign(
|
||||
{},
|
||||
defaultColumns._Default,
|
||||
defaultColumns._Installation
|
||||
),
|
||||
fields: Object.assign({}, defaultColumns._Default, defaultColumns._Installation),
|
||||
};
|
||||
|
||||
describe('Installations', () => {
|
||||
@@ -40,9 +35,7 @@ describe('Installations', () => {
|
||||
};
|
||||
rest
|
||||
.create(config, auth.nobody(config), '_Installation', input)
|
||||
.then(() =>
|
||||
database.adapter.find('_Installation', installationSchema, {}, {})
|
||||
)
|
||||
.then(() => database.adapter.find('_Installation', installationSchema, {}, {}))
|
||||
.then(results => {
|
||||
expect(results.length).toEqual(1);
|
||||
const obj = results[0];
|
||||
@@ -58,8 +51,7 @@ describe('Installations', () => {
|
||||
});
|
||||
|
||||
it('creates an ios installation with ids', done => {
|
||||
const t =
|
||||
'11433856eed2f1285fb3aa11136718c1198ed5647875096952c66bf8cb976306';
|
||||
const t = '11433856eed2f1285fb3aa11136718c1198ed5647875096952c66bf8cb976306';
|
||||
const device = 'ios';
|
||||
const input = {
|
||||
deviceToken: t,
|
||||
@@ -67,9 +59,7 @@ describe('Installations', () => {
|
||||
};
|
||||
rest
|
||||
.create(config, auth.nobody(config), '_Installation', input)
|
||||
.then(() =>
|
||||
database.adapter.find('_Installation', installationSchema, {}, {})
|
||||
)
|
||||
.then(() => database.adapter.find('_Installation', installationSchema, {}, {}))
|
||||
.then(results => {
|
||||
expect(results.length).toEqual(1);
|
||||
const obj = results[0];
|
||||
@@ -93,9 +83,7 @@ describe('Installations', () => {
|
||||
};
|
||||
rest
|
||||
.create(config, auth.nobody(config), '_Installation', input)
|
||||
.then(() =>
|
||||
database.adapter.find('_Installation', installationSchema, {}, {})
|
||||
)
|
||||
.then(() => database.adapter.find('_Installation', installationSchema, {}, {}))
|
||||
.then(results => {
|
||||
expect(results.length).toEqual(1);
|
||||
const obj = results[0];
|
||||
@@ -120,9 +108,7 @@ describe('Installations', () => {
|
||||
};
|
||||
rest
|
||||
.create(config, auth.nobody(config), '_Installation', input)
|
||||
.then(() =>
|
||||
database.adapter.find('_Installation', installationSchema, {}, {})
|
||||
)
|
||||
.then(() => database.adapter.find('_Installation', installationSchema, {}, {}))
|
||||
.then(results => {
|
||||
expect(results.length).toEqual(1);
|
||||
const obj = results[0];
|
||||
@@ -142,8 +128,7 @@ describe('Installations', () => {
|
||||
});
|
||||
|
||||
it('creates an ios installation with all fields', done => {
|
||||
const t =
|
||||
'11433856eed2f1285fb3aa11136718c1198ed5647875096952c66bf8cb976306';
|
||||
const t = '11433856eed2f1285fb3aa11136718c1198ed5647875096952c66bf8cb976306';
|
||||
const device = 'ios';
|
||||
const input = {
|
||||
deviceToken: t,
|
||||
@@ -152,9 +137,7 @@ describe('Installations', () => {
|
||||
};
|
||||
rest
|
||||
.create(config, auth.nobody(config), '_Installation', input)
|
||||
.then(() =>
|
||||
database.adapter.find('_Installation', installationSchema, {}, {})
|
||||
)
|
||||
.then(() => database.adapter.find('_Installation', installationSchema, {}, {}))
|
||||
.then(results => {
|
||||
expect(results.length).toEqual(1);
|
||||
const obj = results[0];
|
||||
@@ -261,8 +244,7 @@ describe('Installations', () => {
|
||||
});
|
||||
|
||||
it('creates an object with custom fields', done => {
|
||||
const t =
|
||||
'11433856eed2f1285fb3aa11136718c1198ed5647875096952c66bf8cb976306';
|
||||
const t = '11433856eed2f1285fb3aa11136718c1198ed5647875096952c66bf8cb976306';
|
||||
const input = {
|
||||
deviceToken: t,
|
||||
deviceType: 'ios',
|
||||
@@ -271,9 +253,7 @@ describe('Installations', () => {
|
||||
};
|
||||
rest
|
||||
.create(config, auth.nobody(config), '_Installation', input)
|
||||
.then(() =>
|
||||
database.adapter.find('_Installation', installationSchema, {}, {})
|
||||
)
|
||||
.then(() => database.adapter.find('_Installation', installationSchema, {}, {}))
|
||||
.then(results => {
|
||||
expect(results.length).toEqual(1);
|
||||
const obj = results[0];
|
||||
@@ -289,8 +269,7 @@ describe('Installations', () => {
|
||||
|
||||
it('merging when installationId already exists', done => {
|
||||
const installId1 = '12345678-abcd-abcd-abcd-123456789abc';
|
||||
const t =
|
||||
'11433856eed2f1285fb3aa11136718c1198ed5647875096952c66bf8cb976306';
|
||||
const t = '11433856eed2f1285fb3aa11136718c1198ed5647875096952c66bf8cb976306';
|
||||
const input = {
|
||||
deviceToken: t,
|
||||
deviceType: 'ios',
|
||||
@@ -301,9 +280,7 @@ describe('Installations', () => {
|
||||
let secondObject;
|
||||
rest
|
||||
.create(config, auth.nobody(config), '_Installation', input)
|
||||
.then(() =>
|
||||
database.adapter.find('_Installation', installationSchema, {}, {})
|
||||
)
|
||||
.then(() => database.adapter.find('_Installation', installationSchema, {}, {}))
|
||||
.then(results => {
|
||||
expect(results.length).toEqual(1);
|
||||
firstObject = results[0];
|
||||
@@ -312,9 +289,7 @@ describe('Installations', () => {
|
||||
input['foo'] = 'bar';
|
||||
return rest.create(config, auth.nobody(config), '_Installation', input);
|
||||
})
|
||||
.then(() =>
|
||||
database.adapter.find('_Installation', installationSchema, {}, {})
|
||||
)
|
||||
.then(() => database.adapter.find('_Installation', installationSchema, {}, {}))
|
||||
.then(results => {
|
||||
expect(results.length).toEqual(1);
|
||||
secondObject = results[0];
|
||||
@@ -330,8 +305,7 @@ describe('Installations', () => {
|
||||
|
||||
it('merging when two objects both only have one id', done => {
|
||||
const installId = '12345678-abcd-abcd-abcd-123456789abc';
|
||||
const t =
|
||||
'0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef';
|
||||
const t = '0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef';
|
||||
const input1 = {
|
||||
installationId: installId,
|
||||
deviceType: 'ios',
|
||||
@@ -349,22 +323,13 @@ describe('Installations', () => {
|
||||
let secondObject;
|
||||
rest
|
||||
.create(config, auth.nobody(config), '_Installation', input1)
|
||||
.then(() =>
|
||||
database.adapter.find('_Installation', installationSchema, {}, {})
|
||||
)
|
||||
.then(() => database.adapter.find('_Installation', installationSchema, {}, {}))
|
||||
.then(results => {
|
||||
expect(results.length).toEqual(1);
|
||||
firstObject = results[0];
|
||||
return rest.create(
|
||||
config,
|
||||
auth.nobody(config),
|
||||
'_Installation',
|
||||
input2
|
||||
);
|
||||
return rest.create(config, auth.nobody(config), '_Installation', input2);
|
||||
})
|
||||
.then(() =>
|
||||
database.adapter.find('_Installation', installationSchema, {}, {})
|
||||
)
|
||||
.then(() => database.adapter.find('_Installation', installationSchema, {}, {}))
|
||||
.then(results => {
|
||||
expect(results.length).toEqual(2);
|
||||
if (results[0]['_id'] == firstObject._id) {
|
||||
@@ -372,16 +337,9 @@ describe('Installations', () => {
|
||||
} else {
|
||||
secondObject = results[0];
|
||||
}
|
||||
return rest.create(
|
||||
config,
|
||||
auth.nobody(config),
|
||||
'_Installation',
|
||||
input3
|
||||
);
|
||||
return rest.create(config, auth.nobody(config), '_Installation', input3);
|
||||
})
|
||||
.then(() =>
|
||||
database.adapter.find('_Installation', installationSchema, {}, {})
|
||||
)
|
||||
.then(() => database.adapter.find('_Installation', installationSchema, {}, {}))
|
||||
.then(results => {
|
||||
expect(results.length).toEqual(1);
|
||||
expect(results[0]['_id']).toEqual(secondObject._id);
|
||||
@@ -397,8 +355,7 @@ describe('Installations', () => {
|
||||
const installId1 = '11111111-abcd-abcd-abcd-123456789abc';
|
||||
const installId2 = '22222222-abcd-abcd-abcd-123456789abc';
|
||||
const installId3 = '33333333-abcd-abcd-abcd-123456789abc';
|
||||
const t =
|
||||
'0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef';
|
||||
const t = '0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef';
|
||||
const input = {
|
||||
installationId: installId1,
|
||||
deviceType: 'ios',
|
||||
@@ -457,26 +414,16 @@ describe('Installations', () => {
|
||||
};
|
||||
rest
|
||||
.create(config, auth.nobody(config), '_Installation', input)
|
||||
.then(() =>
|
||||
database.adapter.find('_Installation', installationSchema, {}, {})
|
||||
)
|
||||
.then(() => database.adapter.find('_Installation', installationSchema, {}, {}))
|
||||
.then(results => {
|
||||
expect(results.length).toEqual(1);
|
||||
const objectId = results[0].objectId;
|
||||
const update = {
|
||||
channels: ['baz'],
|
||||
};
|
||||
return rest.update(
|
||||
config,
|
||||
auth.nobody(config),
|
||||
'_Installation',
|
||||
{ objectId },
|
||||
update
|
||||
);
|
||||
return rest.update(config, auth.nobody(config), '_Installation', { objectId }, update);
|
||||
})
|
||||
.then(() =>
|
||||
database.adapter.find('_Installation', installationSchema, {}, {})
|
||||
)
|
||||
.then(() => database.adapter.find('_Installation', installationSchema, {}, {}))
|
||||
.then(results => {
|
||||
expect(results.length).toEqual(1);
|
||||
expect(results[0].channels.length).toEqual(1);
|
||||
@@ -499,9 +446,7 @@ describe('Installations', () => {
|
||||
};
|
||||
rest
|
||||
.create(config, auth.nobody(config), '_Installation', input)
|
||||
.then(() =>
|
||||
database.adapter.find('_Installation', installationSchema, {}, {})
|
||||
)
|
||||
.then(() => database.adapter.find('_Installation', installationSchema, {}, {}))
|
||||
.then(results => {
|
||||
expect(results.length).toEqual(1);
|
||||
input = { installationId: installId2 };
|
||||
@@ -524,10 +469,8 @@ describe('Installations', () => {
|
||||
});
|
||||
|
||||
it('update ios fails with new deviceToken and no installationId', done => {
|
||||
const a =
|
||||
'11433856eed2f1285fb3aa11136718c1198ed5647875096952c66bf8cb976306';
|
||||
const b =
|
||||
'91433856eed2f1285fb3aa11136718c1198ed5647875096952c66bf8cb976306';
|
||||
const a = '11433856eed2f1285fb3aa11136718c1198ed5647875096952c66bf8cb976306';
|
||||
const b = '91433856eed2f1285fb3aa11136718c1198ed5647875096952c66bf8cb976306';
|
||||
let input = {
|
||||
deviceToken: a,
|
||||
deviceType: 'ios',
|
||||
@@ -535,9 +478,7 @@ describe('Installations', () => {
|
||||
};
|
||||
rest
|
||||
.create(config, auth.nobody(config), '_Installation', input)
|
||||
.then(() =>
|
||||
database.adapter.find('_Installation', installationSchema, {}, {})
|
||||
)
|
||||
.then(() => database.adapter.find('_Installation', installationSchema, {}, {}))
|
||||
.then(results => {
|
||||
expect(results.length).toEqual(1);
|
||||
input = { deviceToken: b };
|
||||
@@ -560,10 +501,8 @@ describe('Installations', () => {
|
||||
|
||||
it('update ios updates device token', done => {
|
||||
const installId = '12345678-abcd-abcd-abcd-123456789abc';
|
||||
const t =
|
||||
'11433856eed2f1285fb3aa11136718c1198ed5647875096952c66bf8cb976306';
|
||||
const u =
|
||||
'91433856eed2f1285fb3aa11136718c1198ed5647875096952c66bf8cb976306';
|
||||
const t = '11433856eed2f1285fb3aa11136718c1198ed5647875096952c66bf8cb976306';
|
||||
const u = '91433856eed2f1285fb3aa11136718c1198ed5647875096952c66bf8cb976306';
|
||||
let input = {
|
||||
installationId: installId,
|
||||
deviceType: 'ios',
|
||||
@@ -572,9 +511,7 @@ describe('Installations', () => {
|
||||
};
|
||||
rest
|
||||
.create(config, auth.nobody(config), '_Installation', input)
|
||||
.then(() =>
|
||||
database.adapter.find('_Installation', installationSchema, {}, {})
|
||||
)
|
||||
.then(() => database.adapter.find('_Installation', installationSchema, {}, {}))
|
||||
.then(results => {
|
||||
expect(results.length).toEqual(1);
|
||||
input = {
|
||||
@@ -590,9 +527,7 @@ describe('Installations', () => {
|
||||
input
|
||||
);
|
||||
})
|
||||
.then(() =>
|
||||
database.adapter.find('_Installation', installationSchema, {}, {})
|
||||
)
|
||||
.then(() => database.adapter.find('_Installation', installationSchema, {}, {}))
|
||||
.then(results => {
|
||||
expect(results.length).toEqual(1);
|
||||
expect(results[0].deviceToken).toEqual(u);
|
||||
@@ -613,9 +548,7 @@ describe('Installations', () => {
|
||||
};
|
||||
rest
|
||||
.create(config, auth.nobody(config), '_Installation', input)
|
||||
.then(() =>
|
||||
database.adapter.find('_Installation', installationSchema, {}, {})
|
||||
)
|
||||
.then(() => database.adapter.find('_Installation', installationSchema, {}, {}))
|
||||
.then(results => {
|
||||
expect(results.length).toEqual(1);
|
||||
input = {
|
||||
@@ -648,9 +581,7 @@ describe('Installations', () => {
|
||||
};
|
||||
rest
|
||||
.create(config, auth.nobody(config), '_Installation', input)
|
||||
.then(() =>
|
||||
database.adapter.find('_Installation', installationSchema, {}, {})
|
||||
)
|
||||
.then(() => database.adapter.find('_Installation', installationSchema, {}, {}))
|
||||
.then(results => {
|
||||
expect(results.length).toEqual(1);
|
||||
input = {
|
||||
@@ -664,9 +595,7 @@ describe('Installations', () => {
|
||||
input
|
||||
);
|
||||
})
|
||||
.then(() =>
|
||||
database.adapter.find('_Installation', installationSchema, {}, {})
|
||||
)
|
||||
.then(() => database.adapter.find('_Installation', installationSchema, {}, {}))
|
||||
.then(results => {
|
||||
expect(results.length).toEqual(1);
|
||||
expect(results[0]['custom']).toEqual('allowed');
|
||||
@@ -677,8 +606,7 @@ describe('Installations', () => {
|
||||
it('update android device token with duplicate device token', async () => {
|
||||
const installId1 = '11111111-abcd-abcd-abcd-123456789abc';
|
||||
const installId2 = '22222222-abcd-abcd-abcd-123456789abc';
|
||||
const t =
|
||||
'0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef';
|
||||
const t = '0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef';
|
||||
|
||||
let input = {
|
||||
installationId: installId1,
|
||||
@@ -737,8 +665,7 @@ describe('Installations', () => {
|
||||
it('update ios device token with duplicate device token', done => {
|
||||
const installId1 = '11111111-abcd-abcd-abcd-123456789abc';
|
||||
const installId2 = '22222222-abcd-abcd-abcd-123456789abc';
|
||||
const t =
|
||||
'0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef';
|
||||
const t = '0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef';
|
||||
let input = {
|
||||
installationId: installId1,
|
||||
deviceToken: t,
|
||||
@@ -816,8 +743,7 @@ describe('Installations', () => {
|
||||
xit('update ios device token with duplicate token different app', done => {
|
||||
const installId1 = '11111111-abcd-abcd-abcd-123456789abc';
|
||||
const installId2 = '22222222-abcd-abcd-abcd-123456789abc';
|
||||
const t =
|
||||
'0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef';
|
||||
const t = '0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef';
|
||||
const input = {
|
||||
installationId: installId1,
|
||||
deviceToken: t,
|
||||
@@ -831,9 +757,7 @@ describe('Installations', () => {
|
||||
input.appIdentifier = 'bar';
|
||||
return rest.create(config, auth.nobody(config), '_Installation', input);
|
||||
})
|
||||
.then(() =>
|
||||
database.adapter.find('_Installation', installationSchema, {}, {})
|
||||
)
|
||||
.then(() => database.adapter.find('_Installation', installationSchema, {}, {}))
|
||||
.then(results => {
|
||||
// The first object should have been deleted during merge
|
||||
expect(results.length).toEqual(1);
|
||||
@@ -848,17 +772,14 @@ describe('Installations', () => {
|
||||
|
||||
it('update ios token and channels', done => {
|
||||
const installId = '12345678-abcd-abcd-abcd-123456789abc';
|
||||
const t =
|
||||
'0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef';
|
||||
const t = '0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef';
|
||||
let input = {
|
||||
installationId: installId,
|
||||
deviceType: 'ios',
|
||||
};
|
||||
rest
|
||||
.create(config, auth.nobody(config), '_Installation', input)
|
||||
.then(() =>
|
||||
database.adapter.find('_Installation', installationSchema, {}, {})
|
||||
)
|
||||
.then(() => database.adapter.find('_Installation', installationSchema, {}, {}))
|
||||
.then(results => {
|
||||
expect(results.length).toEqual(1);
|
||||
input = {
|
||||
@@ -873,9 +794,7 @@ describe('Installations', () => {
|
||||
input
|
||||
);
|
||||
})
|
||||
.then(() =>
|
||||
database.adapter.find('_Installation', installationSchema, {}, {})
|
||||
)
|
||||
.then(() => database.adapter.find('_Installation', installationSchema, {}, {}))
|
||||
.then(results => {
|
||||
expect(results.length).toEqual(1);
|
||||
expect(results[0].installationId).toEqual(installId);
|
||||
@@ -891,8 +810,7 @@ describe('Installations', () => {
|
||||
|
||||
it('update ios linking two existing objects', done => {
|
||||
const installId = '12345678-abcd-abcd-abcd-123456789abc';
|
||||
const t =
|
||||
'0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef';
|
||||
const t = '0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef';
|
||||
let input = {
|
||||
installationId: installId,
|
||||
deviceType: 'ios',
|
||||
@@ -907,12 +825,7 @@ describe('Installations', () => {
|
||||
return rest.create(config, auth.nobody(config), '_Installation', input);
|
||||
})
|
||||
.then(() =>
|
||||
database.adapter.find(
|
||||
'_Installation',
|
||||
installationSchema,
|
||||
{ deviceToken: t },
|
||||
{}
|
||||
)
|
||||
database.adapter.find('_Installation', installationSchema, { deviceToken: t }, {})
|
||||
)
|
||||
.then(results => {
|
||||
expect(results.length).toEqual(1);
|
||||
@@ -929,9 +842,7 @@ describe('Installations', () => {
|
||||
input
|
||||
);
|
||||
})
|
||||
.then(() =>
|
||||
database.adapter.find('_Installation', installationSchema, {}, {})
|
||||
)
|
||||
.then(() => database.adapter.find('_Installation', installationSchema, {}, {}))
|
||||
.then(results => {
|
||||
expect(results.length).toEqual(1);
|
||||
expect(results[0].installationId).toEqual(installId);
|
||||
@@ -947,8 +858,7 @@ describe('Installations', () => {
|
||||
|
||||
it('update is linking two existing objects w/ increment', done => {
|
||||
const installId = '12345678-abcd-abcd-abcd-123456789abc';
|
||||
const t =
|
||||
'0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef';
|
||||
const t = '0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef';
|
||||
let input = {
|
||||
installationId: installId,
|
||||
deviceType: 'ios',
|
||||
@@ -963,12 +873,7 @@ describe('Installations', () => {
|
||||
return rest.create(config, auth.nobody(config), '_Installation', input);
|
||||
})
|
||||
.then(() =>
|
||||
database.adapter.find(
|
||||
'_Installation',
|
||||
installationSchema,
|
||||
{ deviceToken: t },
|
||||
{}
|
||||
)
|
||||
database.adapter.find('_Installation', installationSchema, { deviceToken: t }, {})
|
||||
)
|
||||
.then(results => {
|
||||
expect(results.length).toEqual(1);
|
||||
@@ -989,9 +894,7 @@ describe('Installations', () => {
|
||||
input
|
||||
);
|
||||
})
|
||||
.then(() =>
|
||||
database.adapter.find('_Installation', installationSchema, {}, {})
|
||||
)
|
||||
.then(() => database.adapter.find('_Installation', installationSchema, {}, {}))
|
||||
.then(results => {
|
||||
expect(results.length).toEqual(1);
|
||||
expect(results[0].installationId).toEqual(installId);
|
||||
@@ -1008,8 +911,7 @@ describe('Installations', () => {
|
||||
|
||||
it('update is linking two existing with installation id', done => {
|
||||
const installId = '12345678-abcd-abcd-abcd-123456789abc';
|
||||
const t =
|
||||
'0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef';
|
||||
const t = '0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef';
|
||||
let input = {
|
||||
installationId: installId,
|
||||
deviceType: 'ios',
|
||||
@@ -1018,9 +920,7 @@ describe('Installations', () => {
|
||||
let tokenObj;
|
||||
rest
|
||||
.create(config, auth.nobody(config), '_Installation', input)
|
||||
.then(() =>
|
||||
database.adapter.find('_Installation', installationSchema, {}, {})
|
||||
)
|
||||
.then(() => database.adapter.find('_Installation', installationSchema, {}, {}))
|
||||
.then(results => {
|
||||
expect(results.length).toEqual(1);
|
||||
installObj = results[0];
|
||||
@@ -1031,12 +931,7 @@ describe('Installations', () => {
|
||||
return rest.create(config, auth.nobody(config), '_Installation', input);
|
||||
})
|
||||
.then(() =>
|
||||
database.adapter.find(
|
||||
'_Installation',
|
||||
installationSchema,
|
||||
{ deviceToken: t },
|
||||
{}
|
||||
)
|
||||
database.adapter.find('_Installation', installationSchema, { deviceToken: t }, {})
|
||||
)
|
||||
.then(results => {
|
||||
expect(results.length).toEqual(1);
|
||||
@@ -1076,8 +971,7 @@ describe('Installations', () => {
|
||||
|
||||
it('update is linking two existing with installation id w/ op', done => {
|
||||
const installId = '12345678-abcd-abcd-abcd-123456789abc';
|
||||
const t =
|
||||
'0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef';
|
||||
const t = '0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef';
|
||||
let input = {
|
||||
installationId: installId,
|
||||
deviceType: 'ios',
|
||||
@@ -1086,9 +980,7 @@ describe('Installations', () => {
|
||||
let tokenObj;
|
||||
rest
|
||||
.create(config, auth.nobody(config), '_Installation', input)
|
||||
.then(() =>
|
||||
database.adapter.find('_Installation', installationSchema, {}, {})
|
||||
)
|
||||
.then(() => database.adapter.find('_Installation', installationSchema, {}, {}))
|
||||
.then(results => {
|
||||
expect(results.length).toEqual(1);
|
||||
installObj = results[0];
|
||||
@@ -1099,12 +991,7 @@ describe('Installations', () => {
|
||||
return rest.create(config, auth.nobody(config), '_Installation', input);
|
||||
})
|
||||
.then(() =>
|
||||
database.adapter.find(
|
||||
'_Installation',
|
||||
installationSchema,
|
||||
{ deviceToken: t },
|
||||
{}
|
||||
)
|
||||
database.adapter.find('_Installation', installationSchema, { deviceToken: t }, {})
|
||||
)
|
||||
.then(results => {
|
||||
expect(results.length).toEqual(1);
|
||||
@@ -1158,8 +1045,7 @@ describe('Installations', () => {
|
||||
// imported installation, then we should reuse the existing installation
|
||||
// object in case the developer already added additional fields via Data
|
||||
// Browser or REST API (e.g. channel targeting info).
|
||||
const t =
|
||||
'0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef';
|
||||
const t = '0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef';
|
||||
const installId = '12345678-abcd-abcd-abcd-123456789abc';
|
||||
let input = {
|
||||
deviceToken: t,
|
||||
@@ -1167,9 +1053,7 @@ describe('Installations', () => {
|
||||
};
|
||||
rest
|
||||
.create(config, auth.nobody(config), '_Installation', input)
|
||||
.then(() =>
|
||||
database.adapter.find('_Installation', installationSchema, {}, {})
|
||||
)
|
||||
.then(() => database.adapter.find('_Installation', installationSchema, {}, {}))
|
||||
.then(results => {
|
||||
expect(results.length).toEqual(1);
|
||||
input = {
|
||||
@@ -1179,9 +1063,7 @@ describe('Installations', () => {
|
||||
};
|
||||
return rest.create(config, auth.nobody(config), '_Installation', input);
|
||||
})
|
||||
.then(() =>
|
||||
database.adapter.find('_Installation', installationSchema, {}, {})
|
||||
)
|
||||
.then(() => database.adapter.find('_Installation', installationSchema, {}, {}))
|
||||
.then(results => {
|
||||
expect(results.length).toEqual(1);
|
||||
expect(results[0].deviceToken).toEqual(t);
|
||||
@@ -1211,9 +1093,7 @@ describe('Installations', () => {
|
||||
};
|
||||
return request({
|
||||
headers: headers,
|
||||
url:
|
||||
'http://localhost:8378/1/installations/' +
|
||||
createResult.response.objectId,
|
||||
url: 'http://localhost:8378/1/installations/' + createResult.response.objectId,
|
||||
}).then(response => {
|
||||
const body = response.data;
|
||||
expect(body.objectId).toEqual(createResult.response.objectId);
|
||||
@@ -1299,31 +1179,29 @@ describe('Installations', () => {
|
||||
installationId: installId,
|
||||
deviceType: device,
|
||||
};
|
||||
rest
|
||||
.create(config, auth.nobody(config), '_Installation', input)
|
||||
.then(() => {
|
||||
const query = new Parse.Query(Parse.Installation);
|
||||
query.equalTo('installationId', installId);
|
||||
query
|
||||
.first({ useMasterKey: true })
|
||||
.then(installation => {
|
||||
return installation.save(
|
||||
{
|
||||
key: 'value',
|
||||
},
|
||||
{ useMasterKey: true }
|
||||
);
|
||||
})
|
||||
.then(
|
||||
() => {
|
||||
done();
|
||||
rest.create(config, auth.nobody(config), '_Installation', input).then(() => {
|
||||
const query = new Parse.Query(Parse.Installation);
|
||||
query.equalTo('installationId', installId);
|
||||
query
|
||||
.first({ useMasterKey: true })
|
||||
.then(installation => {
|
||||
return installation.save(
|
||||
{
|
||||
key: 'value',
|
||||
},
|
||||
err => {
|
||||
jfail(err);
|
||||
done();
|
||||
}
|
||||
{ useMasterKey: true }
|
||||
);
|
||||
});
|
||||
})
|
||||
.then(
|
||||
() => {
|
||||
done();
|
||||
},
|
||||
err => {
|
||||
jfail(err);
|
||||
done();
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('should properly reject updating installationId', done => {
|
||||
@@ -1333,36 +1211,32 @@ describe('Installations', () => {
|
||||
installationId: installId,
|
||||
deviceType: device,
|
||||
};
|
||||
rest
|
||||
.create(config, auth.nobody(config), '_Installation', input)
|
||||
.then(() => {
|
||||
const query = new Parse.Query(Parse.Installation);
|
||||
query.equalTo('installationId', installId);
|
||||
query
|
||||
.first({ useMasterKey: true })
|
||||
.then(installation => {
|
||||
return installation.save(
|
||||
{
|
||||
key: 'value',
|
||||
installationId: '22222222-abcd-abcd-abcd-123456789abc',
|
||||
},
|
||||
{ useMasterKey: true }
|
||||
);
|
||||
})
|
||||
.then(
|
||||
() => {
|
||||
fail('should not succeed');
|
||||
done();
|
||||
rest.create(config, auth.nobody(config), '_Installation', input).then(() => {
|
||||
const query = new Parse.Query(Parse.Installation);
|
||||
query.equalTo('installationId', installId);
|
||||
query
|
||||
.first({ useMasterKey: true })
|
||||
.then(installation => {
|
||||
return installation.save(
|
||||
{
|
||||
key: 'value',
|
||||
installationId: '22222222-abcd-abcd-abcd-123456789abc',
|
||||
},
|
||||
err => {
|
||||
expect(err.code).toBe(136);
|
||||
expect(err.message).toBe(
|
||||
'installationId may not be changed in this operation'
|
||||
);
|
||||
done();
|
||||
}
|
||||
{ useMasterKey: true }
|
||||
);
|
||||
});
|
||||
})
|
||||
.then(
|
||||
() => {
|
||||
fail('should not succeed');
|
||||
done();
|
||||
},
|
||||
err => {
|
||||
expect(err.code).toBe(136);
|
||||
expect(err.message).toBe('installationId may not be changed in this operation');
|
||||
done();
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
// TODO: Look at additional tests from installation_collection_test.go:882
|
||||
|
||||
Reference in New Issue
Block a user