Skip to content

Commit 61ae2c7

Browse files
committed
Merge branch 'Mikemosca-conv_329'
2 parents ad8ab03 + 98f2db4 commit 61ae2c7

4 files changed

Lines changed: 64 additions & 10 deletions

File tree

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ script:
1010
after_success:
1111
- jsdoc/publish.sh
1212
before_install:
13-
- '[ "${TRAVIS_PULL_REQUEST}" = "false" ] && openssl aes-256-cbc -K $encrypted_d4f181ef7c79_key -iv $encrypted_d4f181ef7c79_iv -in auth.js.enc -out test/resources/auth.js -d || true'
13+
- '[ "${TRAVIS_PULL_REQUEST}" = "false" ] && openssl aes-256-cbc -K $encrypted_cb4d3d070e32_key -iv $encrypted_cb4d3d070e32_iv -in auth.js.enc -out test/resources/auth.js -d || true'
1414
env:
1515
global:
1616
secure: I50FnfubwiZlol5Qs9tXPVACGbs+SG2dJLjpbzeio0Hl666d/hDuvf7IFwqqaRjQkmK2TdIjaGLMOgHxh/GGAoYf7LfZqjDID/tAhgoFOYiZwiPj66Z82F9P9cega2nkNW+125NzPuU3rhSCByG8+K/PMH/5JxPwPMoAYNLQjWc=

auth.js.enc

368 Bytes
Binary file not shown.

test/test.conversation.v1.js

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,14 @@ describe('conversation-v1', function() {
1616
password: 'bruce-wayne',
1717
url: 'http://ibm.com:80',
1818
version: 'v1',
19-
version_date: '2016-05-19'
19+
version_date: '2016-07-11'
20+
};
21+
22+
var service1 = {
23+
password: 'bruce-wayne',
24+
url: 'http://ibm.com:80',
25+
version: 'v1',
26+
username: 'batman'
2027
};
2128

2229
var payload = {
@@ -47,22 +54,45 @@ describe('conversation-v1', function() {
4754

4855
describe('conversation()', function() {
4956
var reqPayload = {input:'foo',context:'rab'};
57+
var reqPayload1 = {output:'foo',alternate_intents:true,entities:'1entity',intents:'1intent',junk:'junk'};
58+
var reqPayload2 = {output:'foo',alternate_intents:true,entities:'1entity',intents:'1intent'};
5059
var params = extend({}, reqPayload, payload);
60+
var params1 = extend({}, reqPayload1, payload);
61+
62+
it('should generate a valid payload', function() {
63+
var req = conversation.message(params,noop);
64+
var body = new Buffer(req.body).toString('ascii');
65+
assert.equal(req.uri.href, service.url + paths.message + '?version=' + service.version_date);
66+
assert.equal(req.method, 'POST');
67+
assert.deepEqual(JSON.parse(body), reqPayload);
68+
});
69+
70+
it('should generate a valid payload but parse out the junk option', function() {
71+
var req = conversation.message(params1,noop);
72+
var body = new Buffer(req.body).toString('ascii');
73+
assert.equal(req.uri.href, service.url + paths.message + '?version=' + service.version_date);
74+
assert.equal(req.method, 'POST');
75+
assert.deepEqual(JSON.parse(body), reqPayload2);
76+
});
5177

52-
it('should check no parameters provided', function() {
78+
it('should check no parameters provided (negative test)', function() {
5379
conversation.message({}, missingParameter);
5480
conversation.message(null, missingParameter);
5581
conversation.message(undefined, missingParameter);
5682
conversation.message(pick(params,['workspace_id']), missingParameter);
83+
conversation.message(pick(params,['input']), missingParameter);
5784
});
5885

59-
it('should generate a valid payload', function(done) {
60-
var req = conversation.message(params,noop);
61-
var body = new Buffer(req.body).toString('ascii');
62-
assert.equal(req.uri.href, service.url + paths.message + '?version=' + service.version_date);
63-
assert.equal(req.method, 'POST');
64-
assert.deepEqual(JSON.parse(body), reqPayload);
65-
done();
86+
it('should generate version_date was not specified (negative test)', function() {
87+
var threw = false;
88+
try {
89+
watson.conversation(service1);
90+
}
91+
catch(err) {
92+
threw = true;
93+
assert.equal(err.message, 'Argument error: version_date was not specified, use 2016-07-11');
94+
}
95+
assert(threw, "should throw an error")
6696
});
6797
});
6898

test/test.zz.integration-all-services.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -712,4 +712,28 @@ describe('integration-all-services', function() {
712712
});
713713
});
714714
});
715+
716+
describe('functional_conversation', function() {
717+
this.timeout(TEN_SECONDS);
718+
var conversation = watson.conversation(auth.conversation);
719+
720+
it('message()', function(done) {
721+
var params = {
722+
input: {
723+
text: 'Turn on the lights'
724+
},
725+
alternate_intents: true,
726+
workspace_id: auth.conversation.workspace_id
727+
};
728+
729+
conversation.message(params, function(err, result) {
730+
if (err) {
731+
return done(err);
732+
}
733+
assert.equal(result.alternate_intents, true);
734+
done();
735+
});
736+
});
737+
});
738+
715739
});

0 commit comments

Comments
 (0)