Skip to content

Commit

Permalink
fix /tojson tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanbilan-i25s committed Feb 8, 2024
1 parent 2ec151c commit fdf53db
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
17 changes: 9 additions & 8 deletions __tests__/e2e/convert.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,22 @@ const CONVERT_URL = `http://localhost:${server.port}/hibonutil/convert`;
describe("Test /convert/tohibon endpoint", () => {
const CONVERT_TOHIBON_URL = CONVERT_URL + "/tohibon";

it.skip("should return correct data in default format", async () => {
const response = await axios.post(CONVERT_TOHIBON_URL, res.sampleJSON);
it("should return correct data in default format", async () => {
const response = await axios.post(CONVERT_TOHIBON_URL, res.sampleJSON, {
responseType: "arraybuffer",
});
expect(response.status).toBe(200);
const responseBodyHex = Buffer.from(response.data).toString("hex");
expect(responseBodyHex).toBe(res.sampleHiBONHex);
expect(Buffer.from(response.data)).toEqual(res.sampleHiBONBuffer);
});

it.skip("should return correct data in octet-stream format", async () => {
it("should return correct data in octet-stream format", async () => {
const response = await axios.post(
CONVERT_TOHIBON_URL + "?format=octet-stream",
res.sampleJSON
res.sampleJSON,
{ responseType: "arraybuffer" }
);
expect(response.status).toBe(200);
const responseBodyHex = Buffer.from(response.data).toString("hex");
expect(responseBodyHex).toBe(res.sampleHiBONHex);
expect(Buffer.from(response.data)).toEqual(res.sampleHiBONBuffer);
});

it("should return correct data in base64 format", async () => {
Expand Down
11 changes: 4 additions & 7 deletions __tests__/res/convertTestData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,10 @@ export const sampleJSON = {
},
};

export const sampleHiBONRaw =
"\x95\x01\x1A\x06BIGINT\x99è\x82ú\x88\x87¯¤àøó\x90µ\x87Y\b\x07BOOLEAN\x01\x17\x07FLOAT32¤p\x9D?\x18\x07FLOAT64Æ\x85âoÙµyi\x11\x05INT32V\x12\x05INT64ÚÚáò£²ç}\x14\x06UINT32*\x15\x06UINT64¦¥\x9E\x8DÜÍ\x98\x02\x02\tsub_hibon\x1A\x03\x06BINARY\x04\x01\x02\x03\x04\x01\x06STRING\x04Text";

export const sampleHiBONBuffer = Buffer.from(sampleHiBONRaw, "binary");

export const sampleHiBONHex =
"95011a06424947494e5499e882fa8887afa4e0f8f390b587590807424f4f4c45414e011707464c4f41543332a4709d3f1807464c4f41543634c685e26fd9b579691105494e543332561205494e543634dadae1f2a3b2e77d140655494e5433322a150655494e543634a6a59e8ddccd980202097375625f6869626f6e1a030642494e41525904010203040106535452494e470454657874";
export const sampleHiBONBuffer = Buffer.from(
"\x95\x01\x1A\x06BIGINT\x99è\x82ú\x88\x87¯¤àøó\x90µ\x87Y\b\x07BOOLEAN\x01\x17\x07FLOAT32¤p\x9D?\x18\x07FLOAT64Æ\x85âoÙµyi\x11\x05INT32V\x12\x05INT64ÚÚáò£²ç}\x14\x06UINT32*\x15\x06UINT64¦¥\x9E\x8DÜÍ\x98\x02\x02\tsub_hibon\x1A\x03\x06BINARY\x04\x01\x02\x03\x04\x01\x06STRING\x04Text",
"binary"
);

export const sampleHiBONBase64 =
"@lQEaBkJJR0lOVJnogvqIh6-k4PjzkLWHWQgHQk9PTEVBTgEXB0ZMT0FUMzKkcJ0_GAdGTE9BVDY0xoXib9m1eWkRBUlOVDMyVhIFSU5UNjTa2uHyo7LnfRQGVUlOVDMyKhUGVUlOVDY0pqWejdzNmAICCXN1Yl9oaWJvbhoDBkJJTkFSWQQBAgMEAQZTVFJJTkcEVGV4dA==";
Expand Down

0 comments on commit fdf53db

Please sign in to comment.