diff --git a/interfaces/migratable/migrate.create.test.js b/interfaces/migratable/migrate.create.test.js index 67f0cea..aa986b2 100644 --- a/interfaces/migratable/migrate.create.test.js +++ b/interfaces/migratable/migrate.create.test.js @@ -19,7 +19,7 @@ var newFixture = { gender : 'string' } }) -}; +}; describe('Migratable Interface', function() { @@ -30,92 +30,91 @@ describe('Migratable Interface', function() { function runTests(collectionName) { - it('should have the proper migrate setting when bootstrapping', function() { - assert(Migratable[collectionName].migrate === 'create'); + it('should have the proper migrate setting when bootstrapping', function() { + assert(Migratable[collectionName].migrate === 'create'); + }); + + it('should have tables', function(done) { + Migratable[collectionName].describe(function(err, schema) { + assert(!err); + assert(schema); + done(); }); + }); - it('should have tables', function(done) { - Migratable[collectionName].describe(function(err, schema) { - assert(!err); - assert(schema); - done(); + + describe('teardown and migrate existing data', function() { + + before(function(done) { + Migratable[collectionName].create({ name: 'blackbeard' }, done); + }); + + it('should retain the data when bootstrapped the second time', function(done) { + Migratable.waterline.teardown(function(err) { + bootstrapFn(function(err, obj) { + assert(!err); + var ontology = obj.ontology; + ontology.collections[collectionName.toLowerCase()].findOne({name: 'blackbeard'}) + .exec(function(err, pirate) { + assert(!err); + assert.equal(pirate.name, 'blackbeard'); + done(); + }); + }); }); }); + }); - describe('teardown and migrate existing data', function() { + describe('teardown and migrate existing data after adding property', function() { - before(function(done) { - Migratable[collectionName].create({ name: 'blackbeard' }, done); - }); + var collection; - it('should retain the data when bootstrapped the second time', function(done) { + before(function(done) { + Migratable[collectionName].create({ name : 'bluebeard' }, function(err) { + if(err) { return done(err); } Migratable.waterline.teardown(function(err) { - bootstrapFn(function(err, obj) { + bootstrapFn(newFixture, function(err, obj) { assert(!err); var ontology = obj.ontology; - ontology.collections[collectionName.toLowerCase()].findOne({name: 'blackbeard'}) - .exec(function(err, pirate) { - assert(!err); - assert(pirate.name, 'blackbeard'); - done(); - }); + ontology.collections[collectionName.toLowerCase()].findOne({name: 'bluebeard'}); + collection = ontology.collections[collectionName.toLowerCase()]; + done(); }); }); }); }); - - - describe('teardown and migrate existing data after adding property', function() { - - var collection; - - before(function(done) { - Migratable[collectionName].create({ name : 'bluebeard' }, function(err) { - if(err) { return done(err); } - Migratable.waterline.teardown(function(err) { - bootstrapFn(newFixture, function(err, obj) { - assert(!err); - var ontology = obj.ontology; - ontology.collections[collectionName.toLowerCase()].findOne({name: 'bluebeard'}); - collection = ontology.collections[collectionName.toLowerCase()]; - done(); - }); - }); - }); - }); - - it('should retain the data when bootstrapped the second time', function(done) { - collection.findOne({name: 'bluebeard'}) - .exec(function(err, pirate) { - assert(!err); - assert(pirate.name, 'bluebeard'); - done(); - }); + + it('should retain the data when bootstrapped the second time', function(done) { + collection.findOne({name: 'bluebeard'}) + .exec(function(err, pirate) { + assert(!err); + assert.equal(pirate.name, 'bluebeard'); + done(); }); - - it('should have new attribute', function(done) { - collection.describe(function(err, schema) { - assert(!err); - assert(schema); - assert(schema.name); - assert(schema.gender); - done(); - }); + }); + + it('should have new attribute', function(done) { + collection.describe(function(err, schema) { + assert(!err); + assert(schema); + assert(schema.name); + assert(schema.gender); + done(); }); + }); - it('should be able to record data using new attribute', function(done) { - collection.create({ name: 'whitebeard', gender: 'male' }) - .exec(function(err, newPirate) { - assert(!err); - console.log('\n newPirate:', newPirate); - assert(newPirate.name, 'whitebeard'); - assert(newPirate.gender, 'male'); // requires addAttribute - done(); - }); + it('should be able to record data using new attribute', function(done) { + collection.create({ name: 'whitebeard', gender: 'male' }) + .exec(function(err, newPirate) { + assert(!err); + assert.equal(newPirate.name, 'whitebeard'); + assert.equal(newPirate.gender, 'male'); // requires addAttribute + done(); }); - }); + + }); } });