Skip to content

Commit 67479fb

Browse files
committed
Add a test for empty nested includes
I had a thought that I might not be handling the case where `includePath` doesn't return a promise, but it turns out to work because now I'm only calling that method from inside a promise handler. Let's still commit the test to prevent any regressions in the future.
1 parent 03c02cd commit 67479fb

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

spec/ParseQuery.spec.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2439,6 +2439,27 @@ describe('Parse.Query testing', () => {
24392439
});
24402440
});
24412441

2442+
it('handles nested includes with no results', async () => {
2443+
const obj = new TestObject({ foo: 'bar' });
2444+
await obj.save();
2445+
2446+
const query = new Parse.Query(TestObject)
2447+
.equalTo('objectId', obj.id)
2448+
.include('fake.path');
2449+
2450+
// This query with should not reject
2451+
const results = await query.find();
2452+
2453+
// ... and we should get back the one object we saved
2454+
expect(results.length).toBe(1);
2455+
2456+
// ... and it should not add the `fake` attribute from the query that
2457+
// doesn't exist on the object
2458+
expect(
2459+
Object.prototype.hasOwnProperty.call(results[0].attributes, 'fake')
2460+
).toBeFalse();
2461+
});
2462+
24422463
it("include doesn't make dirty wrong", function(done) {
24432464
const Parent = Parse.Object.extend('ParentObject');
24442465
const Child = Parse.Object.extend('ChildObject');

0 commit comments

Comments
 (0)