test: Improve test for $setOnInsert (#8793)
This commit is contained in:
@@ -258,6 +258,19 @@ describe_only_db('mongo')('MongoStorageAdapter', () => {
|
||||
const uuid = require('uuid');
|
||||
const uuid1 = uuid.v4();
|
||||
const uuid2 = uuid.v4();
|
||||
const schema = {
|
||||
className: 'MyClass',
|
||||
fields: {
|
||||
x: { type: 'Number' },
|
||||
count: { type: 'Number' },
|
||||
},
|
||||
classLevelPermissions: {},
|
||||
};
|
||||
|
||||
const myClassSchema = new Parse.Schema(schema.className);
|
||||
myClassSchema.setCLP(schema.classLevelPermissions);
|
||||
await myClassSchema.save();
|
||||
|
||||
const query = {
|
||||
x: 1,
|
||||
};
|
||||
@@ -266,7 +279,6 @@ describe_only_db('mongo')('MongoStorageAdapter', () => {
|
||||
__op: 'SetOnInsert',
|
||||
amount: uuid1,
|
||||
},
|
||||
x: 1,
|
||||
count: {
|
||||
__op: 'Increment',
|
||||
amount: 1,
|
||||
@@ -285,12 +297,16 @@ describe_only_db('mongo')('MongoStorageAdapter', () => {
|
||||
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);
|
||||
|
||||
const res = await Parse.Server.database.find(
|
||||
schema.className,
|
||||
{},
|
||||
{},
|
||||
);
|
||||
expect(res.length).toBe(1);
|
||||
expect(res[0].objectId).toBe(uuid1);
|
||||
expect(res[0].count).toBe(2);
|
||||
expect(res[0].x).toBe(1);
|
||||
});
|
||||
|
||||
it('handles updating a single object with array, object date', done => {
|
||||
|
||||
Reference in New Issue
Block a user