Skip to content

Commit 7dbbf6d

Browse files
committed
Merge pull request watson-developer-cloud#237 from g-may/patch-2
Add tests for Alchemy endpoint selection
2 parents f1a9456 + 8e6e4c4 commit 7dbbf6d

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

test/test.alchemy_language.v1.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,28 @@ describe('alchemy_language', function() {
7474
var expectedBody = qs.stringify({ text: payload.text, outputMode: 'json'});
7575
assert.equal(body, expectedBody);
7676
});
77+
78+
it('should use /text/ endpoint if the text parameter is passed', function() {
79+
var req = alchemy.sentiment({text: payload.text, url:'www.ibm.com'}, noop);
80+
var sentimenPath = service.url + '/text/TextGetTextSentiment?apikey=' + service.api_key;
81+
assert.equal(req.uri.href, sentimenPath);
82+
assert.equal(req.method, 'POST');
83+
assert(req.form);
84+
var body = new Buffer(req.body).toString('ascii');
85+
var expectedBody = qs.stringify({ text: payload.text, url:'www.ibm.com', outputMode: 'json'});
86+
assert.equal(body, expectedBody);
87+
});
88+
89+
it('should use /html/ endpoint if the html parameter is passed', function() {
90+
var req = alchemy.sentiment({html: '<html><body>test</body></html>', url:'www.ibm.com'}, noop);
91+
var sentimenPath = service.url + '/html/HTMLGetTextSentiment?apikey=' + service.api_key;
92+
assert.equal(req.uri.href, sentimenPath);
93+
assert.equal(req.method, 'POST');
94+
assert(req.form);
95+
var body = new Buffer(req.body).toString('ascii');
96+
var expectedBody = qs.stringify({html: '<html><body>test</body></html>', url:'www.ibm.com', outputMode: 'json'});
97+
assert.equal(body, expectedBody);
98+
});
7799

78100
});
79101
});

0 commit comments

Comments
 (0)