Skip to content

Commit

Permalink
WIP add more dish translation tests
Browse files Browse the repository at this point in the history
  • Loading branch information
d98762625 committed Apr 29, 2019
1 parent aeb08ca commit a2d70d4
Showing 1 changed file with 46 additions and 4 deletions.
50 changes: 46 additions & 4 deletions tests/node/tests/NodeDish.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,50 @@ TestRegister.addApiTests([
assert.strictEqual(result.toString(), "493e8136b759370a415ef2cf2f7a69690441ff86592aba082bc2e2e0");
}),

// it("Dish translation: ArrayBuffer to ArrayBuffer", () => {
// const dish = new Dish();

// }),
it("Dish translation: ArrayBuffer to ArrayBuffer", () => {
const dish = new Dish(new ArrayBuffer(10), 4);
dish.get("array buffer");
assert.strictEqual(dish.value.byteLength, 10);
assert.strictEqual(dish.type, 4);
}),

it("Dish translation: ArrayBuffer and String", () => {
const dish = new Dish("some string", 1);
dish.get("array buffer");

assert.strictEqual(dish.type, 4);
assert.deepEqual(dish.value, new ArrayBuffer(11));
assert.deepEqual(dish.value.byteLength, 11);

dish.get("string");
assert.strictEqual(dish.type, 1);
assert.strictEqual(dish.value, "some string");
}),

it("Dish translation: ArrayBuffer and number", () => {
const dish = new Dish(100, 2);
dish.get(4);

assert.strictEqual(dish.type, 4);
assert.deepEqual(dish.value, new ArrayBuffer(10));
assert.strictEqual(dish.value.byteLength, 3);

// Check the data in ArrayBuffer represents 100
const view = new DataView(dish.value, 0);
assert.strictEqual(view.getInt8(0), 100);

dish.get("number");
assert.strictEqual(dish.type, 2);
assert.strictEqual(dish.value, 100);
}),

it("Dish translation: ArrayBuffer and byte array", () => {
const dish = new Dish(new Uint8Array([1, 2, 3]), 0);
dish.get(4);

const check = new Uint8Array(dish.value);
assert.deepEqual(check, [1, 2, 3]);


}),
]);

0 comments on commit a2d70d4

Please sign in to comment.