Skip to content

Commit be31baa

Browse files
committed
test: add tests for new assistant/conversation methods
1 parent b891cb3 commit be31baa

File tree

4 files changed

+100
-0
lines changed

4 files changed

+100
-0
lines changed

test/integration/test.assistant.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -958,6 +958,23 @@ describe('assistant_integration', function() {
958958
});
959959
});
960960

961+
describe('listEntityMentions()', function() {
962+
it('should return an EntityMentionCollection', function(done) {
963+
const params = {
964+
workspace_id: workspace1.workspace_id,
965+
entity: test_entities_update.entity,
966+
};
967+
assistant.listEntityMentions(params, function(err, result) {
968+
if (err) {
969+
return done(err);
970+
}
971+
assert(Array.isArray(result.examples));
972+
assert(result.pagination);
973+
done();
974+
});
975+
});
976+
});
977+
961978
describe('deleteEntity()', function() {
962979
it('should delete an entity of the workspace', function(done) {
963980
const params = {

test/integration/test.conversation.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -954,6 +954,23 @@ describe('conversation_integration', function() {
954954
});
955955
});
956956

957+
describe('listEntityMentions()', function() {
958+
it('should return an EntityMentionCollection', function(done) {
959+
const params = {
960+
workspace_id: workspace1.workspace_id,
961+
entity: test_entities_update.entity,
962+
};
963+
conversation.listEntityMentions(params, function(err, result) {
964+
if (err) {
965+
return done(err);
966+
}
967+
assert(Array.isArray(result.examples));
968+
assert(result.pagination);
969+
done();
970+
});
971+
});
972+
});
973+
957974
describe('deleteEntity()', function() {
958975
it('should delete an entity of the workspace', function(done) {
959976
const params = {

test/unit/test.assistant.v1.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -919,6 +919,39 @@ describe('assistant-v1', function() {
919919
});
920920
});
921921

922+
describe('listEntityMentions()', function() {
923+
it('should check no parameters provided (negative test)', function() {
924+
assistant.listEntityMentions({}, missingParameter);
925+
assistant.listEntityMentions(null, missingParameter);
926+
assistant.listEntityMentions(undefined, missingParameter);
927+
assistant.listEntityMentions({ workspace_id: '123' }, missingParameter);
928+
});
929+
930+
it('should generate a valid payload', function() {
931+
const params = {
932+
workspace_id: 'id123',
933+
entity: 'ent123',
934+
export: true,
935+
include_audit: true,
936+
};
937+
const path =
938+
service.url +
939+
'/v1/workspaces/' +
940+
params.workspace_id +
941+
'/entities/' +
942+
params.entity +
943+
'/mentions?version=' +
944+
service.version +
945+
'&export=' +
946+
params.export +
947+
'&include_audit=' +
948+
params.include_audit;
949+
const req = assistant.listEntityMentions(params, noop);
950+
assert.equal(req.uri.href, path);
951+
assert.equal(req.method, 'GET');
952+
});
953+
});
954+
922955
describe('credentials()', function() {
923956
it('should load its credentials from bluemix (conversation)', function() {
924957
process.env.VCAP_SERVICES = JSON.stringify({

test/unit/test.conversation.v1.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -916,4 +916,37 @@ describe('conversation-v1', function() {
916916
assert.equal(req.method, 'POST');
917917
});
918918
});
919+
920+
describe('listEntityMentions()', function() {
921+
it('should check no parameters provided (negative test)', function() {
922+
conversation.listEntityMentions({}, missingParameter);
923+
conversation.listEntityMentions(null, missingParameter);
924+
conversation.listEntityMentions(undefined, missingParameter);
925+
conversation.listEntityMentions({ workspace_id: '123' }, missingParameter);
926+
});
927+
928+
it('should generate a valid payload', function() {
929+
const params = {
930+
workspace_id: 'id123',
931+
entity: 'ent123',
932+
export: true,
933+
include_audit: true,
934+
};
935+
const path =
936+
service.url +
937+
'/v1/workspaces/' +
938+
params.workspace_id +
939+
'/entities/' +
940+
params.entity +
941+
'/mentions?version=' +
942+
service.version +
943+
'&export=' +
944+
params.export +
945+
'&include_audit=' +
946+
params.include_audit;
947+
const req = conversation.listEntityMentions(params, noop);
948+
assert.equal(req.uri.href, path);
949+
assert.equal(req.method, 'GET');
950+
});
951+
});
919952
});

0 commit comments

Comments
 (0)