ellipsis-api
Advanced tools
Comparing version 0.0.5 to 0.0.6
"use strict"; | ||
jest.unmock('../index'); | ||
jest.unmock('../error-messages'); | ||
jest.mock('request'); | ||
jest.mock('request', () => { | ||
return { | ||
post: jest.fn((params, callback) => callback(null, { statusCode: 200 }, { form: params.form })) | ||
}; | ||
}); | ||
const errorMessages = require('../error-messages'); | ||
const request = require('request'); | ||
const EllipsisApi = require('../index'); | ||
@@ -36,4 +39,4 @@ const ellipsis = { | ||
const actionName = "foo"; | ||
return actionsApi.run({ actionName: actionName, args: args }).then(data => { | ||
const form = data.body.form; | ||
return actionsApi.run({ actionName: actionName, args: args }).then(body => { | ||
const form = body.form; | ||
const expectedForm = Object.assign({}, defaultExpectedForm, { | ||
@@ -45,3 +48,3 @@ actionName: actionName, | ||
expect(form).toEqual(expectedForm); | ||
expect(data.url).toEqual(actionsApi.urlFor("run_action")) | ||
expect(request.post.mock.calls[0][0].url).toEqual(actionsApi.urlFor("run_action")); | ||
}); | ||
@@ -55,4 +58,4 @@ | ||
const trigger = "foo bar baz"; | ||
return actionsApi.run({ trigger: trigger }).then(data => { | ||
const form = data.body.form; | ||
return actionsApi.run({ trigger: trigger }).then(body => { | ||
const form = body.form; | ||
const expectedForm = Object.assign({}, defaultExpectedForm, { | ||
@@ -62,3 +65,3 @@ trigger: trigger | ||
expect(form).toEqual(expectedForm); | ||
expect(data.url).toEqual(actionsApi.urlFor("run_action")) | ||
expect(request.post.mock.calls[0][0].url).toEqual(actionsApi.urlFor("run_action")); | ||
}); | ||
@@ -94,4 +97,4 @@ | ||
const message = "yo"; | ||
return actionsApi.say({ message: message }).then(data => { | ||
const form = data.body.form; | ||
return actionsApi.say({ message: message }).then(body => { | ||
const form = body.form; | ||
const expectedForm = Object.assign({}, defaultExpectedForm, { | ||
@@ -101,3 +104,3 @@ message: message | ||
expect(form).toEqual(expectedForm); | ||
expect(data.url).toEqual(actionsApi.urlFor("say")) | ||
expect(request.post.mock.calls[0][0].url).toEqual(actionsApi.urlFor("say")); | ||
}); | ||
@@ -134,4 +137,4 @@ | ||
}); | ||
return actionsApi.schedule(options).then(data => { | ||
const form = data.body.form; | ||
return actionsApi.schedule(options).then(body => { | ||
const form = body.form; | ||
const expectedForm = Object.assign({}, defaultExpectedForm, defaultOptions, { | ||
@@ -143,3 +146,3 @@ actionName: options.actionName, | ||
expect(form).toEqual(expectedForm); | ||
expect(data.url).toEqual(actionsApi.urlFor("schedule_action")) | ||
expect(request.post.mock.calls[0][0].url).toEqual(actionsApi.urlFor("schedule_action")); | ||
}); | ||
@@ -195,4 +198,4 @@ | ||
}); | ||
return actionsApi.unschedule(options).then(data => { | ||
const form = data.body.form; | ||
return actionsApi.unschedule(options).then(body => { | ||
const form = body.form; | ||
const expectedForm = Object.assign({}, defaultExpectedForm, { | ||
@@ -202,3 +205,3 @@ actionName: options.actionName | ||
expect(form).toEqual(expectedForm); | ||
expect(data.url).toEqual(actionsApi.urlFor("unschedule_action")) | ||
expect(request.post.mock.calls[0][0].url).toEqual(actionsApi.urlFor("unschedule_action")); | ||
}); | ||
@@ -241,4 +244,4 @@ | ||
const query = "{ foo { bar } }"; | ||
return storageApi.query({ query: query }).then(data => { | ||
const form = data.body.form; | ||
return storageApi.query({ query: query }).then(body => { | ||
const form = body.form; | ||
const expectedForm = { | ||
@@ -251,3 +254,3 @@ query: query, | ||
expect(form).toEqual(expectedForm); | ||
expect(data.url).toEqual(storageApi.url()) | ||
expect(request.post.mock.calls[0][0].url).toEqual(storageApi.url()); | ||
}); | ||
@@ -262,4 +265,4 @@ | ||
const variables = { key1: "something", key2: { key3: "something else" } }; | ||
return storageApi.query({ query: query, variables: variables }).then(data => { | ||
const form = data.body.form; | ||
return storageApi.query({ query: query, variables: variables }).then(body => { | ||
const form = body.form; | ||
const expectedForm = { | ||
@@ -272,3 +275,3 @@ query: query, | ||
expect(form).toEqual(expectedForm); | ||
expect(data.url).toEqual(storageApi.url()) | ||
expect(request.post.mock.calls[0][0].url).toEqual(storageApi.url()); | ||
}); | ||
@@ -283,4 +286,4 @@ | ||
const variables = '{ "key1": "something", "key2": { "key3": "something else" } }'; | ||
return storageApi.query({ query: query, variables: variables }).then(data => { | ||
const form = data.body.form; | ||
return storageApi.query({ query: query, variables: variables }).then(body => { | ||
const form = body.form; | ||
const expectedForm = { | ||
@@ -293,3 +296,3 @@ query: query, | ||
expect(form).toEqual(expectedForm); | ||
expect(data.url).toEqual(storageApi.url()) | ||
expect(request.post.mock.calls[0][0].url).toEqual(storageApi.url()); | ||
}); | ||
@@ -296,0 +299,0 @@ |
@@ -56,3 +56,3 @@ const request = require('request'); | ||
} else if (options.success) { | ||
options.success(response, body); | ||
options.success(body); | ||
} else { | ||
@@ -222,4 +222,6 @@ // do nothing if no success argument was provided | ||
reject(error); | ||
} else if (response.statusCode !== 200) { | ||
reject(`Error ${response.statusCode}: ${response.body}`); | ||
} else { | ||
resolve(response, body); | ||
resolve(body); | ||
} | ||
@@ -226,0 +228,0 @@ }); |
{ | ||
"name": "ellipsis-api", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"description": "Interact with Ellipsis skills & actions", | ||
@@ -12,3 +12,3 @@ "main": "index.js", | ||
"dependencies": { | ||
"request": "latest" | ||
"request": "^2.81.0" | ||
}, | ||
@@ -15,0 +15,0 @@ "devDependencies": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16509
8
460
Updatedrequest@^2.81.0