UNPKG

octify

Version:

Base8 Encoder

23 lines (19 loc) 843 B
const {encode, decode} = require("../octify.js"); function expectDecodedToBe(input) { const encoded = encode(input); const decoded = decode(encoded); expect(decoded).toStrictEqual(input); } describe("objects", () => { test("empty", () => { expectDecodedToBe({}); }); test("one property", () => { expectDecodedToBe({test : "data"}); }); test("number object", () => { expectDecodedToBe({test : 0, test1 : 1, test2 : 2}); }); test("nested", () => { expectDecodedToBe({nested : {test : "data"}}); }); test("empty array", () => { expectDecodedToBe([]); }); test("string array", () => { expectDecodedToBe([ "one", "two", "three" ]); }); test("object array", () => { expectDecodedToBe([ {}, {test : "data"}, {nested : {test : "data"}} ]); }); test("number array", () => { expectDecodedToBe([ 1, 2, 3 ]); }); });