Skip to content

Commit 250b8a8

Browse files
author
Chris Park
committed
publish 0.7.3
1 parent ce87ea5 commit 250b8a8

File tree

3 files changed

+24
-32
lines changed

3 files changed

+24
-32
lines changed

.travis.yml

Lines changed: 0 additions & 9 deletions
This file was deleted.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "rosette-api",
33
"description": "Rosette API Node.JS client SDK",
4-
"version": "0.7.1",
4+
"version": "0.7.3",
55
"homepage": "https://developer.rosette.com",
66
"author": {
77
"name": "Basis Technology Corp.",

tests/mockApiTest.js

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ var NameTranslationParameters = require("../target/instrumented/lib/NameTranslat
2424
var fs = require("fs");
2525
var nock = require("nock");
2626
var zlib = require("zlib");
27+
var path =require('path');
2728

2829
/*
2930
======== A Handy Little Nodeunit Reference ========
@@ -50,12 +51,12 @@ function setMock() {
5051
nock("https://api.rosette.com/rest/v1")
5152
.persist()
5253
.get("/ping")
53-
.reply(200, new Buffer(fs.readFileSync("../mock-data/response/ping.json")));
54+
.reply(200, new Buffer(fs.readFileSync(path.resolve(__dirname, "mock-data/response/ping.json"))));
5455

5556
nock("https://api.rosette.com/rest/v1")
5657
.persist()
5758
.get("/info")
58-
.reply(200, new Buffer(fs.readFileSync("../mock-data/response/info.json")));
59+
.reply(200, new Buffer(fs.readFileSync(path.resolve(__dirname, "mock-data/response/info.json"))));
5960

6061
nock("https://api.rosette.com/rest/v1")
6162
.persist()
@@ -73,9 +74,9 @@ function setMock() {
7374
.reply(function (uri, request) {
7475
request = JSON.parse(request);
7576
var file = request.file;
76-
var statusCode = parseInt(fs.readFileSync("../mock-data/response/" + file + ".status"));
77+
var statusCode = parseInt(fs.readFileSync(path.resolve(__dirname, "mock-data/response/" + file + ".status")));
7778
// Because a call to the API returns a buffer
78-
var response = fs.readFileSync("../mock-data/response/" + file + ".json");
79+
var response = fs.readFileSync(path.resolve(__dirname, "mock-data/response/" + file + ".json"));
7980
return [statusCode, new Buffer(response)];
8081
});
8182
}
@@ -93,7 +94,7 @@ exports.testAllEndpoints = {
9394
callback();
9495
},
9596
"test endpoints": function(test) {
96-
var files = fs.readdirSync("../mock-data/request");
97+
var files = fs.readdirSync(path.resolve(__dirname, "mock-data/request"));
9798

9899
// All the regex necessary to extract info for the tests
99100
var filenameRe = /(\w+).json/;
@@ -105,7 +106,7 @@ exports.testAllEndpoints = {
105106
var counter = 0;
106107

107108
function checkResult(err, result) {
108-
var expected = JSON.parse(fs.readFileSync("../mock-data/response/" + files[counter]));
109+
var expected = JSON.parse(fs.readFileSync(path.resolve(__dirname, "mock-data/response/" + files[counter])));
109110
var errorExpected = false;
110111

111112
// Figure out if there should be an error
@@ -142,7 +143,7 @@ exports.testAllEndpoints = {
142143
if (files[i].indexOf(".json") > -1) {
143144
// Set up API with the file name as the user key
144145
var api = new Api("0123456789");
145-
var input = JSON.parse(fs.readFileSync("../mock-data/request/" + files[i]));
146+
var input = JSON.parse(fs.readFileSync(path.resolve(__dirname, "mock-data/request/" + files[i])));
146147

147148
// Anything not matched-name or translated-name
148149
if (files[i].indexOf("name") === -1) {
@@ -251,7 +252,7 @@ exports.testInfo = {
251252
"test info": function(test) {
252253
test.expect(1);
253254
var api = new Api("0123456789");
254-
var expected = JSON.parse(fs.readFileSync("../mock-data/response/info.json"));
255+
var expected = JSON.parse(fs.readFileSync(path.resolve(__dirname, "mock-data/response/info.json")));
255256
api.info(function (err, res) {
256257
if (err) {
257258
test.ok(false, "Shouldn't have thrown an error");
@@ -276,7 +277,7 @@ exports.testPing = {
276277
"test ping": function(test) {
277278
test.expect(1);
278279
var api = new Api("0123456789");
279-
var expected = JSON.parse(fs.readFileSync("../mock-data/response/ping.json"));
280+
var expected = JSON.parse(fs.readFileSync(path.resolve(__dirname, "mock-data/response/ping.json")));
280281
api.ping(function (err, res) {
281282
if (err) {
282283
test.ok(false, "Shouldn't have thrown an error");
@@ -342,7 +343,7 @@ function setPartialFailMock() {
342343

343344
nock("https://api.rosette.com/rest/v1")
344345
.get("/info")
345-
.reply(200, new Buffer(fs.readFileSync("../mock-data/response/info.json")));
346+
.reply(200, new Buffer(fs.readFileSync(path.resolve(__dirname, "mock-data/response/info.json"))));
346347
}
347348

348349
// Test that it actually retries because the first response will return a 503 status code but the second will return 200
@@ -359,7 +360,7 @@ exports.testRetryingRequest = {
359360
"test return correct error": function(test) {
360361
test.expect(1);
361362
var api = new Api("0123456789");
362-
var expected = JSON.parse(fs.readFileSync("../mock-data/response/info.json"));
363+
var expected = JSON.parse(fs.readFileSync(path.resolve(__dirname, "mock-data/response/info.json")));
363364
api.info(function (err, res) {
364365
if (err) {
365366
test.ok(false, "Shouldn't have thrown an error");
@@ -377,12 +378,12 @@ function setGzipMock() {
377378
nock("https://api.rosette.com/rest/v1")
378379
.persist()
379380
.get("/ping")
380-
.reply(200, new Buffer(fs.readFileSync("../mock-data/response/ping.json")));
381+
.reply(200, new Buffer(fs.readFileSync(path.resolve(__dirname, "mock-data/response/ping.json"))));
381382

382383
nock("https://api.rosette.com/rest/v1")
383384
.persist()
384385
.get("/info")
385-
.reply(200, new Buffer(fs.readFileSync("../mock-data/response/info.json")));
386+
.reply(200, new Buffer(fs.readFileSync(path.resolve(__dirname, "mock-data/response/info.json"))));
386387

387388
nock("https://api.rosette.com/rest/v1")
388389
.persist()
@@ -401,9 +402,9 @@ function setGzipMock() {
401402
.reply(function (uri, request) {
402403
request = JSON.parse(request);
403404
var file = request.file;
404-
var statusCode = parseInt(fs.readFileSync("../mock-data/response/" + file + ".status"));
405+
var statusCode = parseInt(fs.readFileSync(path.resolve(__dirname, "mock-data/response/" + file + ".status")));
405406
// Because a call to the API returns a buffer
406-
var response = fs.readFileSync("../mock-data/response/" + file + ".json");
407+
var response = fs.readFileSync(path.resolve(__dirname, "mock-data/response/" + file + ".json"));
407408
return [statusCode, zlib.gzipSync(response)];
408409
});
409410
}
@@ -421,7 +422,7 @@ exports.testAllEndpointsGzipped = {
421422
callback();
422423
},
423424
"test endpoints": function(test) {
424-
var files = fs.readdirSync("../mock-data/request");
425+
var files = fs.readdirSync(path.resolve(__dirname, "mock-data/request"));
425426

426427
// All the regex necessary to extract info for the tests
427428
var filenameRe = /(\w+).json/;
@@ -433,7 +434,7 @@ exports.testAllEndpointsGzipped = {
433434
var counter = 0;
434435

435436
function checkResult(err, result) {
436-
var expected = JSON.parse(fs.readFileSync("../mock-data/response/" + files[counter]));
437+
var expected = JSON.parse(fs.readFileSync(path.resolve(__dirname, "mock-data/response/" + files[counter])));
437438
var errorExpected = false;
438439

439440
// Figure out if there should be an error
@@ -470,7 +471,7 @@ exports.testAllEndpointsGzipped = {
470471
if (files[i].indexOf(".json") > -1) {
471472
// Set up API with the file name as the user key
472473
var api = new Api("0123456789");
473-
var input = JSON.parse(fs.readFileSync("../mock-data/request/" + files[i]));
474+
var input = JSON.parse(fs.readFileSync(path.resolve(__dirname, "mock-data/request/" + files[i])));
474475

475476
// Anything not matched-name or translated-name
476477
if (files[i].indexOf("name") === -1) {
@@ -577,7 +578,7 @@ exports.testTextOnly = {
577578
nock("https://api.rosette.com/rest/v1")
578579
.persist()
579580
.get("/info")
580-
.reply(200, new Buffer(fs.readFileSync("../mock-data/response/info.json")));
581+
.reply(200, new Buffer(fs.readFileSync(path.resolve(__dirname, "mock-data/response/info.json"))));
581582

582583
nock("https://api.rosette.com/rest/v1")
583584
.persist()
@@ -590,9 +591,9 @@ exports.testTextOnly = {
590591
.post("/entities")
591592
.reply(function () {
592593
var file = "eng-sentence-entities";
593-
var statusCode = parseInt(fs.readFileSync("../mock-data/response/" + file + ".status"));
594+
var statusCode = parseInt(fs.readFileSync(path.resolve(__dirname, "mock-data/response/" + file + ".status")));
594595
// Because a call to the API returns a buffer
595-
var response = fs.readFileSync("../mock-data/response/" + file + ".json");
596+
var response = fs.readFileSync(path.resolve(__dirname, "mock-data/response/" + file + ".json"));
596597
return [statusCode, new Buffer(response)];
597598
});
598599

@@ -604,7 +605,7 @@ exports.testTextOnly = {
604605
callback();
605606
},
606607
"test entities": function(test) {
607-
var expected = JSON.parse(fs.readFileSync("../mock-data/response/eng-sentence-entities.json"));
608+
var expected = JSON.parse(fs.readFileSync(path.resolve(__dirname, "mock-data/response/eng-sentence-entities.json")));
608609
this.api.entities(this.content, false, function(err, res) {
609610
if (err) {
610611
test.ok(false, "threw an error");

0 commit comments

Comments
 (0)