Merge e59f0907f458d47310b93da4529112b0463f8fc6 into 4290ea753912378913b1f3f54e0fc5720afeda5d
This commit is contained in:
commit
a04691bc20
@ -37,17 +37,18 @@ class Dish {
|
||||
constructor(dishOrInput=null, type = null) {
|
||||
this.value = new ArrayBuffer(0);
|
||||
this.type = Dish.ARRAY_BUFFER;
|
||||
const hasInput = dishOrInput !== undefined && dishOrInput !== null;
|
||||
|
||||
// Case: dishOrInput is dish object
|
||||
if (dishOrInput &&
|
||||
if (hasInput &&
|
||||
Object.prototype.hasOwnProperty.call(dishOrInput, "value") &&
|
||||
Object.prototype.hasOwnProperty.call(dishOrInput, "type")) {
|
||||
this.set(dishOrInput.value, dishOrInput.type);
|
||||
// input and type defined separately
|
||||
} else if (dishOrInput && type !== null) {
|
||||
} else if (hasInput && type !== null) {
|
||||
this.set(dishOrInput, type);
|
||||
// No type declared, so infer it.
|
||||
} else if (dishOrInput) {
|
||||
} else if (hasInput) {
|
||||
const inferredType = Dish.typeEnum(dishOrInput.constructor.name);
|
||||
this.set(dishOrInput, inferredType);
|
||||
}
|
||||
|
||||
@ -102,7 +102,7 @@ function transformArgs(opArgsList, newArgs) {
|
||||
* @param input
|
||||
*/
|
||||
function ensureIsDish(input) {
|
||||
if (!input) {
|
||||
if (input === undefined || input === null) {
|
||||
return new NodeDish();
|
||||
}
|
||||
|
||||
|
||||
@ -38,6 +38,9 @@ TestRegister.addApiTests([
|
||||
const numberDish = new Dish(333);
|
||||
assert.strictEqual(numberDish.type, 2);
|
||||
|
||||
const zeroDish = new Dish(0);
|
||||
assert.strictEqual(zeroDish.type, 2);
|
||||
|
||||
const arrayBufferDish = new Dish(Buffer.from("some buffer input").buffer);
|
||||
assert.strictEqual(arrayBufferDish.type, 4);
|
||||
|
||||
|
||||
@ -97,6 +97,11 @@ TestRegister.addApiTests([
|
||||
assert(result instanceof NodeDish);
|
||||
}),
|
||||
|
||||
it("should process numeric zero input", () => {
|
||||
const result = chef.toHex(0);
|
||||
assert.strictEqual(result.toString(), "30");
|
||||
}),
|
||||
|
||||
it("should coerce to a string as you expect", () => {
|
||||
const result = chef.fromBase32(chef.toBase32("something"));
|
||||
assert.equal(String(result), "something");
|
||||
@ -212,6 +217,11 @@ TestRegister.addApiTests([
|
||||
assert.strictEqual(result.toString(), "ONXW2ZJANFXHA5LU");
|
||||
}),
|
||||
|
||||
it("chef.bake: should process numeric zero input", async () => {
|
||||
const result = await chef.bake(0, "to hex");
|
||||
assert.strictEqual(result.toString(), "30");
|
||||
}),
|
||||
|
||||
it("chef.bake: should complain if recipe isnt a valid object", async () => {
|
||||
await assert.rejects(() => chef.bake("some input", 3264), {
|
||||
name: "TypeError",
|
||||
|
||||
@ -59,6 +59,13 @@ TestRegister.addApiTests([
|
||||
assert.strictEqual(result.toString(), "7");
|
||||
}),
|
||||
|
||||
it("ADD: processes numeric zero input", () => {
|
||||
const result = chef.ADD(0, {
|
||||
key: "4",
|
||||
});
|
||||
assert.strictEqual(result.toString(), "4");
|
||||
}),
|
||||
|
||||
it("addLineNumbers: No arguments", () => {
|
||||
const result = addLineNumbers("sample input");
|
||||
assert.equal(result.toString(), "1 sample input");
|
||||
@ -1203,4 +1210,3 @@ ExifImageHeight: 57`);
|
||||
|
||||
|
||||
]);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user