smartystreets-javascript-sdk 5.2.0 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/AgentSender.cjs +1 -0
- package/dist/cjs/BaseUrlSender.cjs +1 -0
- package/dist/cjs/Batch.cjs +1 -0
- package/dist/cjs/ClientBuilder.cjs +1 -0
- package/dist/cjs/CustomHeaderSender.cjs +1 -0
- package/dist/cjs/Errors.cjs +1 -0
- package/dist/cjs/HttpSender.cjs +1 -0
- package/dist/cjs/InputData.cjs +1 -0
- package/dist/cjs/LicenseSender.cjs +1 -0
- package/dist/cjs/Request.cjs +1 -0
- package/dist/cjs/Response.cjs +1 -0
- package/dist/cjs/RetrySender.cjs +1 -0
- package/dist/cjs/SharedCredentials.cjs +1 -0
- package/dist/cjs/SigningSender.cjs +1 -0
- package/dist/cjs/StaticCredentials.cjs +1 -0
- package/dist/cjs/StatusCodeSender.cjs +1 -0
- package/dist/cjs/_virtual/Batch.cjs +1 -0
- package/dist/cjs/_virtual/Candidate.cjs +1 -0
- package/dist/cjs/_virtual/Candidate2.cjs +1 -0
- package/dist/cjs/_virtual/ClientBuilder.cjs +1 -0
- package/dist/cjs/_virtual/Errors.cjs +1 -0
- package/dist/cjs/_virtual/Lookup.cjs +1 -0
- package/dist/cjs/_virtual/Lookup2.cjs +1 -0
- package/dist/cjs/_virtual/Lookup3.cjs +1 -0
- package/dist/cjs/_virtual/Lookup4.cjs +1 -0
- package/dist/cjs/_virtual/Lookup5.cjs +1 -0
- package/dist/cjs/_virtual/Lookup6.cjs +1 -0
- package/dist/cjs/_virtual/Lookup7.cjs +1 -0
- package/dist/cjs/_virtual/Lookup8.cjs +1 -0
- package/dist/cjs/_virtual/Response.cjs +1 -0
- package/dist/cjs/_virtual/Result.cjs +1 -0
- package/dist/cjs/_virtual/Result2.cjs +1 -0
- package/dist/cjs/_virtual/SharedCredentials.cjs +1 -0
- package/dist/cjs/_virtual/StaticCredentials.cjs +1 -0
- package/dist/cjs/_virtual/Suggestion.cjs +1 -0
- package/dist/cjs/_virtual/Suggestion2.cjs +1 -0
- package/dist/cjs/_virtual/_axios.cjs +1 -0
- package/dist/cjs/_virtual/_commonjsHelpers.cjs +1 -0
- package/dist/cjs/_virtual/buildClients.cjs +1 -0
- package/dist/cjs/index.cjs +1 -0
- package/dist/cjs/international_address_autocomplete/Client.cjs +1 -0
- package/dist/cjs/international_address_autocomplete/Lookup.cjs +1 -0
- package/dist/cjs/international_address_autocomplete/Suggestion.cjs +1 -0
- package/dist/cjs/international_street/Candidate.cjs +1 -0
- package/dist/cjs/international_street/Client.cjs +1 -0
- package/dist/cjs/international_street/Lookup.cjs +1 -0
- package/dist/cjs/package.json.cjs +1 -0
- package/dist/cjs/us_autocomplete_pro/Client.cjs +1 -0
- package/dist/cjs/us_autocomplete_pro/Lookup.cjs +1 -0
- package/dist/cjs/us_autocomplete_pro/Suggestion.cjs +1 -0
- package/dist/cjs/us_enrichment/Client.cjs +1 -0
- package/dist/cjs/us_enrichment/Lookup.cjs +1 -0
- package/dist/cjs/us_enrichment/Response.cjs +1 -0
- package/dist/cjs/us_extract/Address.cjs +1 -0
- package/dist/cjs/us_extract/Client.cjs +1 -0
- package/dist/cjs/us_extract/Lookup.cjs +1 -0
- package/dist/cjs/us_extract/Result.cjs +1 -0
- package/dist/cjs/us_reverse_geo/Client.cjs +1 -0
- package/dist/cjs/us_reverse_geo/Lookup.cjs +1 -0
- package/dist/cjs/us_reverse_geo/Response.cjs +1 -0
- package/dist/cjs/us_reverse_geo/Result.cjs +1 -0
- package/dist/cjs/us_street/Candidate.cjs +1 -0
- package/dist/cjs/us_street/Client.cjs +1 -0
- package/dist/cjs/us_street/Lookup.cjs +1 -0
- package/dist/cjs/us_zipcode/Client.cjs +1 -0
- package/dist/cjs/us_zipcode/Lookup.cjs +1 -0
- package/dist/cjs/us_zipcode/Result.cjs +1 -0
- package/dist/cjs/util/Sleeper.cjs +1 -0
- package/dist/cjs/util/apiToSDKKeyMap.cjs +1 -0
- package/dist/cjs/util/buildClients.cjs +1 -0
- package/dist/cjs/util/buildInputData.cjs +1 -0
- package/dist/cjs/util/buildSmartyResponse.cjs +1 -0
- package/dist/cjs/util/sendBatch.cjs +1 -0
- package/dist/esm/AgentSender.mjs +1 -0
- package/dist/esm/BaseUrlSender.mjs +1 -0
- package/dist/esm/Batch.mjs +1 -0
- package/dist/esm/ClientBuilder.mjs +1 -0
- package/dist/esm/CustomHeaderSender.mjs +1 -0
- package/dist/esm/Errors.mjs +1 -0
- package/dist/esm/HttpSender.mjs +1 -0
- package/dist/esm/InputData.mjs +1 -0
- package/dist/esm/LicenseSender.mjs +1 -0
- package/dist/esm/Request.mjs +1 -0
- package/dist/esm/Response.mjs +1 -0
- package/dist/esm/RetrySender.mjs +1 -0
- package/dist/esm/SharedCredentials.mjs +1 -0
- package/dist/esm/SigningSender.mjs +1 -0
- package/dist/esm/StaticCredentials.mjs +1 -0
- package/dist/esm/StatusCodeSender.mjs +1 -0
- package/dist/esm/_virtual/Batch.mjs +1 -0
- package/dist/esm/_virtual/Candidate.mjs +1 -0
- package/dist/esm/_virtual/Candidate2.mjs +1 -0
- package/dist/esm/_virtual/ClientBuilder.mjs +1 -0
- package/dist/esm/_virtual/Errors.mjs +1 -0
- package/dist/esm/_virtual/Lookup.mjs +1 -0
- package/dist/esm/_virtual/Lookup2.mjs +1 -0
- package/dist/esm/_virtual/Lookup3.mjs +1 -0
- package/dist/esm/_virtual/Lookup4.mjs +1 -0
- package/dist/esm/_virtual/Lookup5.mjs +1 -0
- package/dist/esm/_virtual/Lookup6.mjs +1 -0
- package/dist/esm/_virtual/Lookup7.mjs +1 -0
- package/dist/esm/_virtual/Lookup8.mjs +1 -0
- package/dist/esm/_virtual/Response.mjs +1 -0
- package/dist/esm/_virtual/Result.mjs +1 -0
- package/dist/esm/_virtual/Result2.mjs +1 -0
- package/dist/esm/_virtual/SharedCredentials.mjs +1 -0
- package/dist/esm/_virtual/StaticCredentials.mjs +1 -0
- package/dist/esm/_virtual/Suggestion.mjs +1 -0
- package/dist/esm/_virtual/Suggestion2.mjs +1 -0
- package/dist/esm/_virtual/_axios.mjs +1 -0
- package/dist/esm/_virtual/_commonjsHelpers.mjs +1 -0
- package/dist/esm/_virtual/buildClients.mjs +1 -0
- package/dist/esm/index.mjs +1 -0
- package/dist/esm/international_address_autocomplete/Client.mjs +1 -0
- package/dist/esm/international_address_autocomplete/Lookup.mjs +1 -0
- package/dist/esm/international_address_autocomplete/Suggestion.mjs +1 -0
- package/dist/esm/international_street/Candidate.mjs +1 -0
- package/dist/esm/international_street/Client.mjs +1 -0
- package/dist/esm/international_street/Lookup.mjs +1 -0
- package/dist/esm/package.json.mjs +1 -0
- package/dist/esm/us_autocomplete_pro/Client.mjs +1 -0
- package/dist/esm/us_autocomplete_pro/Lookup.mjs +1 -0
- package/dist/esm/us_autocomplete_pro/Suggestion.mjs +1 -0
- package/dist/esm/us_enrichment/Client.mjs +1 -0
- package/dist/esm/us_enrichment/Lookup.mjs +1 -0
- package/dist/esm/us_enrichment/Response.mjs +1 -0
- package/dist/esm/us_extract/Address.mjs +1 -0
- package/dist/esm/us_extract/Client.mjs +1 -0
- package/dist/esm/us_extract/Lookup.mjs +1 -0
- package/dist/esm/us_extract/Result.mjs +1 -0
- package/dist/esm/us_reverse_geo/Client.mjs +1 -0
- package/dist/esm/us_reverse_geo/Lookup.mjs +1 -0
- package/dist/esm/us_reverse_geo/Response.mjs +1 -0
- package/dist/esm/us_reverse_geo/Result.mjs +1 -0
- package/dist/esm/us_street/Candidate.mjs +1 -0
- package/dist/esm/us_street/Client.mjs +1 -0
- package/dist/esm/us_street/Lookup.mjs +1 -0
- package/dist/esm/us_zipcode/Client.mjs +1 -0
- package/dist/esm/us_zipcode/Lookup.mjs +1 -0
- package/dist/esm/us_zipcode/Result.mjs +1 -0
- package/dist/esm/util/Sleeper.mjs +1 -0
- package/dist/esm/util/apiToSDKKeyMap.mjs +1 -0
- package/dist/esm/util/buildClients.mjs +1 -0
- package/dist/esm/util/buildInputData.mjs +1 -0
- package/dist/esm/util/buildSmartyResponse.mjs +1 -0
- package/dist/esm/util/sendBatch.mjs +1 -0
- package/package.json +26 -6
- package/.github/workflows/node-tests.yml +0 -27
- package/CHANGELOG.md +0 -5
- package/Makefile +0 -28
- package/examples/international_address_autocomplete.js +0 -58
- package/examples/international_street.js +0 -56
- package/examples/us_autocomplete_pro.js +0 -63
- package/examples/us_enrichment.js +0 -36
- package/examples/us_extract.js +0 -40
- package/examples/us_reverse_geo.js +0 -40
- package/examples/us_street.js +0 -73
- package/examples/us_zipcode.js +0 -57
- package/index.js +0 -41
- package/js-sdk-demo.cast +0 -95
- package/src/AgentSender.js +0 -16
- package/src/BaseUrlSender.js +0 -18
- package/src/Batch.js +0 -49
- package/src/ClientBuilder.js +0 -212
- package/src/CustomHeaderSender.js +0 -20
- package/src/Errors.js +0 -100
- package/src/HttpSender.js +0 -66
- package/src/InputData.js +0 -21
- package/src/LicenseSender.js +0 -20
- package/src/Request.js +0 -12
- package/src/Response.js +0 -10
- package/src/RetrySender.js +0 -50
- package/src/SharedCredentials.js +0 -13
- package/src/SigningSender.js +0 -26
- package/src/StaticCredentials.js +0 -13
- package/src/StatusCodeSender.js +0 -35
- package/src/international_address_autocomplete/Client.js +0 -41
- package/src/international_address_autocomplete/Lookup.js +0 -14
- package/src/international_address_autocomplete/Suggestion.js +0 -14
- package/src/international_street/Candidate.js +0 -153
- package/src/international_street/Client.js +0 -42
- package/src/international_street/Lookup.js +0 -85
- package/src/us_autocomplete_pro/Client.js +0 -41
- package/src/us_autocomplete_pro/Lookup.js +0 -29
- package/src/us_autocomplete_pro/Suggestion.js +0 -19
- package/src/us_enrichment/Client.js +0 -112
- package/src/us_enrichment/Lookup.js +0 -13
- package/src/us_enrichment/Response.js +0 -559
- package/src/us_extract/Address.js +0 -17
- package/src/us_extract/Client.js +0 -35
- package/src/us_extract/Lookup.js +0 -24
- package/src/us_extract/Result.js +0 -21
- package/src/us_reverse_geo/Client.js +0 -40
- package/src/us_reverse_geo/Lookup.js +0 -17
- package/src/us_reverse_geo/Response.js +0 -17
- package/src/us_reverse_geo/Result.js +0 -36
- package/src/us_street/Candidate.js +0 -89
- package/src/us_street/Client.js +0 -43
- package/src/us_street/Lookup.js +0 -25
- package/src/us_zipcode/Client.js +0 -39
- package/src/us_zipcode/Lookup.js +0 -16
- package/src/us_zipcode/Result.js +0 -45
- package/src/util/Sleeper.js +0 -8
- package/src/util/apiToSDKKeyMap.js +0 -75
- package/src/util/buildClients.js +0 -48
- package/src/util/buildInputData.js +0 -11
- package/src/util/buildSmartyResponse.js +0 -10
- package/src/util/sendBatch.js +0 -39
- package/tests/fixtures/MockSleeper.js +0 -10
- package/tests/fixtures/mock_senders.js +0 -43
- package/tests/international_address_autocomplete/test_Client.js +0 -86
- package/tests/international_address_autocomplete/test_Lookup.js +0 -55
- package/tests/international_street/test_Candidate.js +0 -268
- package/tests/international_street/test_Client.js +0 -70
- package/tests/international_street/test_Lookup.js +0 -108
- package/tests/test_AgentSender.js +0 -25
- package/tests/test_BaseUrlSender.js +0 -31
- package/tests/test_Batch.js +0 -73
- package/tests/test_CustomHeaderSender.js +0 -31
- package/tests/test_ExtractExample.js +0 -167
- package/tests/test_HttpSender.js +0 -93
- package/tests/test_LicenseSender.js +0 -40
- package/tests/test_RetrySender.js +0 -98
- package/tests/test_SigningSender.js +0 -56
- package/tests/test_StatusCodeSender.js +0 -95
- package/tests/us_autocomplete_pro/test_Client.js +0 -116
- package/tests/us_autocomplete_pro/test_Lookup.js +0 -11
- package/tests/us_autocomplete_pro/test_Suggestion.js +0 -24
- package/tests/us_enrichment/test_Client.js +0 -455
- package/tests/us_enrichment/test_Lookup.js +0 -22
- package/tests/us_enrichment/test_Response.js +0 -739
- package/tests/us_extract/test_Address.js +0 -67
- package/tests/us_extract/test_Client.js +0 -148
- package/tests/us_extract/test_Lookup.js +0 -19
- package/tests/us_extract/test_Result.js +0 -39
- package/tests/us_reverse_geo/test_Client.js +0 -48
- package/tests/us_reverse_geo/test_Lookup.js +0 -14
- package/tests/us_reverse_geo/test_Response.js +0 -44
- package/tests/us_street/test_Candidate.js +0 -133
- package/tests/us_street/test_Client.js +0 -150
- package/tests/us_street/test_Lookup.js +0 -29
- package/tests/us_zipcode/test_Client.js +0 -150
- package/tests/us_zipcode/test_Result.js +0 -81
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
const chai = require("chai");
|
|
2
|
-
const expect = chai.expect;
|
|
3
|
-
const Client = require("../../src/international_address_autocomplete/Client");
|
|
4
|
-
const Lookup = require("../../src/international_address_autocomplete/Lookup");
|
|
5
|
-
const Suggestion = require("../../src/international_address_autocomplete/Suggestion");
|
|
6
|
-
const errors = require("../../src/Errors");
|
|
7
|
-
const MockSender = require("../fixtures/mock_senders").MockSender;
|
|
8
|
-
const MockSenderWithResponse = require("../fixtures/mock_senders").MockSenderWithResponse;
|
|
9
|
-
|
|
10
|
-
describe("An International Address Autocomplete Client", function () {
|
|
11
|
-
it("correctly builds parameter", function () {
|
|
12
|
-
let mockSender = new MockSender();
|
|
13
|
-
let client = new Client(mockSender);
|
|
14
|
-
let search = "(";
|
|
15
|
-
let lookup = new Lookup({search});
|
|
16
|
-
let expectedParameters = {
|
|
17
|
-
max_results: 5,
|
|
18
|
-
search: "(",
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
client.send(lookup);
|
|
22
|
-
expect(mockSender.request.parameters).to.deep.equal(expectedParameters);
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it("builds parameters for different country", function () {
|
|
26
|
-
let mockSender = new MockSender();
|
|
27
|
-
let client = new Client(mockSender);
|
|
28
|
-
let search = "(";
|
|
29
|
-
let lookup = new Lookup({search});
|
|
30
|
-
lookup.search = search;
|
|
31
|
-
lookup.country = "Russia";
|
|
32
|
-
let expectedParameters = {
|
|
33
|
-
country: "Russia",
|
|
34
|
-
max_results: 5,
|
|
35
|
-
search: search,
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
client.send(lookup);
|
|
39
|
-
expect(mockSender.request.parameters).to.deep.equal(expectedParameters);
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it("builds parameters with different max results", function () {
|
|
43
|
-
let mockSender = new MockSender();
|
|
44
|
-
let client = new Client(mockSender);
|
|
45
|
-
let search = "(";
|
|
46
|
-
let lookup = new Lookup({search});
|
|
47
|
-
lookup.search = search;
|
|
48
|
-
lookup.maxResults = 10;
|
|
49
|
-
let expectedParameters = {
|
|
50
|
-
max_results: 10,
|
|
51
|
-
search: search,
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
client.send(lookup);
|
|
55
|
-
expect(mockSender.request.parameters).to.deep.equal(expectedParameters);
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it("throws an error if sending without a lookup.", function () {
|
|
59
|
-
let mockSender = new MockSender();
|
|
60
|
-
let client = new Client(mockSender);
|
|
61
|
-
expect(client.send).to.throw(errors.UndefinedLookupError);
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
it("attaches suggestions from a response to a lookup", function () {
|
|
65
|
-
const responseData = {
|
|
66
|
-
candidates: [
|
|
67
|
-
{
|
|
68
|
-
"street": "L alleya",
|
|
69
|
-
"locality": "Novosibirsk",
|
|
70
|
-
"administrative_area": "Novosibirskaya oblast'",
|
|
71
|
-
"postal_code": "40000",
|
|
72
|
-
"country_iso3": "RUS",
|
|
73
|
-
}
|
|
74
|
-
]
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
let mockSender = new MockSenderWithResponse(responseData);
|
|
78
|
-
let client = new Client(mockSender);
|
|
79
|
-
let lookup = new Lookup({search: "f"});
|
|
80
|
-
let expectedSuggestion = new Suggestion(responseData.candidates[0]);
|
|
81
|
-
|
|
82
|
-
return client.send(lookup).then(() => {
|
|
83
|
-
expect(lookup.result[0]).to.deep.equal(expectedSuggestion);
|
|
84
|
-
});
|
|
85
|
-
});
|
|
86
|
-
});
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
const chai = require("chai");
|
|
2
|
-
const expect = chai.expect;
|
|
3
|
-
const Lookup = require("../../src/international_address_autocomplete/Lookup");
|
|
4
|
-
|
|
5
|
-
describe("An International Address Autocomplete lookup", function () {
|
|
6
|
-
it("Can be newed up with a prefix", function () {
|
|
7
|
-
const expectedPrefix = "z";
|
|
8
|
-
let lookup = new Lookup({search: expectedPrefix});
|
|
9
|
-
expect(lookup.search).to.equal(expectedPrefix);
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
it("Set address ID", function () {
|
|
13
|
-
const addressId = "111";
|
|
14
|
-
let lookup = new Lookup({addressId});
|
|
15
|
-
expect(lookup.addressId).to.equal(addressId);
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it("Set country", function () {
|
|
19
|
-
const country = "Russia";
|
|
20
|
-
let lookup = new Lookup({country});
|
|
21
|
-
expect(lookup.country).to.equal(country);
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it("Set max results", function () {
|
|
25
|
-
const maxResults = 10000;
|
|
26
|
-
let lookup = new Lookup({maxResults});
|
|
27
|
-
expect(lookup.maxResults).to.equal(maxResults);
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
it("Set include only include locality param", function () {
|
|
31
|
-
const onlyIncludeLocality = "locality";
|
|
32
|
-
let lookup = new Lookup({includeOnlyLocality: onlyIncludeLocality});
|
|
33
|
-
expect(lookup.includeOnlyLocality).to.equal(onlyIncludeLocality);
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
it("Set include only include postal code param", function () {
|
|
37
|
-
const onlyIncludePostalCode = "post code";
|
|
38
|
-
let lookup = new Lookup({includeOnlyPostalCode: onlyIncludePostalCode});
|
|
39
|
-
expect(lookup.includeOnlyPostalCode).to.equal(onlyIncludePostalCode);
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it("Checking defaults of params on instantiation ", function () {
|
|
43
|
-
const defaultLookup = {
|
|
44
|
-
result: [],
|
|
45
|
-
search: undefined,
|
|
46
|
-
addressId: undefined,
|
|
47
|
-
country: undefined,
|
|
48
|
-
maxResults: 5,
|
|
49
|
-
includeOnlyLocality: undefined,
|
|
50
|
-
includeOnlyPostalCode: undefined,
|
|
51
|
-
};
|
|
52
|
-
let lookup = new Lookup();
|
|
53
|
-
expect(lookup).to.deep.equal(defaultLookup);
|
|
54
|
-
});
|
|
55
|
-
});
|
|
@@ -1,268 +0,0 @@
|
|
|
1
|
-
const chai = require("chai");
|
|
2
|
-
const expect = chai.expect;
|
|
3
|
-
const Candidate = require("../../src/international_street/Candidate");
|
|
4
|
-
|
|
5
|
-
describe("An International match candidate", function () {
|
|
6
|
-
it("populates with the appropriate fields.", function () {
|
|
7
|
-
const sampleResponse = {
|
|
8
|
-
organization: "1",
|
|
9
|
-
address1: "2",
|
|
10
|
-
address2: "3",
|
|
11
|
-
address3: "4",
|
|
12
|
-
address4: "5",
|
|
13
|
-
address5: "6",
|
|
14
|
-
address6: "7",
|
|
15
|
-
address7: "8",
|
|
16
|
-
address8: "9",
|
|
17
|
-
address9: "10",
|
|
18
|
-
address10: "11",
|
|
19
|
-
address11: "12",
|
|
20
|
-
address12: "13",
|
|
21
|
-
components: {
|
|
22
|
-
country_iso_3: "14",
|
|
23
|
-
super_administrative_area: "15",
|
|
24
|
-
administrative_area: "16",
|
|
25
|
-
administrative_area_short: "16.1",
|
|
26
|
-
administrative_area_long: "16.2",
|
|
27
|
-
sub_administrative_area: "17",
|
|
28
|
-
dependent_locality: "18",
|
|
29
|
-
dependent_locality_name: "19",
|
|
30
|
-
double_dependent_locality: "20",
|
|
31
|
-
locality: "21",
|
|
32
|
-
postal_code: "22",
|
|
33
|
-
postal_code_short: "23",
|
|
34
|
-
postal_code_extra: "24",
|
|
35
|
-
premise: "25",
|
|
36
|
-
premise_extra: "26",
|
|
37
|
-
premise_prefix_number: "26.5",
|
|
38
|
-
premise_number: "27",
|
|
39
|
-
premise_type: "28",
|
|
40
|
-
thoroughfare: "29",
|
|
41
|
-
thoroughfare_predirection: "30",
|
|
42
|
-
thoroughfare_postdirection: "31",
|
|
43
|
-
thoroughfare_name: "32",
|
|
44
|
-
thoroughfare_trailing_type: "33",
|
|
45
|
-
thoroughfare_type: "34",
|
|
46
|
-
dependent_thoroughfare: "35",
|
|
47
|
-
dependent_thoroughfare_predirection: "36",
|
|
48
|
-
dependent_thoroughfare_postdirection: "37",
|
|
49
|
-
dependent_thoroughfare_name: "38",
|
|
50
|
-
dependent_thoroughfare_trailing_type: "39",
|
|
51
|
-
dependent_thoroughfare_type: "40",
|
|
52
|
-
building: "41",
|
|
53
|
-
building_leading_type: "42",
|
|
54
|
-
building_name: "43",
|
|
55
|
-
building_trailing_type: "44",
|
|
56
|
-
sub_building_type: "45",
|
|
57
|
-
sub_building_number: "46",
|
|
58
|
-
sub_building_name: "47",
|
|
59
|
-
sub_building: "48",
|
|
60
|
-
level_type: "48.1",
|
|
61
|
-
level_number: "48.2",
|
|
62
|
-
post_box: "49",
|
|
63
|
-
post_box_type: "50",
|
|
64
|
-
post_box_number: "51",
|
|
65
|
-
},
|
|
66
|
-
metadata: {
|
|
67
|
-
latitude: 52.0,
|
|
68
|
-
longitude: 53.0,
|
|
69
|
-
geocode_precision: "54",
|
|
70
|
-
max_geocode_precision: "55",
|
|
71
|
-
address_format: "56",
|
|
72
|
-
},
|
|
73
|
-
analysis: {
|
|
74
|
-
verification_status: "57",
|
|
75
|
-
address_precision: "58",
|
|
76
|
-
max_address_precision: "59",
|
|
77
|
-
changes: {
|
|
78
|
-
organization: "60",
|
|
79
|
-
address1: "61",
|
|
80
|
-
address2: "62",
|
|
81
|
-
address3: "63",
|
|
82
|
-
address4: "64",
|
|
83
|
-
address5: "65",
|
|
84
|
-
address6: "66",
|
|
85
|
-
address7: "67",
|
|
86
|
-
address8: "68",
|
|
87
|
-
address9: "69",
|
|
88
|
-
address10: "70",
|
|
89
|
-
address11: "71",
|
|
90
|
-
address12: "72",
|
|
91
|
-
components: {
|
|
92
|
-
country_iso_3: "73",
|
|
93
|
-
super_administrative_area: "74",
|
|
94
|
-
administrative_area: "75",
|
|
95
|
-
administrative_area_short: "75.1",
|
|
96
|
-
administrative_area_long: "75.2",
|
|
97
|
-
sub_administrative_area: "76",
|
|
98
|
-
dependent_locality: "77",
|
|
99
|
-
dependent_locality_name: "78",
|
|
100
|
-
double_dependent_locality: "79",
|
|
101
|
-
locality: "80",
|
|
102
|
-
postal_code: "81",
|
|
103
|
-
postal_code_short: "82",
|
|
104
|
-
postal_code_extra: "83",
|
|
105
|
-
premise: "84",
|
|
106
|
-
premise_extra: "85",
|
|
107
|
-
premise_prefix_number: "86",
|
|
108
|
-
premise_number: "87",
|
|
109
|
-
premise_type: "88",
|
|
110
|
-
thoroughfare: "89",
|
|
111
|
-
thoroughfare_predirection: "90",
|
|
112
|
-
thoroughfare_postdirection: "91",
|
|
113
|
-
thoroughfare_name: "92",
|
|
114
|
-
thoroughfare_trailing_type: "93",
|
|
115
|
-
thoroughfare_type: "94",
|
|
116
|
-
dependent_thoroughfare: "95",
|
|
117
|
-
dependent_thoroughfare_predirection: "96",
|
|
118
|
-
dependent_thoroughfare_postdirection: "97",
|
|
119
|
-
dependent_thoroughfare_name: "98",
|
|
120
|
-
dependent_thoroughfare_trailing_type: "99",
|
|
121
|
-
dependent_thoroughfare_type: "100",
|
|
122
|
-
building: "101",
|
|
123
|
-
building_leading_type: "102",
|
|
124
|
-
building_name: "103",
|
|
125
|
-
building_trailing_type: "104",
|
|
126
|
-
sub_building_type: "105",
|
|
127
|
-
sub_building_number: "106",
|
|
128
|
-
sub_building_name: "107",
|
|
129
|
-
sub_building: "108",
|
|
130
|
-
level_type: "108.1",
|
|
131
|
-
level_number: "108.2",
|
|
132
|
-
post_box: "109",
|
|
133
|
-
post_box_type: "110",
|
|
134
|
-
post_box_number: "111",
|
|
135
|
-
},
|
|
136
|
-
},
|
|
137
|
-
},
|
|
138
|
-
};
|
|
139
|
-
|
|
140
|
-
const candidate = new Candidate(sampleResponse);
|
|
141
|
-
|
|
142
|
-
expect(candidate.organization).to.equal("1");
|
|
143
|
-
expect(candidate.address1).to.equal("2");
|
|
144
|
-
expect(candidate.address2).to.equal("3");
|
|
145
|
-
expect(candidate.address3).to.equal("4");
|
|
146
|
-
expect(candidate.address4).to.equal("5");
|
|
147
|
-
expect(candidate.address5).to.equal("6");
|
|
148
|
-
expect(candidate.address6).to.equal("7");
|
|
149
|
-
expect(candidate.address7).to.equal("8");
|
|
150
|
-
expect(candidate.address8).to.equal("9");
|
|
151
|
-
expect(candidate.address9).to.equal("10");
|
|
152
|
-
expect(candidate.address10).to.equal("11");
|
|
153
|
-
expect(candidate.address11).to.equal("12");
|
|
154
|
-
expect(candidate.address12).to.equal("13");
|
|
155
|
-
let components = candidate.components;
|
|
156
|
-
expect(components.countryIso3).to.equal("14");
|
|
157
|
-
expect(components.superAdministrativeArea).to.equal("15");
|
|
158
|
-
expect(components.administrativeArea).to.equal("16");
|
|
159
|
-
expect(components.administrativeAreaShort).to.equal("16.1");
|
|
160
|
-
expect(components.administrativeAreaLong).to.equal("16.2");
|
|
161
|
-
expect(components.subAdministrativeArea).to.equal("17");
|
|
162
|
-
expect(components.dependentLocality).to.equal("18");
|
|
163
|
-
expect(components.dependentLocalityName).to.equal("19");
|
|
164
|
-
expect(components.doubleDependentLocality).to.equal("20");
|
|
165
|
-
expect(components.locality).to.equal("21");
|
|
166
|
-
expect(components.postalCode).to.equal("22");
|
|
167
|
-
expect(components.postalCodeShort).to.equal("23");
|
|
168
|
-
expect(components.postalCodeExtra).to.equal("24");
|
|
169
|
-
expect(components.premise).to.equal("25");
|
|
170
|
-
expect(components.premiseExtra).to.equal("26");
|
|
171
|
-
expect(components.premisePrefixNumber).to.equal("26.5");
|
|
172
|
-
expect(components.premiseNumber).to.equal("27");
|
|
173
|
-
expect(components.premiseType).to.equal("28");
|
|
174
|
-
expect(components.thoroughfare).to.equal("29");
|
|
175
|
-
expect(components.thoroughfarePredirection).to.equal("30");
|
|
176
|
-
expect(components.thoroughfarePostdirection).to.equal("31");
|
|
177
|
-
expect(components.thoroughfareName).to.equal("32");
|
|
178
|
-
expect(components.thoroughfareTrailingType).to.equal("33");
|
|
179
|
-
expect(components.thoroughfareType).to.equal("34");
|
|
180
|
-
expect(components.dependentThoroughfare).to.equal("35");
|
|
181
|
-
expect(components.dependentThoroughfarePredirection).to.equal("36");
|
|
182
|
-
expect(components.dependentThoroughfarePostdirection).to.equal("37");
|
|
183
|
-
expect(components.dependentThoroughfareName).to.equal("38");
|
|
184
|
-
expect(components.dependentThoroughfareTrailingType).to.equal("39");
|
|
185
|
-
expect(components.dependentThoroughfareType).to.equal("40");
|
|
186
|
-
expect(components.building).to.equal("41");
|
|
187
|
-
expect(components.buildingLeadingType).to.equal("42");
|
|
188
|
-
expect(components.buildingName).to.equal("43");
|
|
189
|
-
expect(components.buildingTrailingType).to.equal("44");
|
|
190
|
-
expect(components.subBuildingType).to.equal("45");
|
|
191
|
-
expect(components.subBuildingNumber).to.equal("46");
|
|
192
|
-
expect(components.subBuildingName).to.equal("47");
|
|
193
|
-
expect(components.subBuilding).to.equal("48");
|
|
194
|
-
expect(components.levelType).to.equal("48.1");
|
|
195
|
-
expect(components.levelNumber).to.equal("48.2");
|
|
196
|
-
expect(components.postBox).to.equal("49");
|
|
197
|
-
expect(components.postBoxType).to.equal("50");
|
|
198
|
-
expect(components.postBoxNumber).to.equal("51");
|
|
199
|
-
let metadata = candidate.metadata;
|
|
200
|
-
expect(metadata.latitude).to.equal(52.0);
|
|
201
|
-
expect(metadata.longitude).to.equal(53.0);
|
|
202
|
-
expect(metadata.geocodePrecision).to.equal("54");
|
|
203
|
-
expect(metadata.maxGeocodePrecision).to.equal("55");
|
|
204
|
-
expect(metadata.addressFormat).to.equal("56");
|
|
205
|
-
let analysis = candidate.analysis;
|
|
206
|
-
expect(analysis.verificationStatus).to.equal("57");
|
|
207
|
-
expect(analysis.addressPrecision).to.equal("58");
|
|
208
|
-
expect(analysis.maxAddressPrecision).to.equal("59");
|
|
209
|
-
let changes = analysis.changes;
|
|
210
|
-
expect(changes.organization).to.equal("60");
|
|
211
|
-
expect(changes.address1).to.equal("61");
|
|
212
|
-
expect(changes.address2).to.equal("62");
|
|
213
|
-
expect(changes.address3).to.equal("63");
|
|
214
|
-
expect(changes.address4).to.equal("64");
|
|
215
|
-
expect(changes.address5).to.equal("65");
|
|
216
|
-
expect(changes.address6).to.equal("66");
|
|
217
|
-
expect(changes.address7).to.equal("67");
|
|
218
|
-
expect(changes.address8).to.equal("68");
|
|
219
|
-
expect(changes.address9).to.equal("69");
|
|
220
|
-
expect(changes.address10).to.equal("70");
|
|
221
|
-
expect(changes.address11).to.equal("71");
|
|
222
|
-
expect(changes.address12).to.equal("72");
|
|
223
|
-
let ccomponents = changes.components;
|
|
224
|
-
expect(ccomponents.countryIso3).to.equal("73");
|
|
225
|
-
expect(ccomponents.superAdministrativeArea).to.equal("74");
|
|
226
|
-
expect(ccomponents.administrativeArea).to.equal("75");
|
|
227
|
-
expect(ccomponents.administrativeAreaShort).to.equal("75.1");
|
|
228
|
-
expect(ccomponents.administrativeAreaLong).to.equal("75.2");
|
|
229
|
-
expect(ccomponents.subAdministrativeArea).to.equal("76");
|
|
230
|
-
expect(ccomponents.dependentLocality).to.equal("77");
|
|
231
|
-
expect(ccomponents.dependentLocalityName).to.equal("78");
|
|
232
|
-
expect(ccomponents.doubleDependentLocality).to.equal("79");
|
|
233
|
-
expect(ccomponents.locality).to.equal("80");
|
|
234
|
-
expect(ccomponents.postalCode).to.equal("81");
|
|
235
|
-
expect(ccomponents.postalCodeShort).to.equal("82");
|
|
236
|
-
expect(ccomponents.postalCodeExtra).to.equal("83");
|
|
237
|
-
expect(ccomponents.premise).to.equal("84");
|
|
238
|
-
expect(ccomponents.premiseExtra).to.equal("85");
|
|
239
|
-
expect(ccomponents.premisePrefixNumber).to.equal("86");
|
|
240
|
-
expect(ccomponents.premiseNumber).to.equal("87");
|
|
241
|
-
expect(ccomponents.premiseType).to.equal("88");
|
|
242
|
-
expect(ccomponents.thoroughfare).to.equal("89");
|
|
243
|
-
expect(ccomponents.thoroughfarePredirection).to.equal("90");
|
|
244
|
-
expect(ccomponents.thoroughfarePostdirection).to.equal("91");
|
|
245
|
-
expect(ccomponents.thoroughfareName).to.equal("92");
|
|
246
|
-
expect(ccomponents.thoroughfareTrailingType).to.equal("93");
|
|
247
|
-
expect(ccomponents.thoroughfareType).to.equal("94");
|
|
248
|
-
expect(ccomponents.dependentThoroughfare).to.equal("95");
|
|
249
|
-
expect(ccomponents.dependentThoroughfarePredirection).to.equal("96");
|
|
250
|
-
expect(ccomponents.dependentThoroughfarePostdirection).to.equal("97");
|
|
251
|
-
expect(ccomponents.dependentThoroughfareName).to.equal("98");
|
|
252
|
-
expect(ccomponents.dependentThoroughfareTrailingType).to.equal("99");
|
|
253
|
-
expect(ccomponents.dependentThoroughfareType).to.equal("100");
|
|
254
|
-
expect(ccomponents.building).to.equal("101");
|
|
255
|
-
expect(ccomponents.buildingLeadingType).to.equal("102");
|
|
256
|
-
expect(ccomponents.buildingName).to.equal("103");
|
|
257
|
-
expect(ccomponents.buildingTrailingType).to.equal("104");
|
|
258
|
-
expect(ccomponents.subBuildingType).to.equal("105");
|
|
259
|
-
expect(ccomponents.subBuildingNumber).to.equal("106");
|
|
260
|
-
expect(ccomponents.subBuildingName).to.equal("107");
|
|
261
|
-
expect(ccomponents.subBuilding).to.equal("108");
|
|
262
|
-
expect(ccomponents.levelType).to.equal("108.1");
|
|
263
|
-
expect(ccomponents.levelNumber).to.equal("108.2");
|
|
264
|
-
expect(ccomponents.postBox).to.equal("109");
|
|
265
|
-
expect(ccomponents.postBoxType).to.equal("110");
|
|
266
|
-
expect(ccomponents.postBoxNumber).to.equal("111");
|
|
267
|
-
});
|
|
268
|
-
});
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
const chai = require("chai");
|
|
2
|
-
const expect = chai.expect;
|
|
3
|
-
const Client = require("../../src/international_street/Client");
|
|
4
|
-
const Lookup = require("../../src/international_street/Lookup");
|
|
5
|
-
const Candidate = require("../../src/international_street/Candidate");
|
|
6
|
-
const errors = require("../../src/Errors");
|
|
7
|
-
const MockSender = require("../fixtures/mock_senders").MockSender;
|
|
8
|
-
const MockSenderWithResponse = require("../fixtures/mock_senders").MockSenderWithResponse;
|
|
9
|
-
|
|
10
|
-
describe("An International Street client", function () {
|
|
11
|
-
it("has an inner sender.", function () {
|
|
12
|
-
let mockSender = new MockSender();
|
|
13
|
-
let client = new Client(mockSender);
|
|
14
|
-
|
|
15
|
-
expect(client.sender).to.deep.equal(mockSender);
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it("throws an error if sending without a lookup.", function () {
|
|
19
|
-
let mockSender = new MockSender();
|
|
20
|
-
let client = new Client(mockSender);
|
|
21
|
-
|
|
22
|
-
expect(client.send).to.throw(errors.UndefinedLookupError);
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it("correctly assigns request parameters based on lookup input.", function () {
|
|
26
|
-
let mockSender = new MockSender();
|
|
27
|
-
let client = new Client(mockSender);
|
|
28
|
-
let lookup = new Lookup("a", "b");
|
|
29
|
-
lookup.address1 = "c";
|
|
30
|
-
lookup.address2 = "d";
|
|
31
|
-
lookup.address3 = "e";
|
|
32
|
-
lookup.address4 = "f";
|
|
33
|
-
lookup.organization = "g";
|
|
34
|
-
lookup.locality = "h";
|
|
35
|
-
lookup.administrativeArea = "i";
|
|
36
|
-
lookup.postalCode = "j";
|
|
37
|
-
lookup.geocode = "k";
|
|
38
|
-
lookup.language = "l";
|
|
39
|
-
let expectedParameters = {
|
|
40
|
-
country: "a",
|
|
41
|
-
freeform: "b",
|
|
42
|
-
address1: "c",
|
|
43
|
-
address2: "d",
|
|
44
|
-
address3: "e",
|
|
45
|
-
address4: "f",
|
|
46
|
-
organization: "g",
|
|
47
|
-
locality: "h",
|
|
48
|
-
administrative_area: "i",
|
|
49
|
-
postal_code: "j",
|
|
50
|
-
geocode: "k",
|
|
51
|
-
language: "l",
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
client.send(lookup);
|
|
55
|
-
|
|
56
|
-
expect(mockSender.request.parameters).to.deep.equal(expectedParameters);
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
it("attaches a match candidate from a response to a lookup.", function () {
|
|
60
|
-
const expectedMockPayload = [{address1: "A", }];
|
|
61
|
-
let mockSender = new MockSenderWithResponse(expectedMockPayload);
|
|
62
|
-
const client = new Client(mockSender);
|
|
63
|
-
let lookup = new Lookup();
|
|
64
|
-
let expectedResult = new Candidate({address1: "A"});
|
|
65
|
-
|
|
66
|
-
return client.send(lookup).then(response => {
|
|
67
|
-
expect(lookup.result[0]).to.deep.equal(expectedResult);
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
});
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
const chai = require("chai");
|
|
2
|
-
const expect = chai.expect;
|
|
3
|
-
const Lookup = require("../../src/international_street/Lookup");
|
|
4
|
-
const errors = require("../../src/Errors");
|
|
5
|
-
|
|
6
|
-
describe("An International Street lookup", function () {
|
|
7
|
-
const messages = {
|
|
8
|
-
countryRequired: "Country field is required.",
|
|
9
|
-
freeformOrAddress1Required: "Either freeform or address1 is required.",
|
|
10
|
-
insufficientInformation: "Insufficient information: One or more required fields were not set on the lookup.",
|
|
11
|
-
badGeocode: "Invalid input: geocode can only be set to 'true' (default is 'false'.",
|
|
12
|
-
invalidLanguage: "Invalid input: language can only be set to 'latin' or 'native'. When not set, the the output language will match the language of the input values."
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
it("correctly populates fields.", function () {
|
|
16
|
-
let lookup = new Lookup("a", "b");
|
|
17
|
-
|
|
18
|
-
expect(lookup.country).to.equal("a");
|
|
19
|
-
expect(lookup.freeform).to.equal("b");
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it("rejects lookups without a country.", function () {
|
|
23
|
-
ensureValidationThrows(new Lookup().ensureEnoughInfo, messages.countryRequired);
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
it("rejects lookups with only a country.", function () {
|
|
27
|
-
ensureValidationThrows(new Lookup("a").ensureEnoughInfo, messages.freeformOrAddress1Required);
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
it("rejects lookups with only a country and address 1.", function () {
|
|
31
|
-
let lookup = new Lookup("a");
|
|
32
|
-
lookup.address1 = "b";
|
|
33
|
-
|
|
34
|
-
ensureValidationThrows(lookup.ensureEnoughInfo, messages.insufficientInformation);
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
it("rejects lookups with only a country, address 1, and locality.", function () {
|
|
38
|
-
let lookup = new Lookup("a");
|
|
39
|
-
lookup.address1 = "b";
|
|
40
|
-
lookup.locality = "c";
|
|
41
|
-
|
|
42
|
-
ensureValidationThrows(lookup.ensureEnoughInfo, messages.insufficientInformation);
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it("rejects lookups with only a country, address 1, and adminstrative area.", function () {
|
|
46
|
-
let lookup = new Lookup("a");
|
|
47
|
-
lookup.address1 = "b";
|
|
48
|
-
lookup.administrativeArea = "c";
|
|
49
|
-
|
|
50
|
-
ensureValidationThrows(lookup.ensureEnoughInfo, messages.insufficientInformation);
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
it("rejects lookups with an invalid geocode value.", function () {
|
|
54
|
-
let lookup = new Lookup();
|
|
55
|
-
lookup.geocode = "Blarg!";
|
|
56
|
-
|
|
57
|
-
ensureValidationThrows(lookup.ensureValidData, messages.badGeocode);
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
it("rejects lookups with an invalid language.", function () {
|
|
61
|
-
let lookup = new Lookup();
|
|
62
|
-
lookup.language = "Rubberduckian";
|
|
63
|
-
|
|
64
|
-
ensureValidationThrows(lookup.ensureValidData, messages.invalidLanguage);
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
it("accepts lookups with enough info.", function () {
|
|
68
|
-
let lookup1 = new Lookup("a", "b");
|
|
69
|
-
|
|
70
|
-
let lookup2 = new Lookup("a");
|
|
71
|
-
lookup2.address1 = "b";
|
|
72
|
-
lookup2.postalCode = "c";
|
|
73
|
-
|
|
74
|
-
let lookup3 = new Lookup("a");
|
|
75
|
-
lookup3.address1 = "b";
|
|
76
|
-
lookup3.locality = "c";
|
|
77
|
-
lookup3.administrativeArea = "d";
|
|
78
|
-
|
|
79
|
-
expect(lookup1.ensureEnoughInfo()).to.equal(true);
|
|
80
|
-
expect(lookup2.ensureEnoughInfo()).to.equal(true);
|
|
81
|
-
expect(lookup3.ensureEnoughInfo()).to.equal(true);
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
it("accepts lookups with a valid language.", function () {
|
|
85
|
-
let lookup1 = new Lookup();
|
|
86
|
-
lookup1.language = "latin";
|
|
87
|
-
|
|
88
|
-
expect(lookup1.ensureValidData()).to.equal(true);
|
|
89
|
-
|
|
90
|
-
let lookup2 = new Lookup();
|
|
91
|
-
lookup2.language = "native";
|
|
92
|
-
|
|
93
|
-
expect(lookup2.ensureValidData()).to.equal(true);
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
function ensureValidationThrows(callback, message) {
|
|
97
|
-
let expectedError = new errors.UnprocessableEntityError(message);
|
|
98
|
-
|
|
99
|
-
try {
|
|
100
|
-
callback();
|
|
101
|
-
expect(true).to.equal(false);
|
|
102
|
-
}
|
|
103
|
-
catch (error) {
|
|
104
|
-
expect(error.message).to.equal(expectedError.message);
|
|
105
|
-
expect(error).to.be.an.instanceOf(errors.UnprocessableEntityError);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
});
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
const chai = require("chai");
|
|
2
|
-
const expect = chai.expect;
|
|
3
|
-
const Request = require("../src/Request");
|
|
4
|
-
const AgentSender = require("../src/AgentSender");
|
|
5
|
-
|
|
6
|
-
describe("An agent sender", function () {
|
|
7
|
-
it ("attaches an 'agent' parameter to the request config.", function () {
|
|
8
|
-
function MockSender() {
|
|
9
|
-
this.agentString = "";
|
|
10
|
-
|
|
11
|
-
this.send = (request) => {
|
|
12
|
-
this.agentString = request.parameters.agent;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
let mockSender = new MockSender();
|
|
17
|
-
let agentSender = new AgentSender(mockSender);
|
|
18
|
-
let request = new Request();
|
|
19
|
-
let expectedAgentString = "smarty (sdk:javascript@" + require("../package.json").version + ")";
|
|
20
|
-
|
|
21
|
-
agentSender.send(request);
|
|
22
|
-
|
|
23
|
-
expect(mockSender.agentString).to.equal(expectedAgentString);
|
|
24
|
-
});
|
|
25
|
-
});
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
const chai = require("chai");
|
|
2
|
-
const expect = chai.expect;
|
|
3
|
-
const BaseUrlSender = require("../src/BaseUrlSender");
|
|
4
|
-
const Request = require("../src/Request");
|
|
5
|
-
|
|
6
|
-
describe("A base url sender", function () {
|
|
7
|
-
let innerSender;
|
|
8
|
-
let request;
|
|
9
|
-
let urlOverride;
|
|
10
|
-
let baseUrlSender;
|
|
11
|
-
|
|
12
|
-
beforeEach(() => {
|
|
13
|
-
innerSender = {
|
|
14
|
-
send: () => true
|
|
15
|
-
};
|
|
16
|
-
request = new Request();
|
|
17
|
-
urlOverride = "I'm in your base, killing your mans.";
|
|
18
|
-
baseUrlSender = new BaseUrlSender(innerSender, urlOverride);
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
it("replaces the request's base url with a new value.", function () {
|
|
22
|
-
request.baseUrl = "All your baseUrl are belong to us.";
|
|
23
|
-
baseUrlSender.send(request);
|
|
24
|
-
|
|
25
|
-
expect(request.baseUrl).to.equal(urlOverride);
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
it("returns a promise.", function () {
|
|
29
|
-
expect(baseUrlSender.send(request) instanceof Promise).to.equal(true);
|
|
30
|
-
});
|
|
31
|
-
});
|