ellipsis-api
Advanced tools
Comparing version 0.0.6 to 0.0.7
@@ -5,3 +5,3 @@ "use strict"; | ||
post: function (options, callback) { | ||
post: jest.fn((options, callback) => { | ||
const body = options; | ||
@@ -14,4 +14,4 @@ const response = { | ||
callback(null, response, body); | ||
} | ||
}) | ||
}; |
"use strict"; | ||
jest.mock('request', () => { | ||
return { | ||
post: jest.fn((params, callback) => callback(null, { statusCode: 200 }, { form: params.form })) | ||
}; | ||
}); | ||
jest.mock('request'); | ||
@@ -298,1 +294,35 @@ const errorMessages = require('../error-messages'); | ||
}); | ||
describe("legacy API methods", () => { | ||
it("works to call say from the api root", () => { | ||
expect.hasAssertions(); | ||
return api.say({ message: "yo" }).then(() => { | ||
expect(request.post.mock.calls[0][0].url).toEqual(actionsApi.urlFor("say")); | ||
}); | ||
}); | ||
it("works to call run from the api root", () => { | ||
expect.hasAssertions(); | ||
return api.run({ trigger: "yo" }).then(() => { | ||
expect(request.post.mock.calls[0][0].url).toEqual(actionsApi.urlFor("run_action")); | ||
}); | ||
}); | ||
it("works to call schedule from the api root", () => { | ||
expect.hasAssertions(); | ||
return api.schedule({ trigger: "yo", recurrence: "every day at noon" }).then(() => { | ||
expect(request.post.mock.calls[0][0].url).toEqual(actionsApi.urlFor("schedule_action")); | ||
}); | ||
}); | ||
it("works to call unschedule from the api root", () => { | ||
expect.hasAssertions(); | ||
return api.unschedule({ trigger: "yo" }).then(() => { | ||
expect(request.post.mock.calls[0][0].url).toEqual(actionsApi.urlFor("unschedule_action")); | ||
}); | ||
}); | ||
}); |
24
index.js
@@ -38,12 +38,2 @@ const request = require('request'); | ||
class Api extends AbstractApi { | ||
constructor(ellipsis) { | ||
super(ellipsis); | ||
this.actions = new ActionsApi(ellipsis); | ||
this.storage = new StorageApi(ellipsis); | ||
} | ||
} | ||
class ActionsApi extends AbstractApi { | ||
@@ -233,2 +223,16 @@ | ||
class Api extends AbstractApi { | ||
constructor(ellipsis) { | ||
super(ellipsis); | ||
this.actions = new ActionsApi(ellipsis); | ||
this.storage = new StorageApi(ellipsis); | ||
this.say = this.actions.say.bind(this.actions); | ||
this.run = this.actions.run.bind(this.actions); | ||
this.schedule = this.actions.schedule.bind(this.actions); | ||
this.unschedule = this.actions.unschedule.bind(this.actions); | ||
} | ||
} | ||
module.exports = Api; |
{ | ||
"name": "ellipsis-api", | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"description": "Interact with Ellipsis skills & actions", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "./node_modules/.bin/jest" | ||
"test": "jest", | ||
"lint": "eslint .", | ||
"prepublishOnly": "npm run lint && npm test" | ||
}, | ||
@@ -15,4 +17,5 @@ "author": "Ellipsis Co. <a@ellipsis.ai> (http://ellipsis.ai)", | ||
"devDependencies": { | ||
"eslint": "^4.3.0", | ||
"jest-cli": "^20.0.3" | ||
} | ||
} |
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
19293
11
486
2