Skip to content

Commit

Permalink
Fix failing tests for hasOne reversed find
Browse files Browse the repository at this point in the history
  • Loading branch information
notheotherben committed Aug 10, 2013
1 parent b8622ef commit 7f49c12
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions test/integration/association-hasone-reverse.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ describe("hasOne", function () {
name : String
});
Person.hasOne('pet', Pet, {
reverse: 'owner',
field: 'ownerId'
reverse: 'owner'
});

return helper.dropSync([ Person, Pet ], function () {
Expand Down Expand Up @@ -118,17 +117,20 @@ describe("hasOne", function () {
it("should be able to find given an association id", function (done) {
Person.find({ name: "John Doe" }).first(function (err, John) {
should.not.exist(err);
should.exist(John);
Pet.find({ name: "Deco" }).first(function (err, Deco) {
should.not.exist(err);
should.exist(Deco);
Deco.hasOwner(function (err, has_owner) {
should.not.exist(err);
has_owner.should.be.false;

Deco.setOwner(John, function (err) {
should.not.exist(err);

Pet.find({ ownerId: John.id }).first(function (err, owner) {
Person.find({ pet_id: Deco.id }).first(function (err, owner) {
should.not.exist(err);
should.exist(owner);
should.equal(owner.id, John.id);
done();
});
Expand All @@ -142,17 +144,20 @@ describe("hasOne", function () {
it("should be able to find given an association instance", function (done) {
Person.find({ name: "John Doe" }).first(function (err, John) {
should.not.exist(err);
should.exist(John);
Pet.find({ name: "Deco" }).first(function (err, Deco) {
should.not.exist(err);
should.exist(Deco);
Deco.hasOwner(function (err, has_owner) {
should.not.exist(err);
has_owner.should.be.false;

Deco.setOwner(John, function (err) {
should.not.exist(err);

Pet.find({ owner: John }).first(function (err, owner) {
Person.find({ pet: Deco }).first(function (err, owner) {
should.not.exist(err);
should.exist(owner);
should.equal(owner.id, John.id);
done();
});
Expand Down

0 comments on commit 7f49c12

Please sign in to comment.