Skip to content
This repository has been archived by the owner on Apr 24, 2024. It is now read-only.

Commit

Permalink
fix tests for https
Browse files Browse the repository at this point in the history
  • Loading branch information
mourner committed Feb 22, 2019
1 parent 4efdbb9 commit a40d000
Show file tree
Hide file tree
Showing 10 changed files with 68 additions and 70 deletions.
15 changes: 5 additions & 10 deletions test/spec/feature_layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('L.mapbox.featureLayer', function() {
});

it('loads data from a GeoJSON URL', function() {
var url = 'http://api.tiles.mapbox.com/v4/examples.map-zr0njcqy/features.json',
var url = 'https://api.tiles.mapbox.com/v4/examples.map-zr0njcqy/features.json',
layer = L.mapbox.featureLayer(url);

server.respondWith("GET", url,
Expand Down Expand Up @@ -57,21 +57,16 @@ describe('L.mapbox.featureLayer', function() {
});

describe("#loadURL", function() {
it('returns self', function() {
var layer = L.mapbox.featureLayer();
expect(layer.loadURL('http://a.tiles.mapbox.com/v3/mapbox.map-0l53fhk2.json')).to.eql(layer);
});

it('emits a ready event', function(done) {
var layer = L.mapbox.featureLayer();

layer.on('ready', function() {
done();
});

layer.loadURL('http://a.tiles.mapbox.com/v3/mapbox.map-0l53fhk2.json');
layer.loadURL('https://a.tiles.mapbox.com/v3/mapbox.map-0l53fhk2.json');

server.respondWith("GET", "http://a.tiles.mapbox.com/v3/mapbox.map-0l53fhk2.json",
server.respondWith("GET", "https://a.tiles.mapbox.com/v3/mapbox.map-0l53fhk2.json",
[200, { "Content-Type": "application/json" }, JSON.stringify(helpers.geoJson)]);
server.respond();
});
Expand All @@ -85,9 +80,9 @@ describe('L.mapbox.featureLayer', function() {
done();
});

layer.loadURL('http://a.tiles.mapbox.com/v3/mapbox.map-0l53fhk2.json');
layer.loadURL('https://a.tiles.mapbox.com/v3/mapbox.map-0l53fhk2.json');

server.respondWith("GET", "http://a.tiles.mapbox.com/v3/mapbox.map-0l53fhk2.json",
server.respondWith("GET", "https://a.tiles.mapbox.com/v3/mapbox.map-0l53fhk2.json",
[400, { "Content-Type": "application/json" }, JSON.stringify({error: 'error'})]);
server.respond();
});
Expand Down
14 changes: 7 additions & 7 deletions test/spec/format_url.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ describe("format_url", function() {
});

it('returns a v4 URL with access_token parameter', function() {
expect(internals.url('/v4/user.map.json')).to.equal('http://a.tiles.mapbox.com/v4/user.map.json?access_token=key')
expect(internals.url('/v4/user.map.json')).to.equal('https://a.tiles.mapbox.com/v4/user.map.json?access_token=key')
});

it('uses provided access token', function() {
expect(internals.url('/v4/user.map.json', 'token')).to.equal('http://a.tiles.mapbox.com/v4/user.map.json?access_token=token')
expect(internals.url('/v4/user.map.json', 'token')).to.equal('https://a.tiles.mapbox.com/v4/user.map.json?access_token=token')
});

it('throws an error if no access token is provided', function() {
Expand Down Expand Up @@ -47,13 +47,13 @@ describe("format_url", function() {
expect(internals.url.tileJSON('http://a.tiles.mapbox.com/v3/user.map.json')).to.equal('http://a.tiles.mapbox.com/v3/user.map.json')
});

it('returns a v4 URL with access_token parameter', function() {
expect(internals.url.tileJSON('user.map')).to.equal('http://a.tiles.mapbox.com/v4/user.map.json?access_token=key')
it('returns a v4 URL with access_token parameter, uses https and appends &secure', function() {
expect(internals.url.tileJSON('user.map')).to.equal('https://a.tiles.mapbox.com/v4/user.map.json?access_token=key&secure');
});

it('appends &secure and uses https when FORCE_HTTPS is set', function() {
internals.config.FORCE_HTTPS = true;
expect(internals.url.tileJSON('user.map')).to.equal('https://a.tiles.mapbox.com/v4/user.map.json?access_token=key&secure');
it('does not append &secure and uses http when FORCE_HTTPS is set to false', function() {
internals.config.FORCE_HTTPS = false;
expect(internals.url.tileJSON('user.map')).to.equal('http://a.tiles.mapbox.com/v4/user.map.json?access_token=key');
});
});

Expand Down
27 changes: 13 additions & 14 deletions test/spec/geocoder.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,48 +13,47 @@ describe('L.mapbox.geocoder', function() {
it('supports multiple arguments', function() {
var g = L.mapbox.geocoder('mapbox.places');
expect(g.queryURL(['austin', 'houston']))
.to.eql('http://a.tiles.mapbox.com/geocoding/v5/mapbox.places/austin;houston.json?access_token=key');
.to.eql('https://a.tiles.mapbox.com/geocoding/v5/mapbox.places/austin;houston.json?access_token=key');
});

it('supports proximity', function() {
var g = L.mapbox.geocoder('mapbox.places');
expect(g.queryURL({query: ['austin', 'houston'], proximity: [10, 15]}))
.to.eql('http://a.tiles.mapbox.com/geocoding/v5/mapbox.places/austin;houston.json?access_token=key&proximity=15,10');
.to.eql('https://a.tiles.mapbox.com/geocoding/v5/mapbox.places/austin;houston.json?access_token=key&proximity=15,10');
});

it('supports country option', function() {
var g = L.mapbox.geocoder('mapbox.places');
expect(g.queryURL({query: ['austin', 'houston'], country: 'us'}))
.to.eql('http://a.tiles.mapbox.com/geocoding/v5/mapbox.places/austin;houston.json?access_token=key&country=us');
.to.eql('https://a.tiles.mapbox.com/geocoding/v5/mapbox.places/austin;houston.json?access_token=key&country=us');
});

it('supports bbox option', function() {
var g = L.mapbox.geocoder('mapbox.places');
expect(g.queryURL({query: ['austin', 'houston'], bbox: [ -104.0458814, 26.0696823, -93.7347459, 36.4813628 ]}))
.to.eql('http://a.tiles.mapbox.com/geocoding/v5/mapbox.places/
austin;houston.json?access_token=key&bbox='-104.0458814,26.0696823,-93.7347459,36.4813628');
.to.eql('https://a.tiles.mapbox.com/geocoding/v5/mapbox.places/austin;houston.json?access_token=key&bbox=-104.0458814,26.0696823,-93.7347459,36.4813628');
});

it('supports autocomplete option', function() {
var g = L.mapbox.geocoder('mapbox.places');
expect(g.queryURL({query: ['austin', 'houston'], country: 'us', autocomplete: false}))
.to.eql('http://a.tiles.mapbox.com/geocoding/v5/mapbox.places/austin;houston.json?access_token=key&country=us&autocomplete=false');
.to.eql('https://a.tiles.mapbox.com/geocoding/v5/mapbox.places/austin;houston.json?access_token=key&country=us&autocomplete=false');
});

it('rounds proximity params correctly', function() {
var g = L.mapbox.geocoder('mapbox.places');
expect(g.queryURL({query: ['austin', 'houston'], proximity: L.latLng(-10.12345, 15.67890)}))
.to.eql('http://a.tiles.mapbox.com/geocoding/v5/mapbox.places/austin;houston.json?access_token=key&proximity=15.679,-10.123');
.to.eql('https://a.tiles.mapbox.com/geocoding/v5/mapbox.places/austin;houston.json?access_token=key&proximity=15.679,-10.123');
});

it('rounds reverse ')

it('supports types', function() {
var g = L.mapbox.geocoder('mapbox.places');
expect(g.queryURL({query: ['austin', 'houston'], types: 'place'}))
.to.eql('http://a.tiles.mapbox.com/geocoding/v5/mapbox.places/austin;houston.json?access_token=key&types=place');
.to.eql('https://a.tiles.mapbox.com/geocoding/v5/mapbox.places/austin;houston.json?access_token=key&types=place');
expect(g.queryURL({query: ['austin', 'houston'], types: ['place', 'address']}))
.to.eql('http://a.tiles.mapbox.com/geocoding/v5/mapbox.places/austin;houston.json?access_token=key&types=place,address');
.to.eql('https://a.tiles.mapbox.com/geocoding/v5/mapbox.places/austin;houston.json?access_token=key&types=place,address');
});
});

Expand All @@ -63,7 +62,7 @@ describe('L.mapbox.geocoder', function() {
var g = L.mapbox.geocoder('mapbox.places');

server.respondWith('GET',
'http://a.tiles.mapbox.com/geocoding/v5/mapbox.places/austin;houston.json?access_token=key',
'https://a.tiles.mapbox.com/geocoding/v5/mapbox.places/austin;houston.json?access_token=key',
[200, { 'Content-Type': 'application/json' }, JSON.stringify(helpers.geocoderBulk)]);

g.query(['austin', 'houston'], function(err, res) {
Expand All @@ -78,7 +77,7 @@ describe('L.mapbox.geocoder', function() {
var g = L.mapbox.geocoder('mapbox.places');

server.respondWith('GET',
'http://a.tiles.mapbox.com/geocoding/v5/mapbox.places/austin.json?access_token=key',
'https://a.tiles.mapbox.com/geocoding/v5/mapbox.places/austin.json?access_token=key',
[200, { "Content-Type": "application/json" }, JSON.stringify(helpers.geocoderAustin)]);

g.query('austin', function(err, res) {
Expand All @@ -94,7 +93,7 @@ describe('L.mapbox.geocoder', function() {
var g = L.mapbox.geocoder('mapbox.places');

server.respondWith('GET',
'http://a.tiles.mapbox.com/geocoding/v5/mapbox.places/nonesuch.json?access_token=key',
'https://a.tiles.mapbox.com/geocoding/v5/mapbox.places/nonesuch.json?access_token=key',
[200, { 'Content-Type': 'application/json' }, JSON.stringify({"type":"FeatureCollection","query":["nonesuch"],"features":[]})]);

g.query('nonesuch', function(err, res) {
Expand All @@ -111,7 +110,7 @@ describe('L.mapbox.geocoder', function() {
var g = L.mapbox.geocoder('mapbox.places');

server.respondWith('GET',
'http://a.tiles.mapbox.com/geocoding/v5/mapbox.places/-97.7%2C30.3.json?access_token=key',
'https://a.tiles.mapbox.com/geocoding/v5/mapbox.places/-97.7%2C30.3.json?access_token=key',
[200, { "Content-Type": "application/json" }, JSON.stringify(helpers.geocoderReverse)]);

g.reverseQuery({ lat: 30.3, lng: -97.7 }, function(err, res) {
Expand All @@ -126,7 +125,7 @@ describe('L.mapbox.geocoder', function() {
var g = L.mapbox.geocoder('mapbox.places');

server.respondWith('GET',
/http:\/\/a\.tiles\.mapbox\.com\/geocoding\/v5\/mapbox.places\/[\-\d\.]+(%2C|,)[\-\d\.]+\.json\?access_token=key/,
/https:\/\/a\.tiles\.mapbox\.com\/geocoding\/v5\/mapbox.places\/[\-\d\.]+(%2C|,)[\-\d\.]+\.json\?access_token=key/,
[200, { "Content-Type": "application/json" }, JSON.stringify(helpers.geocoderReverseRounded)]);

g.reverseQuery({ lat: 30.1234567890, lng: -97.0987654321 }, function(err, res) {
Expand Down
Loading

0 comments on commit a40d000

Please sign in to comment.