Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Improve test for $setOnInsert #8793

Merged
merged 1 commit into from
Oct 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 23 additions & 7 deletions spec/MongoStorageAdapter.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand All @@ -266,7 +279,6 @@ describe_only_db('mongo')('MongoStorageAdapter', () => {
__op: 'SetOnInsert',
amount: uuid1,
},
x: 1,
count: {
__op: 'Increment',
amount: 1,
Expand All @@ -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 => {
Expand Down