Explorar o código

update editableOptions wrapper

d98762625 %!s(int64=7) %!d(string=hai) anos
pai
achega
c90f30a7a1
Modificáronse 2 ficheiros con 20 adicións e 0 borrados
  1. 3 0
      src/node/apiUtils.mjs
  2. 17 0
      test/tests/nodeApi/ops.mjs

+ 3 - 0
src/node/apiUtils.mjs

@@ -56,6 +56,9 @@ function transformArgs(originalArgs, newArgs) {
                 if (["toggleString"].indexOf(argument.type) > -1) {
                     argument.string = newArgs[key].string;
                     argument.option = newArgs[key].option;
+                } else if (argument.type === "editableOption") {
+                    // takes key: "option", key: {name, val: "string"}, key: {name, val: [...]}
+                    argument.value = typeof newArgs[key] === "string" ? newArgs[key]: newArgs[key].value;
                 } else {
                     argument.value = newArgs[key];
                 }

+ 17 - 0
test/tests/nodeApi/ops.mjs

@@ -27,6 +27,7 @@ import {
     bitShiftRight,
     cartesianProduct,
     CSSMinify,
+    toBase64,
 } from "../../../src/node/index";
 import TestRegister from "../../TestRegister";
 
@@ -115,6 +116,22 @@ color: white;
             preserveComments: true,
         });
         assert.strictEqual(result.toString(), "header {// comment width: 100%;color: white;}");
+    }),
+
+    it("toBase64: editableOption", () => {
+        const result = toBase64("some input", {
+            alphabet: {
+                value: "0-9A-W"
+            },
+        });
+        assert.strictEqual(result.toString(), "SPI1R1T0");
+    }),
+
+    it("toBase64: editableOptions key is value", () => {
+        const result = toBase64("some input", {
+            alphabet: "0-9A-W",
+        });
+        assert.strictEqual(result.toString(), "SPI1R1T0");
     })