diff --git a/test/integration/association-hasone-reverse-async.js b/test/integration/association-hasone-reverse-async.js index 6d10d79b..a15bd675 100644 --- a/test/integration/association-hasone-reverse-async.js +++ b/test/integration/association-hasone-reverse-async.js @@ -142,23 +142,25 @@ describe("hasOne Async", function () { it("should be able to find given an association id", function () { return Person .findAsync({ name: "John Doe" }) - .then(function (John) { + .then(function (persons) { + var John = persons[0]; should.exist(John); return [John, Pet.findAsync({ name: "Deco" })]; }) .spread(function (John, Deco) { + var Deco = Deco[0]; should.exist(Deco); - return [John[0], Deco[0], Deco[0].hasOwnersAsync()]; + return [John, Deco, Deco.hasOwnersAsync()]; }) .spread(function (John, Deco, has_owner) { has_owner.should.equal(false); - return [John, Deco.setOwnersAsync(John)]; + return [John, Deco, Deco.setOwnersAsync(John)]; }) - .spread(function (John) { - return [John, Person.findAsync({ pet_id: 1 })]; + .spread(function (John, Deco) { + return [John, Person.findAsync({ pet_id: Deco[Pet.id] })]; }) .spread(function (John, owner) { - should.exist(owner[0]); + should.exist(owner); should.equal(owner[0].name, John.name); }); }); @@ -178,14 +180,14 @@ describe("hasOne Async", function () { }) .spread(function (John, Deco, has_owner) { has_owner.should.equal(false); - return [John, Deco.setOwnersAsync(John)]; + return [John, Deco, Deco.setOwnersAsync(John)]; }) .spread(function (John, Deco) { return [John, Person.findAsync({ pet: Deco })]; }) .spread(function(John, owner){ - should.exist(owner[1]); - should.equal(owner[1].name, John.name); + should.exist(owner[0]); + should.equal(owner[0].name, John.name); }); }); diff --git a/test/integration/association-hasone-zeroid-async.js b/test/integration/association-hasone-zeroid-async.js index b872a99d..29f3777e 100644 --- a/test/integration/association-hasone-zeroid-async.js +++ b/test/integration/association-hasone-zeroid-async.js @@ -82,16 +82,16 @@ describe("hasOne promise-based methods", function() { return Pet .findAsync({petName: "Snagglepuss"}) .then(function(pets) { - pets[0].petName.should.equal("Snagglepuss"); - pets[0].should.have.property("id"); - pets[0].id.should.equal(11); + var pet = pets[0]; + pet.petName.should.equal("Snagglepuss"); + pet.should.have.property("id"); + pet.id.should.equal(11); return Person.allAsync(); }) .then(function (people) { should.equal(typeof people[0], 'object'); should.equal(Array.isArray(people), true); - people[0].should.have.property("firstName", "Stuey"); }); }); });