Skip to content

Commit

Permalink
test() add test for utils
Browse files Browse the repository at this point in the history
  • Loading branch information
immortal-tofu committed Nov 10, 2023
1 parent 39c0237 commit 35dc65d
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/utils.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { numberToBytes, bytesToNumber } from './utils';

describe('decrypt', () => {
it('converts a number to bytes', async () => {
const value = 28482;
const bytes = numberToBytes(value);
expect(bytes).toEqual(new Uint8Array([111, 66]));

const value2 = 255;
const bytes2 = numberToBytes(value2);
expect(bytes2).toEqual(new Uint8Array([255]));
});

it('converts bytes to number', async () => {
const value = new Uint8Array([23, 200, 15]);
const bytes = bytesToNumber(value);
expect(bytes).toBe(1558543);

const value2 = new Uint8Array();
const bytes2 = bytesToNumber(value2);
expect(bytes2).toBe(0);
});
});

0 comments on commit 35dc65d

Please sign in to comment.