UNPKG

1.05 kBJavaScriptView Raw
1import CONFIGURATION_1 from './data/configuration_1.json';
2
3import craftai from '../src';
4
5describe('client.listAgents()', function() {
6 let client;
7 const agentsId = [`list_agents_${RUN_ID}_1`, `list_agents_${RUN_ID}_2`, `list_agents_${RUN_ID}_3`];
8
9 before(function() {
10 client = craftai(CRAFT_CFG);
11 expect(client).to.be.ok;
12 });
13
14 beforeEach(function() {
15 return Promise.all(_.map(agentsId, (agentId) => client.deleteAgent(agentId))) // Delete any preexisting agent with this id.
16 .then(() => Promise.all(_.map(agentsId, (agentId) => client.createAgent(CONFIGURATION_1, agentId))));
17 });
18
19 afterEach(function() {
20 return Promise.all(_.map(agentsId, (agentId) => client.deleteAgent(agentId)));
21 });
22
23 it('should retrieve the created agents', function() {
24 return client.listAgents()
25 .then((retrievedAgentIds) => {
26 expect(retrievedAgentIds).to.include(agentsId[0]);
27 expect(retrievedAgentIds).to.include(agentsId[1]);
28 expect(retrievedAgentIds).to.include(agentsId[2]);
29 });
30 });
31});