Add unit test for `kind` parameter on actions.create
diff --git a/README.md b/README.md
index 80c1dae..eabde8c 100644
--- a/README.md
+++ b/README.md
@@ -326,6 +326,7 @@
The following optional parameters are supported:
- `namespace` - set custom namespace for endpoint
- `params` - object containing default parameters for the action (default: `{}`)
+- `kind` - runtime environment parameter, ignored when `action` is an object (default: `nodejs:default`)
If you pass in an array for the first parameter, the `create` call will be executed for each array item. The function returns a Promise which resolves with the results when all operations have finished.
diff --git a/test/unit/actions.test.js b/test/unit/actions.test.js
index 8f3c274..78cf16f 100644
--- a/test/unit/actions.test.js
+++ b/test/unit/actions.test.js
@@ -249,12 +249,31 @@
return actions.create({name: '12345', action})
})
+test('create a new action with custom kind', t => {
+ t.plan(4)
+ const ns = '_'
+ const client = {}
+ const action = 'function main() { // main function body};'
+ const kind = 'custom_runtime:version'
+ const actions = new Actions(client)
+
+ client.request = (method, path, options) => {
+ t.is(method, 'PUT')
+ t.is(path, `namespaces/${ns}/actions/12345`)
+ t.deepEqual(options.qs, {})
+ t.deepEqual(options.body, {exec: {kind, code: action}})
+ }
+
+ return actions.create({name: '12345', action, kind})
+})
+
test('create a new action with custom body', t => {
t.plan(4)
const ns = '_'
const client = {}
const code = 'function main() { // main function body};'
const action = {exec: {kind: 'swift', code: code}}
+ const kind = 'custom_runtime:version'
const actions = new Actions(client)
client.request = (method, path, options) => {
@@ -264,7 +283,7 @@
t.deepEqual(options.body, action)
}
- return actions.create({name: '12345', action})
+ return actions.create({name: '12345', kind, action})
})
test('create a new action with buffer body', t => {