univ-conv
Version:
The universal binary and text converter
70 lines • 2.52 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const UnivConv_1 = require("../UnivConv");
const Environment_1 = require("../converters/Environment");
const head = "大谷翔平";
const tail = "ホームラン";
const expected = "大谷翔平ホームラン";
let c;
it("initialize", async () => {
c = (await (0, UnivConv_1.getUnivConv)());
});
it("arraybuffer", async () => {
const chunk1 = await c._of("arraybuffer").from(head);
const chunk2 = await c._of("arraybuffer").from(tail);
const chunks = [chunk1, chunk2];
const merged = await c.merge("text", chunks);
expect(expected).toBe(merged);
});
it("uint8array", async () => {
const chunk1 = await c._of("uint8array").from(head);
const chunk2 = await c._of("uint8array").from(tail);
const chunks = [chunk1, chunk2];
const merged = await c.merge("text", chunks);
expect(expected).toBe(merged);
});
it("blob", async () => {
if (!Environment_1.hasBlob) {
return;
}
const chunk1 = await c._of("blob").from(head);
const chunk2 = await c._of("blob").from(tail);
const chunks = [chunk1, chunk2];
const merged = await c.merge("text", chunks);
expect(expected).toBe(merged);
});
it("base64", async () => {
const chunk1 = await c._of("base64").from(head);
const chunk2 = await c._of("base64").from(tail);
const chunks = [chunk1, chunk2];
const merged = await c.merge("text", chunks, { inputStringType: "base64" });
expect(expected).toBe(merged);
});
it("binary", async () => {
const chunk1 = await c._of("binary").from(head);
const chunk2 = await c._of("binary").from(tail);
const chunks = [chunk1, chunk2];
const merged = await c.merge("text", chunks, { inputStringType: "binary" });
expect(expected).toBe(merged);
});
it("readable", async () => {
if (!Environment_1.hasReadable) {
return;
}
const chunk1 = await c._of("readable").from(head);
const chunk2 = await c._of("readable").from(tail);
const chunks = [chunk1, chunk2];
const merged = await c.merge("text", chunks);
expect(expected).toBe(merged);
});
it("readablestream", async () => {
if (!Environment_1.hasReadableStream) {
return;
}
const chunk1 = await c._of("readablestream").from(head);
const chunk2 = await c._of("readablestream").from(tail);
const chunks = [chunk1, chunk2];
const merged = await c.merge("text", chunks);
expect(expected).toBe(merged);
});
//# sourceMappingURL=common.spec.js.map