Skip to content

Commit a97197f

Browse files
committed
Updates tests for new point property to avoid drivers that don't support it (like sqlite) (#221)
1 parent 1df422a commit a97197f

File tree

2 files changed

+51
-45
lines changed

2 files changed

+51
-45
lines changed

test/integration2/model-get.js

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -277,32 +277,34 @@ describe("Model.get()", function() {
277277
});
278278
});
279279

280-
describe("with a point property type", function() {
281-
before(function (done) {
282-
Person = db.define("person", {
283-
name : String,
284-
location: {type: 'point'}
285-
});
286-
287-
ORM.singleton.clear();
288-
289-
return helper.dropSync(Person, function () {
290-
Person.create([{
291-
name : "John Doe",
292-
location: {x: 51.5177, y: -0.0968}
293-
}], done);
294-
});
295-
});
296-
297-
it("should deserialize the point to an array", function (done) {
298-
Person.get("John Doe", function(err, person) {
299-
should.equal(err, null);
300-
301-
person.location.should.be.an.instanceOf(Object);
302-
person.location.should.have.property('x', 51.5177);
303-
person.location.should.have.property('y', -0.0968);
304-
return done();
305-
});
306-
});
307-
});
280+
describe("with a point property type", function() {
281+
it("should deserialize the point to an array", function (done) {
282+
db.settings.set('properties.primary_key', 'id');
283+
284+
Person = db.define("person", {
285+
name : String,
286+
location : { type: "point" }
287+
});
288+
289+
ORM.singleton.clear();
290+
291+
return helper.dropSync(Person, function (err) {
292+
if (err) {
293+
return done(); // not supported
294+
}
295+
296+
Person.create({
297+
name : "John Doe",
298+
location : { x : 51.5177, y : -0.0968 }
299+
}, function (err, person) {
300+
should.equal(err, null);
301+
302+
person.location.should.be.an.instanceOf(Object);
303+
person.location.should.have.property('x', 51.5177);
304+
person.location.should.have.property('y', -0.0968);
305+
return done();
306+
});
307+
});
308+
});
309+
});
308310
});

test/integration2/model-save.js

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -197,21 +197,25 @@ describe("Model.save()", function() {
197197
});
198198
});
199199

200-
describe("with a point property", function () {
201-
before(setup({type: 'point'}, null));
202-
203-
it("should save the instance as a geospatial point", function (done) {
204-
var John = new Person({
205-
name: {x: 51.5177, y: -0.0968}
206-
});
207-
John.save(function (err) {
208-
should.equal(err, null);
209-
210-
John.name.should.be.an.instanceOf(Object);
211-
John.name.should.have.property('x', 51.5177);
212-
John.name.should.have.property('y', -0.0968);
213-
return done();
214-
});
215-
});
216-
});
200+
describe("with a point property", function () {
201+
it("should save the instance as a geospatial point", function (done) {
202+
setup({ type: "point" }, null)(function (err) {
203+
if (err) {
204+
return done(); // not supported
205+
}
206+
207+
var John = new Person({
208+
name: { x: 51.5177, y: -0.0968 }
209+
});
210+
John.save(function (err) {
211+
should.equal(err, null);
212+
213+
John.name.should.be.an.instanceOf(Object);
214+
John.name.should.have.property('x', 51.5177);
215+
John.name.should.have.property('y', -0.0968);
216+
return done();
217+
});
218+
});
219+
});
220+
});
217221
});

0 commit comments

Comments
 (0)