Skip to content

Commit ab9abcf

Browse files
author
Adam Soos
committed
WS-3330: fix and test request with documentFile
1 parent 4c73675 commit ab9abcf

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

lib/parameters.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,10 @@ parameters.prototype.loadFile = function(filePath, loadedParameters, userKey, pr
226226
result.headers = res.headers;
227227
result = JSON.stringify(result);
228228

229-
if (res.statusCode === 200 && res.statusCode != 200) {
230-
return callback(err, JSON.parse(result.toString()));
229+
if (res.statusCode === 200) {
230+
return callback(null, JSON.parse(result.toString()));
231+
} else {
232+
return callback(new RosetteException(res.statusCode, result.toString()));
231233
}
232234
});
233235
});

tests/test.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
The quick brown fox jumped over the lazy dog. 👍🏾 Yes he did. B)

tests/unittests.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,18 @@ describe("Entities Endpoint", function() {
589589
done();
590590
});
591591
});
592+
593+
it("successfully calls entities with documentFile", function(done) {
594+
var api = new Api('123456789', 'https://analytics.babelstreet.com/rest/v1');
595+
596+
api.parameters.documentFile = "tests/test.txt";
597+
598+
api.rosette("entities", function(err, res) {
599+
chai.expect(err).to.be.null;
600+
chai.expect(res.name).to.equal('Rosette API');
601+
done();
602+
});
603+
});
592604
});
593605

594606
describe("Events Endpoint", function() {

0 commit comments

Comments
 (0)