Skip to content

Commit f5cedd7

Browse files
committed
fix test
1 parent 8689535 commit f5cedd7

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

spec/MongoStorageAdapter.spec.js

+15-14
Original file line numberDiff line numberDiff line change
@@ -256,42 +256,43 @@ describe_only_db('mongo')('MongoStorageAdapter', () => {
256256

257257
it('upserts with $setOnInsert', async () => {
258258
const uuid = require('uuid');
259-
const schema = {
260-
className: 'MyClass',
261-
fields: {
262-
x: { type: 'Number' },
263-
count: { type: 'Number' },
264-
},
265-
};
259+
const uuid1 = uuid.v4();
260+
const uuid2 = uuid.v4();
266261
const query = {
267262
x: 1,
268263
};
269264
const update = {
270265
objectId: {
271266
__op: 'SetOnInsert',
272-
amount: uuid.v4(),
267+
amount: uuid1,
273268
},
274269
x: 1,
275270
count: {
276271
__op: 'Increment',
277272
amount: 1,
278273
},
279274
};
280-
const res1 = await Parse.Server.database.update(
281-
schema,
275+
await Parse.Server.database.update(
276+
'MyClass',
282277
query,
283278
update,
284279
{ upsert: true },
285280
);
286-
update.objectId.amount = uuid.v4();
287-
const res2 = await Parse.Server.database.update(
288-
schema,
281+
update.objectId.amount = uuid2;
282+
await Parse.Server.database.update(
283+
'MyClass',
289284
query,
290285
update,
291286
{ upsert: true },
292287
);
288+
const q = new Parse.Query('MyClass');
289+
const docs = await q.find();
290+
expect(docs.length).toBe(1);
291+
expect(docs[0].id).toBe(uuid1);
292+
expect(docs[0].get('x')).toBe(1);
293+
expect(docs[0].get('count')).toBe(2);
293294
});
294-
295+
295296
it('handles updating a single object with array, object date', done => {
296297
const adapter = new MongoStorageAdapter({ uri: databaseURI });
297298

0 commit comments

Comments
 (0)