Skip to content

Commit

Permalink
Merge branch 'feat/http-codes' of https://github.com/dblythy/parse-se…
Browse files Browse the repository at this point in the history
…rver into feat/http-codes
  • Loading branch information
dblythy committed Dec 23, 2024
2 parents ab03153 + 1c42f55 commit da8af05
Show file tree
Hide file tree
Showing 72 changed files with 7,446 additions and 6,535 deletions.
107 changes: 55 additions & 52 deletions spec/AudienceRouter.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,59 +317,62 @@ describe('AudiencesRouter', () => {
);
});

it_id('af1111b5-3251-4b40-8f06-fb0fc624fa91')(it_exclude_dbs(['postgres']))('should support legacy parse.com audience fields', done => {
const database = Config.get(Parse.applicationId).database.adapter.database;
const now = new Date();
Parse._request(
'POST',
'push_audiences',
{ name: 'My Audience', query: JSON.stringify({ deviceType: 'ios' }) },
{ useMasterKey: true }
).then(audience => {
database
.collection('test__Audience')
.updateOne(
{ _id: audience.objectId },
{
$set: {
times_used: 1,
_last_used: now,
},
}
)
.then(result => {
expect(result).toBeTruthy();
it_id('af1111b5-3251-4b40-8f06-fb0fc624fa91')(it_exclude_dbs(['postgres']))(
'should support legacy parse.com audience fields',
done => {
const database = Config.get(Parse.applicationId).database.adapter.database;
const now = new Date();
Parse._request(
'POST',
'push_audiences',
{ name: 'My Audience', query: JSON.stringify({ deviceType: 'ios' }) },
{ useMasterKey: true }
).then(audience => {
database
.collection('test__Audience')
.updateOne(
{ _id: audience.objectId },
{
$set: {
times_used: 1,
_last_used: now,
},
}
)
.then(result => {
expect(result).toBeTruthy();

database
.collection('test__Audience')
.find({ _id: audience.objectId })
.toArray()
.then(rows => {
expect(rows[0]['times_used']).toEqual(1);
expect(rows[0]['_last_used']).toEqual(now);
Parse._request(
'GET',
'push_audiences/' + audience.objectId,
{},
{ useMasterKey: true }
)
.then(audience => {
expect(audience.name).toEqual('My Audience');
expect(audience.query.deviceType).toEqual('ios');
expect(audience.timesUsed).toEqual(1);
expect(audience.lastUsed).toEqual(now.toISOString());
done();
})
.catch(error => {
done.fail(error);
});
})
.catch(error => {
done.fail(error);
});
});
});
});
database
.collection('test__Audience')
.find({ _id: audience.objectId })
.toArray()
.then(rows => {
expect(rows[0]['times_used']).toEqual(1);
expect(rows[0]['_last_used']).toEqual(now);
Parse._request(
'GET',
'push_audiences/' + audience.objectId,
{},
{ useMasterKey: true }
)
.then(audience => {
expect(audience.name).toEqual('My Audience');
expect(audience.query.deviceType).toEqual('ios');
expect(audience.timesUsed).toEqual(1);
expect(audience.lastUsed).toEqual(now.toISOString());
done();
})
.catch(error => {
done.fail(error);
});
})
.catch(error => {
done.fail(error);
});
});
});
}
);

it('should be able to search on audiences', done => {
Parse._request(
Expand Down
10 changes: 2 additions & 8 deletions spec/Auth.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,16 +237,10 @@ describe('extendSessionOnUse', () => {
const { shouldUpdateSessionExpiry } = require('../lib/Auth');
let update = new Date(Date.now() - 86410 * 1000);

const res = shouldUpdateSessionExpiry(
{ sessionLength: 86460 },
{ updatedAt: update }
);
const res = shouldUpdateSessionExpiry({ sessionLength: 86460 }, { updatedAt: update });

update = new Date(Date.now() - 43210 * 1000);
const res2 = shouldUpdateSessionExpiry(
{ sessionLength: 86460 },
{ updatedAt: update }
);
const res2 = shouldUpdateSessionExpiry({ sessionLength: 86460 }, { updatedAt: update });

expect(res).toBe(true);
expect(res2).toBe(false);
Expand Down
Loading

0 comments on commit da8af05

Please sign in to comment.