|
| 1 | +'use strict'; |
| 2 | + |
1 | 3 | var Config = require('../src/Config'); |
2 | 4 | var Schema = require('../src/Schema'); |
3 | 5 | var dd = require('deep-diff'); |
@@ -512,24 +514,31 @@ describe('Schema', () => { |
512 | 514 | it('drops related collection when deleting relation field', done => { |
513 | 515 | var obj1 = hasAllPODobject(); |
514 | 516 | obj1.save() |
515 | | - .then(savedObj1 => { |
516 | | - var obj2 = new Parse.Object('HasPointersAndRelations'); |
517 | | - obj2.set('aPointer', savedObj1); |
518 | | - var relation = obj2.relation('aRelation'); |
519 | | - relation.add(obj1); |
520 | | - return obj2.save(); |
521 | | - }) |
522 | | - .then(() => { |
523 | | - config.database.adapter.database.collection('test__Join:aRelation:HasPointersAndRelations', { strict: true }, (err, coll) => { |
524 | | - expect(err).toEqual(null); |
525 | | - config.database.loadSchema() |
526 | | - .then(schema => schema.deleteField('aRelation', 'HasPointersAndRelations', config.database)) |
527 | | - .then(() => config.database.adapter.database.collection('test__Join:aRelation:HasPointersAndRelations', { strict: true }, (err, coll) => { |
528 | | - expect(err).not.toEqual(null); |
529 | | - done(); |
530 | | - })); |
| 517 | + .then(savedObj1 => { |
| 518 | + var obj2 = new Parse.Object('HasPointersAndRelations'); |
| 519 | + obj2.set('aPointer', savedObj1); |
| 520 | + var relation = obj2.relation('aRelation'); |
| 521 | + relation.add(obj1); |
| 522 | + return obj2.save(); |
| 523 | + }) |
| 524 | + .then(() => config.database.collectionExists('_Join:aRelation:HasPointersAndRelations')) |
| 525 | + .then(exists => { |
| 526 | + if (!exists) { |
| 527 | + fail('Relation collection should exist after save.'); |
| 528 | + } |
| 529 | + }) |
| 530 | + .then(() => config.database.loadSchema()) |
| 531 | + .then(schema => schema.deleteField('aRelation', 'HasPointersAndRelations', config.database)) |
| 532 | + .then(() => config.database.collectionExists('_Join:aRelation:HasPointersAndRelations')) |
| 533 | + .then(exists => { |
| 534 | + if (exists) { |
| 535 | + fail('Relation collection should not exist after deleting relation field.'); |
| 536 | + } |
| 537 | + done(); |
| 538 | + }, error => { |
| 539 | + fail(error); |
| 540 | + done(); |
531 | 541 | }); |
532 | | - }) |
533 | 542 | }); |
534 | 543 |
|
535 | 544 | it('can delete string fields and resave as number field', done => { |
|
0 commit comments