Skip to content

Commit

Permalink
Updates tests for new point property to avoid drivers that don't supp…
Browse files Browse the repository at this point in the history
…ort it (like sqlite) (#221)
  • Loading branch information
dresende committed Jul 8, 2013
1 parent 1df422a commit a97197f
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 45 deletions.
58 changes: 30 additions & 28 deletions test/integration2/model-get.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,32 +277,34 @@ describe("Model.get()", function() {
});
});

describe("with a point property type", function() {
before(function (done) {
Person = db.define("person", {
name : String,
location: {type: 'point'}
});

ORM.singleton.clear();

return helper.dropSync(Person, function () {
Person.create([{
name : "John Doe",
location: {x: 51.5177, y: -0.0968}
}], done);
});
});

it("should deserialize the point to an array", function (done) {
Person.get("John Doe", function(err, person) {
should.equal(err, null);

person.location.should.be.an.instanceOf(Object);
person.location.should.have.property('x', 51.5177);
person.location.should.have.property('y', -0.0968);
return done();
});
});
});
describe("with a point property type", function() {
it("should deserialize the point to an array", function (done) {
db.settings.set('properties.primary_key', 'id');

Person = db.define("person", {
name : String,
location : { type: "point" }
});

ORM.singleton.clear();

return helper.dropSync(Person, function (err) {
if (err) {
return done(); // not supported
}

Person.create({
name : "John Doe",
location : { x : 51.5177, y : -0.0968 }
}, function (err, person) {
should.equal(err, null);

person.location.should.be.an.instanceOf(Object);
person.location.should.have.property('x', 51.5177);
person.location.should.have.property('y', -0.0968);
return done();
});
});
});
});
});
38 changes: 21 additions & 17 deletions test/integration2/model-save.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,21 +197,25 @@ describe("Model.save()", function() {
});
});

describe("with a point property", function () {
before(setup({type: 'point'}, null));

it("should save the instance as a geospatial point", function (done) {
var John = new Person({
name: {x: 51.5177, y: -0.0968}
});
John.save(function (err) {
should.equal(err, null);

John.name.should.be.an.instanceOf(Object);
John.name.should.have.property('x', 51.5177);
John.name.should.have.property('y', -0.0968);
return done();
});
});
});
describe("with a point property", function () {
it("should save the instance as a geospatial point", function (done) {
setup({ type: "point" }, null)(function (err) {
if (err) {
return done(); // not supported
}

var John = new Person({
name: { x: 51.5177, y: -0.0968 }
});
John.save(function (err) {
should.equal(err, null);

John.name.should.be.an.instanceOf(Object);
John.name.should.have.property('x', 51.5177);
John.name.should.have.property('y', -0.0968);
return done();
});
});
});
});
});

0 comments on commit a97197f

Please sign in to comment.