|
1 | 1 | import hex from "hex";
|
2 | 2 |
|
3 |
| -it("should encode/decode text", () => { |
4 |
| - let hello = "hello"; |
5 |
| - const encoded = new TextEncoder().encode(hello); |
6 |
| - const decoded = new TextDecoder().decode(encoded); |
| 3 | +describe("hex", () => { |
| 4 | + it("should encode/decode text", () => { |
| 5 | + let hello = "hello"; |
| 6 | + const encoded = new TextEncoder().encode(hello); |
| 7 | + const decoded = new TextDecoder().decode(encoded); |
7 | 8 |
|
8 |
| - assert.equal(decoded, hello); |
9 |
| -}); |
| 9 | + assert.equal(decoded, hello); |
| 10 | + }); |
| 11 | + |
| 12 | + it("should encode/decode hex", () => { |
| 13 | + const byteArray = new TextEncoder().encode("hello"); |
| 14 | + const encoded = hex.encode(byteArray); |
10 | 15 |
|
11 |
| -it("should encode/decode hex", () => { |
12 |
| - const byteArray = new TextEncoder().encode("hello"); |
13 |
| - const encoded = hex.encode(byteArray); |
| 16 | + assert.equal(encoded, "68656c6c6f"); |
| 17 | + }); |
| 18 | +}); |
14 | 19 |
|
15 |
| - assert.equal(encoded, "68656c6c6f"); |
| 20 | +describe("atoa & btoa", () => { |
| 21 | + it("btoa/atob", () => { |
| 22 | + const text = "Hello, world!"; |
| 23 | + const encodedData = btoa(text); |
| 24 | + assert.equal(encodedData, "SGVsbG8sIHdvcmxkIQ=="); |
| 25 | + const decodedData = atob(encodedData); |
| 26 | + assert.equal(decodedData, text); |
| 27 | + }); |
16 | 28 | });
|
0 commit comments