Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
mtrezza committed Oct 25, 2023
1 parent d45f503 commit 39c9873
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions spec/MongoStorageAdapter.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,40 +215,41 @@ describe_only_db('mongo')('MongoStorageAdapter', () => {

it('upserts with $setOnInsert', async () => {
const uuid = require('uuid');
const schema = {
className: 'MyClass',
fields: {
x: { type: 'Number' },
count: { type: 'Number' },
},
};
const uuid1 = uuid.v4();
const uuid2 = uuid.v4();
const query = {
x: 1,
};
const update = {
objectId: {
__op: 'SetOnInsert',
amount: uuid.v4(),
amount: uuid1,
},
x: 1,
count: {
__op: 'Increment',
amount: 1,
},
};
const res1 = await Parse.Server.database.update(
schema,
await Parse.Server.database.update(
'MyClass',
query,
update,
{ upsert: true },
);
update.objectId.amount = uuid.v4();
const res2 = await Parse.Server.database.update(
schema,
update.objectId.amount = uuid2;
await Parse.Server.database.update(
'MyClass',
query,
update,
{ upsert: true },
);
const q = new Parse.Query('MyClass');
const docs = await q.find();
expect(docs.length).toBe(1);
expect(docs[0].id).toBe(uuid1);
expect(docs[0].get('x')).toBe(1);
expect(docs[0].get('count')).toBe(2);
});

it('handles updating a single object with array, object date', done => {
Expand Down

0 comments on commit 39c9873

Please sign in to comment.