Skip to content

Commit c80bcda

Browse files
DEVOPS-247: fix parameters; add unittest
1 parent cf2d7ca commit c80bcda

File tree

3 files changed

+55
-3
lines changed

3 files changed

+55
-3
lines changed

lib/parameters.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ parameters.prototype.loadParams = function() {
102102
"contentUri": this.contentUri,
103103
"language": this.language,
104104
"genre": this.genre,
105+
"address1": this.address1,
106+
"address2": this.address2,
105107
"name1": this.name1,
106108
"name2": this.name2,
107109
"name": this.name,

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "rosette-api",
3-
"version": "1.12.2",
3+
"version": "1.14.3",
44
"description": "Rosette API Node.js client SDK",
55
"main": "index",
66
"directories": {
@@ -12,6 +12,7 @@
1212
"url": "git://github.com/rosette-api/nodejs.git"
1313
},
1414
"keywords": [
15+
"address similarity",
1516
"categorization",
1617
"entity extraction",
1718
"language detection",

tests/unittests.js

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
"use strict"
1+
"use strict";
22

33
var chai = require('chai');
44
var mocha = require('mocha');
55
var nock = require('nock');
66
var fs = require('fs');
77

88
var Api = require("../lib/Api");
9+
var addressSimilarity = require("../lib/addressSimilarity");
910
var language = require("../lib/language");
1011
var relationships = require("../lib/relationships");
1112
var nameDeduplication = require("../lib/nameDeduplication");
@@ -143,6 +144,55 @@ describe("Relationships Endpoint", function() {
143144
});
144145
});
145146

147+
describe("Address Similarity Endpoint", function() {
148+
beforeEach(function(done) {
149+
var mockResponse = JSON.stringify({'name': 'Rosette API', 'versionChecked': true});
150+
151+
nock('https://api.rosette.com', {"encodedQueryParams": true })
152+
.post('/rest/v1/info')
153+
.query({"clientVersion": "1.14.3"})
154+
.reply(200, JSON.parse(mockResponse));
155+
156+
nock('https://api.rosette.com', {"encodedQueryParams": true })
157+
.post('/rest/v1/address-similarity')
158+
.query({"clientVersion": "1.14.3"})
159+
.reply(200, JSON.parse(mockResponse));
160+
done();
161+
});
162+
163+
afterEach(function(done) {
164+
nock.cleanAll();
165+
done();
166+
});
167+
168+
it("successfully calls the address similarity endpoint", function(done) {
169+
var api = new Api('123456789', 'https://api.rosette.com/rest/v1');
170+
171+
api.parameters.address1 = {"city": "cambridge", "state": "ma"};
172+
api.parameters.address2 = {"city": "Cambridge", "road": "1 Kendall sq."};
173+
174+
api.rosette("addressSimilarity", function(err, res) {
175+
chai.expect(err).to.be.null;
176+
chai.expect(res.name).to.equal('Rosette API');
177+
done();
178+
});
179+
180+
});
181+
182+
it("detects missing name parameter", function(done) {
183+
var api = new Api('123456789', 'https://api.rosette.com/rest/v1');
184+
185+
api.parameters.address1 = {"city": "cambridge", "state": "ma"};
186+
187+
api.rosette("addressSimilarity", function(err, res) {
188+
chai.expect(err).to.not.be.null;
189+
chai.expect(err.name).to.equal('RosetteException');
190+
chai.expect(err.message).to.contain('badArgument');
191+
done();
192+
});
193+
});
194+
});
195+
146196
describe("Name Deduplication Endpoint", function() {
147197
beforeEach(function(done) {
148198
var mockResponse = JSON.stringify({'name': 'Rosette API', 'versionChecked': true});
@@ -1047,4 +1097,3 @@ describe("Topics Endpoint", function() {
10471097
});
10481098
});
10491099
});
1050-

0 commit comments

Comments
 (0)