add all options to argOptions. Add some extra test case for Zip
This commit is contained in:
parent
a1b116d2f5
commit
b48a55bd74
@ -141,9 +141,21 @@ function createArgOptions(op) {
|
||||
const result = {};
|
||||
op.args.forEach((a) => {
|
||||
if (a.type === "option" || a.type === "editableOption") {
|
||||
result[sentenceToCamelCase(a.name)] = removeSubheadingsFromArray(a.value);
|
||||
result[sentenceToCamelCase(a.name)] = {
|
||||
type: a.type,
|
||||
options: removeSubheadingsFromArray(a.value)
|
||||
};
|
||||
} else if (a.type === "toggleString") {
|
||||
result[sentenceToCamelCase(a.name)] = removeSubheadingsFromArray(a.toggleValues);
|
||||
result[sentenceToCamelCase(a.name)] = {
|
||||
type: a.type,
|
||||
value: a.value,
|
||||
toggleValues: removeSubheadingsFromArray(a.toggleValues),
|
||||
};
|
||||
} else {
|
||||
result[sentenceToCamelCase(a.name)] = {
|
||||
type: a.type,
|
||||
value: a.value,
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -398,22 +398,33 @@ TestRegister.addApiTests([
|
||||
|
||||
it("Operation arguments: should be accessible from operation object if op has array arg", () => {
|
||||
assert.ok(chef.toCharcode.argOptions);
|
||||
assert.deepEqual(chef.unzip.argOptions, {});
|
||||
assert.deepEqual(chef.unzip.argOptions, {
|
||||
password: {
|
||||
type: "binaryString",
|
||||
value: "",
|
||||
},
|
||||
verifyResult: {
|
||||
type: "boolean",
|
||||
value: false,
|
||||
}
|
||||
});
|
||||
}),
|
||||
|
||||
it("Operation arguments: should have key for each array-based argument in operation", () => {
|
||||
it("Operation arguments: should have key for each argument in operation", () => {
|
||||
assert.ok(chef.convertDistance.argOptions.inputUnits);
|
||||
assert.ok(chef.convertDistance.argOptions.outputUnits);
|
||||
|
||||
assert.ok(chef.bitShiftRight.argOptions.type);
|
||||
// is a number type, so not included.
|
||||
assert.equal(chef.bitShiftRight.argOptions.amount, undefined);
|
||||
assert.strictEqual(chef.bitShiftRight.argOptions.amount.type, "number");
|
||||
assert.strictEqual(chef.bitShiftRight.argOptions.amount.value, 1);
|
||||
assert.strictEqual(chef.bitShiftRight.argOptions.type.type, "option");
|
||||
assert.ok(Array.isArray(chef.bitShiftRight.argOptions.type.options));
|
||||
|
||||
}),
|
||||
|
||||
it("Operation arguments: should list all options excluding subheadings", () => {
|
||||
// First element (subheading) removed
|
||||
assert.equal(chef.convertDistance.argOptions.inputUnits[0], "Nanometres (nm)");
|
||||
assert.equal(chef.defangURL.argOptions.process[1], "Only full URLs");
|
||||
assert.equal(chef.convertDistance.argOptions.inputUnits.options[0], "Nanometres (nm)");
|
||||
assert.equal(chef.defangURL.argOptions.process.options[1], "Only full URLs");
|
||||
})
|
||||
|
||||
]);
|
||||
|
@ -1002,8 +1002,8 @@ ExifImageHeight: 57`);
|
||||
});
|
||||
|
||||
assert.strictEqual(zipped.type, 7);
|
||||
assert.equal(zipped.value.data.toString().indexOf("sample.zip"), 30);
|
||||
assert.equal(zipped.value.data.toString().indexOf("added"), 122);
|
||||
assert.ok(zipped.value.data.toString().includes("sample.zip"));
|
||||
assert.ok(zipped.value.data.toString().includes("added"));
|
||||
}),
|
||||
|
||||
it("Unzip", () => {
|
||||
@ -1018,5 +1018,16 @@ ExifImageHeight: 57`);
|
||||
assert.equal(unzipped.value[0].name, "zipped.zip");
|
||||
}),
|
||||
|
||||
it("Unzip with password", () => {
|
||||
const zipped = chef.zip("some content", {
|
||||
password: "abcd",
|
||||
});
|
||||
const unzipped = chef.unzip(zipped, {
|
||||
password: "abcd",
|
||||
});
|
||||
|
||||
assert.equal(unzipped.value[0].data, "some content");
|
||||
}),
|
||||
|
||||
]);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user