Skip to content

Commit bb385c4

Browse files
committed
Add failing testcase
1 parent 011269f commit bb385c4

File tree

1 file changed

+77
-20
lines changed

1 file changed

+77
-20
lines changed

spec/ParseQuery.spec.js

Lines changed: 77 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4008,29 +4008,86 @@ describe('Parse.Query testing', () => {
40084008
});
40094009
});
40104010

4011+
it('include pointer and pointer array', function (done) {
4012+
const child = new TestObject();
4013+
const child2 = new TestObject();
4014+
child.set('foo', 'bar');
4015+
child2.set('hello', 'world');
4016+
Parse.Object.saveAll([child, child2]).then(function () {
4017+
const parent = new Container();
4018+
parent.set('child', child.toPointer());
4019+
parent.set('child2', [child2.toPointer()]);
4020+
parent.save().then(function () {
4021+
const query = new Parse.Query(Container);
4022+
query.include(['child', 'child2']);
4023+
query.find().then(function (results) {
4024+
equal(results.length, 1);
4025+
const parentAgain = results[0];
4026+
const childAgain = parentAgain.get('child');
4027+
ok(childAgain);
4028+
equal(childAgain.get('foo'), 'bar');
4029+
const child2Again = parentAgain.get('child2');
4030+
equal(child2Again.length, 1);
4031+
ok(child2Again);
4032+
equal(child2Again[0].get('hello'), 'world');
4033+
done();
4034+
});
4035+
});
4036+
});
4037+
});
4038+
4039+
it('include pointer and pointer array (keys switched)', function (done) {
4040+
const child = new TestObject();
4041+
const child2 = new TestObject();
4042+
child.set('foo', 'bar');
4043+
child2.set('hello', 'world');
4044+
Parse.Object.saveAll([child, child2]).then(function () {
4045+
const parent = new Container();
4046+
parent.set('child', child.toPointer());
4047+
parent.set('child2', [child2.toPointer()]);
4048+
parent.save().then(function () {
4049+
const query = new Parse.Query(Container);
4050+
query.include(['child2', 'child']);
4051+
query.find().then(function (results) {
4052+
equal(results.length, 1);
4053+
const parentAgain = results[0];
4054+
const childAgain = parentAgain.get('child');
4055+
ok(childAgain);
4056+
equal(childAgain.get('foo'), 'bar');
4057+
const child2Again = parentAgain.get('child2');
4058+
equal(child2Again.length, 1);
4059+
ok(child2Again);
4060+
equal(child2Again[0].get('hello'), 'world');
4061+
done();
4062+
});
4063+
});
4064+
});
4065+
});
4066+
40114067
it('includeAll pointer and pointer array', function (done) {
4012-
const child = new Parse.Object('FirstObject');
4013-
const child2 = new Parse.Object('SecondObject');
4014-
const parent = new Parse.Object('ParentObject');
4068+
const child = new TestObject();
4069+
const child2 = new TestObject();
40154070
child.set('foo', 'bar');
40164071
child2.set('hello', 'world');
4017-
parent.set('child', child);
4018-
parent.set('child2', [child2]);
4019-
parent.save().then(function () {
4020-
const query = new Parse.Query('ParentObject');
4021-
//query.includeAll();
4022-
query.find().then(function (results) {
4023-
equal(results.length, 1);
4024-
const parentAgain = results[0];
4025-
const childAgain = parentAgain.get('child');
4026-
ok(childAgain);
4027-
equal(childAgain.get('objectId'), 'bar');
4028-
const child2Again = parentAgain.get('child2');
4029-
equal(child2Again.length, 1);
4030-
console.log(childAgain);
4031-
ok(child2Again);
4032-
equal(child2Again[0].get('__type'), 'world');
4033-
done();
4072+
Parse.Object.saveAll([child, child2]).then(function () {
4073+
const parent = new Container();
4074+
parent.set('child', child.toPointer());
4075+
parent.set('child2', [child2.toPointer()]);
4076+
parent.save().then(function () {
4077+
const query = new Parse.Query(Container);
4078+
query.includeAll();
4079+
query.find().then(function (results) {
4080+
equal(results.length, 1);
4081+
const parentAgain = results[0];
4082+
const childAgain = parentAgain.get('child');
4083+
ok(childAgain);
4084+
equal(childAgain.get('foo'), 'bar');
4085+
const child2Again = parentAgain.get('child2');
4086+
equal(child2Again.length, 1);
4087+
ok(child2Again);
4088+
equal(child2Again[0].get('hello'), 'world');
4089+
done();
4090+
});
40344091
});
40354092
});
40364093
});

0 commit comments

Comments
 (0)