From 2ff7b5902c52d6aeda3b1070180054885c1f0943 Mon Sep 17 00:00:00 2001 From: d98762625 Date: Mon, 25 Jun 2018 11:38:05 +0100 Subject: [PATCH] fix args transformation for ops with editableOptions --- src/node/apiUtils.mjs | 7 +++++-- test/tests/nodeApi/ops.mjs | 3 +-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/node/apiUtils.mjs b/src/node/apiUtils.mjs index 7be5e5b3..63107d51 100644 --- a/src/node/apiUtils.mjs +++ b/src/node/apiUtils.mjs @@ -13,11 +13,15 @@ import SyncDish from "./SyncDish"; * @param {Object} arg - an arg from an operation */ function extractArg(arg) { - if (arg.type === "option" || arg.type === "editableOption") { + if (arg.type === "option") { // pick default option if not already chosen return typeof arg.value === "string" ? arg.value : arg.value[0]; } + if (arg.type === "editableOption") { + return typeof arg.value === "string" ? arg.value : arg.value[0].value; + } + if (arg.type === "toggleString") { // ensure string and option exist when user hasn't defined arg.string = arg.string || ""; @@ -96,7 +100,6 @@ export function wrap(OpClass) { const type = SyncDish.typeEnum(input.constructor.name); dish.set(input, type); } - args = transformArgs(operation.args, args); const transformedInput = dish.get(operation.inputType); const result = operation.run(transformedInput, args); diff --git a/test/tests/nodeApi/ops.mjs b/test/tests/nodeApi/ops.mjs index 553cbb5b..95648a0e 100644 --- a/test/tests/nodeApi/ops.mjs +++ b/test/tests/nodeApi/ops.mjs @@ -132,8 +132,7 @@ color: white; alphabet: "0-9A-W", }); assert.strictEqual(result.toString(), "SPI1R1T0"); - }) - + }), ]);