Skip to content

Commit

Permalink
add test for pins with empty bbox
Browse files Browse the repository at this point in the history
  • Loading branch information
ronhippler committed Dec 15, 2015
1 parent 9d1c57a commit 9a83704
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 63 deletions.
Empty file added test/data/empty.json
Empty file.
142 changes: 79 additions & 63 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,84 +170,100 @@ describe('dvb.find "Zellescher Weg"', function () {
});
});

describe('dvb.pins "51.026578, 13.713899, 51.035565, 13.737974, stop"', function () {
mockRequest('pins-stop.json');
describe('dvb.pins', function () {

it('should resolve into an array', function (done) {
dvb.pins(51.026578, 13.713899, 51.035565, 13.737974, 'stop')
.then(function (data) {
assert(Array.isArray(data));
assert.notEqual(0, data.length);
done();
});
});
describe('dvb.pins "51.026578, 13.713899, 51.035565, 13.737974, stop"', function () {
mockRequest('pins-stop.json');

it('should contain objects with id, name, coords and connections', function (done) {
dvb.pins(51.026578, 13.713899, 51.035565, 13.737974, 'stop')
.then(function (data) {
data.forEach(function (elem) {
assert(elem.id);
assert(elem.name);
assert(elem.coords);
assert.strictEqual(2, elem.coords.length);
assert.strictEqual(13, Math.floor(elem.coords[1]));
assert.strictEqual(51, Math.floor(elem.coords[0]));
assert.strictEqual(13, Math.floor(elem.coords[1]));
assert(Array.isArray(elem.connections));
elem.connections.forEach(function (con) {
assert(con.line);
assert(con.type);
it('should resolve into an array', function (done) {
dvb.pins(51.026578, 13.713899, 51.035565, 13.737974, 'stop')
.then(function (data) {
assert(Array.isArray(data));
assert.notEqual(0, data.length);
done();
});
});

it('should contain objects with id, name, coords and connections', function (done) {
dvb.pins(51.026578, 13.713899, 51.035565, 13.737974, 'stop')
.then(function (data) {
data.forEach(function (elem) {
assert(elem.id);
assert(elem.name);
assert(elem.coords);
assert.strictEqual(2, elem.coords.length);
assert.strictEqual(13, Math.floor(elem.coords[1]));
assert.strictEqual(51, Math.floor(elem.coords[0]));
assert.strictEqual(13, Math.floor(elem.coords[1]));
assert(Array.isArray(elem.connections));
elem.connections.forEach(function (con) {
assert(con.line);
assert(con.type);
});
});
done();
});
});

it('should return a Promise but still accept a callback', function (done) {
dvb.pins(51.026578, 13.713899, 51.035565, 13.737974, 'stop', function (err, data) {
assert(data);
done();
});
}).then(assert);
});
});

it('should return a Promise but still accept a callback', function (done) {
dvb.pins(51.026578, 13.713899, 51.035565, 13.737974, 'stop', function (err, data) {
assert(data);
done();
}).then(assert);
describe('dvb.pins "51.026578, 13.713899, 51.035565, 13.737974, platform"', function () {
mockRequest('pins-platform.json');

it('should contain objects with name, coords and platform_nr', function (done) {
dvb.pins(51.026578, 13.713899, 51.035565, 13.737974, 'platform')
.then(function (data) {
assert.notEqual(0, data.length);
data.forEach(function (elem) {
assert(elem.name);
assert(elem.coords);
assert.strictEqual(2, elem.coords.length);
assert.strictEqual(13, Math.floor(elem.coords[1]));
assert.strictEqual(51, Math.floor(elem.coords[0]));
assert(elem.platform_nr);
});
done();
});
});
});
});

describe('dvb.pins "51.026578, 13.713899, 51.035565, 13.737974, platform"', function () {
mockRequest('pins-platform.json');
describe('dvb.pins "51.026578, 13.713899, 51.035565, 13.737974, POI"', function () {
mockRequest('pins-poi.json');

it('should contain objects with name, coords and platform_nr', function (done) {
dvb.pins(51.026578, 13.713899, 51.035565, 13.737974, 'platform')
.then(function (data) {
assert.notEqual(0, data.length);
data.forEach(function (elem) {
assert(elem.name);
assert(elem.coords);
assert.strictEqual(2, elem.coords.length);
assert.strictEqual(13, Math.floor(elem.coords[1]));
assert.strictEqual(51, Math.floor(elem.coords[0]));
assert(elem.platform_nr);
it('should contain objects with name, coords and id', function (done) {
dvb.pins(51.026578, 13.713899, 51.035565, 13.737974, dvb.pins.type.POI)
.then(function (data) {
assert.notEqual(0, data.length);
data.forEach(function (elem) {
assert(elem.id);
assert(elem.name);
assert(elem.coords);
assert.strictEqual(2, elem.coords.length);
assert.strictEqual(13, Math.floor(elem.coords[1]));
assert.strictEqual(51, Math.floor(elem.coords[0]));
});
done();
});
done();
});
});
});
});

describe('dvb.pins "51.026578, 13.713899, 51.035565, 13.737974, POI"', function () {
mockRequest('pins-poi.json');
describe('dvb.pins "0, 0, 0, 0, stop"', function () {
mockRequest('empty.json');

it('should contain objects with name, coords and id', function (done) {
dvb.pins(51.026578, 13.713899, 51.035565, 13.737974, dvb.pins.type.POI)
.then(function (data) {
assert.notEqual(0, data.length);
data.forEach(function (elem) {
assert(elem.id);
assert(elem.name);
assert(elem.coords);
assert.strictEqual(2, elem.coords.length);
assert.strictEqual(13, Math.floor(elem.coords[1]));
assert.strictEqual(51, Math.floor(elem.coords[0]));
it('should resolve into an empty array', function (done) {
dvb.pins(0, 0, 0, 0, dvb.pins.type.STOP)
.then(function (data) {
assert(Array.isArray(data));
assert.equal(0, data.length);
done();
});
done();
});
});
});
});

Expand Down

0 comments on commit 9a83704

Please sign in to comment.