ellipsis-api
Advanced tools
Comparing version 0.0.9 to 0.0.10
@@ -8,5 +8,6 @@ "use strict"; | ||
const response = { | ||
statusCode: 200, | ||
statusCode: options.form.token ? 200 : 400, | ||
statusMessage: options.form.token ? "Ok" : "Bad request", | ||
url: options.url, | ||
body: body // just echo back the options for inspection by tests | ||
body: require('util').inspect(body) // just echo back the options for inspection by tests | ||
}; | ||
@@ -13,0 +14,0 @@ callback(null, response, body); |
@@ -8,23 +8,25 @@ "use strict"; | ||
const EllipsisApi = require('../index'); | ||
const ellipsis = { | ||
userInfo: { | ||
messageInfo: { | ||
medium: "slack", | ||
channel: "C123456" | ||
} | ||
}, | ||
token: "123456acbdef" | ||
}; | ||
const defaultExpectedForm = { | ||
responseContext: ellipsis.userInfo.messageInfo.medium, | ||
channel: ellipsis.userInfo.messageInfo.channel, | ||
token: ellipsis.token | ||
}; | ||
const EllipsisApiError = require('../ellipsis-api-error'); | ||
let ellipsis, defaultExpectedForm, api, actionsApi, storageApi; | ||
const api = new EllipsisApi(ellipsis); | ||
const actionsApi = api.actions; | ||
const storageApi = api.storage; | ||
describe("ActionsApi", () => { | ||
beforeEach(() => { | ||
ellipsis = { | ||
userInfo: { | ||
messageInfo: { | ||
medium: "slack", | ||
channel: "C123456" | ||
} | ||
}, | ||
token: "123456acbdef" | ||
}; | ||
defaultExpectedForm = { | ||
responseContext: ellipsis.userInfo.messageInfo.medium, | ||
channel: ellipsis.userInfo.messageInfo.channel, | ||
token: ellipsis.token | ||
}; | ||
api = new EllipsisApi(ellipsis); | ||
actionsApi = api.actions; | ||
storageApi = api.storage; | ||
}); | ||
describe("run", () => { | ||
@@ -78,2 +80,10 @@ it("sends an appropriate api request for a name", () => { | ||
it("throws an EllipsisApiError if a bad status code is received", () => { | ||
expect.assertions(1); | ||
api.ellipsis.token = null; | ||
const trigger = "foo bar baz"; | ||
return actionsApi.run({ trigger: trigger }).catch(err => { | ||
expect(err instanceof EllipsisApiError).toBe(true); | ||
}); | ||
}); | ||
}); | ||
@@ -80,0 +90,0 @@ |
const request = require('request'); | ||
const errorMessages = require('./error-messages'); | ||
const EllipsisApiError = require('./ellipsis-api-error'); | ||
@@ -31,3 +32,3 @@ class AbstractApi { | ||
} else { | ||
throw new Error(error); | ||
throw error; | ||
} | ||
@@ -44,3 +45,3 @@ } | ||
} else if (response.statusCode !== 200) { | ||
this.handleError(options, response.statusCode + ": " + response.statusMessage); | ||
this.handleError(options, new EllipsisApiError({ response: response, body: body })); | ||
} else if (options.success) { | ||
@@ -160,2 +161,3 @@ options.success(body); | ||
actionName: mergedOptions.actionName, | ||
trigger: mergedOptions.trigger, | ||
userId: mergedOptions.userId, | ||
@@ -216,3 +218,3 @@ channel: this.channelFor(mergedOptions), | ||
} else if (response.statusCode !== 200) { | ||
reject(`${response.statusCode}: ${response.statusMessage}`); | ||
reject(new EllipsisApiError({ response: response, body: body })); | ||
} else { | ||
@@ -219,0 +221,0 @@ resolve(body); |
{ | ||
"name": "ellipsis-api", | ||
"version": "0.0.9", | ||
"version": "0.0.10", | ||
"description": "Interact with Ellipsis skills & actions", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
20031
494
0