-
-
Notifications
You must be signed in to change notification settings - Fork 213
/
Copy pathpickpointgeocoder.test.js
48 lines (37 loc) · 1.56 KB
/
pickpointgeocoder.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
(function () {
var chai = require('chai'),
should = chai.should(),
expect = chai.expect,
sinon = require('sinon');
var PickPointGeocoder = require('../../lib/geocoder/pickpointgeocoder.js');
var mockedHttpAdapter = {
get: sinon.stub(),
supportsHttps: sinon.stub()
};
describe('PickPointGeocoder', () => {
describe('#constructor', () => {
test('should be an instance of PickPointGeocoder', () => {
mockedHttpAdapter.supportsHttps.returns(true);
var geocoder = new PickPointGeocoder(mockedHttpAdapter, {apiKey: 'API_KEY'});
geocoder.should.be.instanceof(PickPointGeocoder);
});
test('an http adapter must be set', () => {
expect(function () {
new PickPointGeocoder();
}).to.throw(Error, 'PickPointGeocoder need an httpAdapter');
});
test('the adapter should support https', () => {
mockedHttpAdapter.supportsHttps.returns(false);
expect(function () {
new PickPointGeocoder(mockedHttpAdapter);
}).to.throw(Error, 'You must use https http adapter');
});
test('an apiKey must be set', () => {
mockedHttpAdapter.supportsHttps.returns(true);
expect(function () {
new PickPointGeocoder(mockedHttpAdapter);
}).to.throw(Error, 'PickPointGeocoder needs an apiKey');
});
});
});
})();