Skip to content

Adds repro for issue #4762 #4764

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

Closed
wants to merge 3 commits into from
Closed
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
94 changes: 94 additions & 0 deletions spec/ParseQuery.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3496,4 +3496,98 @@ describe('Parse.Query testing', () => {
})
});

it('should repro issue #4762', (done) => {
const objects = [1,2,3,4,5].map((idx) => {
const obj = new Parse.Object('Object');
obj.set('key', idx);
return obj;
});
let parent;
Parse.Object.saveAll(objects).then(() => {
parent = new Parse.Object('Parent');
parent.set('objects', objects.slice(0, 3));

const parent2 = new Parse.Object('Parent');
parent2.set('objects', [objects[1]]);

const parent3 = new Parse.Object('Parent');
parent3.set('objects', []);

return Parse.Object.saveAll([parent, parent2, parent3]);
}).then(() => {
const query = new Parse.Query('Parent');
query.containsAll('objects', objects.slice(0,2));
return query.find();
}).then((result) => {
expect(result[0].id).not.toBeUndefined();
expect(result[0].id).toBe(parent.id);
expect(result.length).toBe(1);
}).then(done).catch(done.fail);
});

it('should repro issue #4762 with multiple results', (done) => {
const objects = [1,2,3,4,5,6,7,8].map((idx) => {
const obj = new Parse.Object('Object');
obj.set('key', idx);
return obj;
});
let parent;
let parent3;
Parse.Object.saveAll(objects).then(() => {
parent = new Parse.Object('Parent');
parent.set('objects', objects.slice(0, 3));

const parent2 = new Parse.Object('Parent');
parent2.set('objects', [objects[1]]);

parent3 = new Parse.Object('Parent');
parent3.set('objects', objects.slice(1, 4));

return Parse.Object.saveAll([parent, parent2, parent3]);
}).then(() => {
const query = new Parse.Query('Parent');
query.containsAll('objects', objects.slice(1,3));
return query.find();
}).then((result) => {
const has0 = [parent.id, parent3.id].indexOf(result[0].id) >= 0;
const has1 = [parent.id, parent3.id].indexOf(result[1].id) >= 1;
expect(result[0].id).not.toBeUndefined();
expect(result[1].id).not.toBeUndefined();
expect(has1).toBeTruthy();
expect(has0).toBeTruthy();
expect(result.length).toBe(2);
}).then(done).catch(done.fail);
});

it('should repro issue #4762 with multiple results and $in operator', (done) => {
const objects = [1,2,3,4,5,6,7,8].map((idx) => {
const obj = new Parse.Object('Object');
obj.set('key', idx);
return obj;
});

Parse.Object.saveAll(objects).then(() => {
const parent = new Parse.Object('Parent');
parent.set('objects', objects.slice(0, 3));

const parent2 = new Parse.Object('Parent');
parent2.set('objects', [objects[1]]);

const parent3 = new Parse.Object('Parent');
parent3.set('objects', objects.slice(1, 4));

const parent4 = new Parse.Object('Parent');

return Parse.Object.saveAll([parent, parent2, parent3, parent4]);
}).then(() => {
const query = new Parse.Query('Parent');
query.containedIn('objects', objects);
return query.find();
}).then((result) => {
expect(result[0].id).not.toBeUndefined();
expect(result[1].id).not.toBeUndefined();
expect(result[2].id).not.toBeUndefined();
expect(result.length).toBe(3);
}).then(done).catch(done.fail);
})
});