-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(add mapbox and mapquest static tests):
- Loading branch information
1 parent
fbd26ee
commit 51607e9
Showing
4 changed files
with
180 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
// ----------- | ||
// Tests for Mapbox Static API v1 | ||
// Reference: https://www.mapbox.com/api-documentation/#static | ||
// ----------- | ||
|
||
import { expect } from 'chai'; | ||
import Mappa from '../../src/index'; | ||
|
||
var mapboxStaticOptions = { | ||
lat: 0, | ||
lng: 0, | ||
zoom: 0, | ||
scale: 1, | ||
width: 650, | ||
height: 650 | ||
} | ||
var mapboxStaticKey = 'abcd' | ||
var mapboxStaticMappa = new Mappa('Mapbox', mapboxStaticKey); | ||
var mapboxStaticMap = mapboxStaticMappa.staticMap(mapboxStaticOptions); | ||
|
||
describe('Mapbox static instance', function () { | ||
it('should return a new mappa object with provider and key', function () { | ||
expect(mapboxStaticMappa).to.include.all.keys('provider', 'key'); | ||
}); | ||
}); | ||
|
||
describe('Mapbox static options initialization', function () { | ||
it('should return a scale of 1 if scale is undefined', function () { | ||
expect(mapboxStaticMap.options).to.have.property('scale', 1); | ||
}); | ||
it('should return a pixel option of 256 if scale is undefined', function () { | ||
expect(mapboxStaticMap.options).to.have.property('pixels', 256); | ||
}); | ||
it('should return a pixel scale option of 2 if scale is 2', function () { | ||
var mapboxStaticOptions = { | ||
lat: 0, | ||
lng: 0, | ||
zoom: 0, | ||
scale: 2, | ||
width: 650, | ||
height: 650 | ||
} | ||
var mapboxStaticMap = mapboxStaticMappa.staticMap(mapboxStaticOptions); | ||
expect(mapboxStaticMap.options).to.have.property('scale', 2); | ||
}); | ||
it('should return a pixel option of 512 if scale is 2', function () { | ||
var mapboxStaticOptions = { | ||
lat: 0, | ||
lng: 0, | ||
zoom: 0, | ||
scale: 2, | ||
width: 650, | ||
height: 650 | ||
} | ||
var mapboxStaticMap = mapboxStaticMappa.staticMap(mapboxStaticOptions); | ||
expect(mapboxStaticMap.options).to.have.property('pixels', 512); | ||
}); | ||
}); | ||
|
||
describe('Mapbox staticMap options', function () { | ||
it('should contain valid options', function () { | ||
expect(mapboxStaticMap.options).to.not.have.property('lat', undefined); | ||
expect(mapboxStaticMap.options).to.not.have.property('lng', undefined); | ||
expect(mapboxStaticMap.options).to.not.have.property('zoom', undefined); | ||
expect(mapboxStaticMap.options).to.not.have.property('width', undefined); | ||
expect(mapboxStaticMap.options).to.not.have.property('height', undefined); | ||
expect(mapboxStaticMap.options).to.not.have.property('key', undefined); | ||
expect(mapboxStaticMap.options).to.not.have.property('pixels', undefined); | ||
expect(mapboxStaticMap.options).to.not.have.property('scale', undefined); | ||
expect(mapboxStaticMap.options).to.not.have.property('size', undefined); | ||
expect(mapboxStaticMap.options).to.not.have.property('center', undefined); | ||
}); | ||
}); | ||
|
||
describe('Mapbox staticMap imgUrl', function () { | ||
it('should be a string', function () { | ||
expect(mapboxStaticMap.imgUrl).to.be.a('string'); | ||
}); | ||
it('should be a valid Mapbox Maps url', function () { | ||
expect(mapboxStaticMap.imgUrl).to.not.include('undefined'); | ||
expect(mapboxStaticMap.imgUrl).to.not.include('null'); | ||
expect(mapboxStaticMap.imgUrl).to.include('https://api.mapbox.com/styles/v1/'); | ||
expect(mapboxStaticMap.imgUrl).to.include('access_token=' + mapboxStaticKey); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
// ----------- | ||
// Tests for Mapquest v5 | ||
// Reference: https://developer.mapquest.com/documentation/static-map-api/v5/ | ||
// ----------- | ||
|
||
import { expect } from 'chai'; | ||
import Mappa from '../../src/index'; | ||
|
||
var mapquestStaticOptions = { | ||
lat: 0, | ||
lng: 0, | ||
zoom: 0, | ||
scale: 1, | ||
width: 650, | ||
height: 650 | ||
} | ||
var mapquestStaticKey = 'abcd' | ||
var mapquestStaticMappa = new Mappa('Mapquest', mapquestStaticKey); | ||
var mapquestStaticMap = mapquestStaticMappa.staticMap(mapquestStaticOptions); | ||
|
||
describe('Mapquest static instance', function () { | ||
it('should return a new mappa object with provider and key', function () { | ||
expect(mapquestStaticMappa).to.include.all.keys('provider', 'key'); | ||
}); | ||
}); | ||
|
||
describe('Mapquest static options initialization', function () { | ||
it('should return a scale of 1 if scale is undefined', function () { | ||
expect(mapquestStaticMap.options).to.have.property('scale', 1); | ||
}); | ||
it('should return a pixel option of 128 if scale is undefined', function () { | ||
expect(mapquestStaticMap.options).to.have.property('pixels', 128); | ||
}); | ||
it('should return a pixel scale option of 2 if scale is 2', function () { | ||
var mapquestStaticOptions = { | ||
lat: 0, | ||
lng: 0, | ||
zoom: 0, | ||
scale: 2, | ||
width: 650, | ||
height: 650 | ||
} | ||
var mapquestStaticMap = mapquestStaticMappa.staticMap(mapquestStaticOptions); | ||
expect(mapquestStaticMap.options).to.have.property('scale', 2); | ||
}); | ||
it('should return a pixel option of 256 if scale is 2', function () { | ||
var mapquestStaticOptions = { | ||
lat: 0, | ||
lng: 0, | ||
zoom: 0, | ||
scale: 2, | ||
width: 650, | ||
height: 650 | ||
} | ||
var mapquestStaticMap = mapquestStaticMappa.staticMap(mapquestStaticOptions); | ||
expect(mapquestStaticMap.options).to.have.property('pixels', 256); | ||
}); | ||
}); | ||
|
||
describe('Mapquest staticMap options', function () { | ||
it('should contain valid options', function () { | ||
expect(mapquestStaticMap.options).to.not.have.property('lat', undefined); | ||
expect(mapquestStaticMap.options).to.not.have.property('lng', undefined); | ||
expect(mapquestStaticMap.options).to.not.have.property('zoom', undefined); | ||
expect(mapquestStaticMap.options).to.not.have.property('width', undefined); | ||
expect(mapquestStaticMap.options).to.not.have.property('height', undefined); | ||
expect(mapquestStaticMap.options).to.not.have.property('key', undefined); | ||
expect(mapquestStaticMap.options).to.not.have.property('pixels', undefined); | ||
expect(mapquestStaticMap.options).to.not.have.property('scale', undefined); | ||
expect(mapquestStaticMap.options).to.not.have.property('size', undefined); | ||
expect(mapquestStaticMap.options).to.not.have.property('center', undefined); | ||
}); | ||
}); | ||
|
||
describe('Mapquest staticMap imgUrl', function () { | ||
it('should be a string', function () { | ||
expect(mapquestStaticMap.imgUrl).to.be.a('string'); | ||
}); | ||
it('should be a valid Mapquest Maps url', function () { | ||
expect(mapquestStaticMap.imgUrl).to.not.include('undefined'); | ||
expect(mapquestStaticMap.imgUrl).to.not.include('null'); | ||
expect(mapquestStaticMap.imgUrl).to.include('https://www.mapquestapi.com/staticmap/v5/'); | ||
expect(mapquestStaticMap.imgUrl).to.include('key=' + mapquestStaticKey); | ||
}); | ||
}); |