-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #42 from assafmo/fix-bytesToNumber-to-return-uint
Fix `bytesToNumber()`
- Loading branch information
Showing
2 changed files
with
32 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters