Converts tests to TypeScript (#300)

This commit is contained in:
Jaco Greeff
2019-02-14 10:48:08 +01:00
committed by GitHub
parent 2a14a8b553
commit 1e6eb2c283
158 changed files with 89 additions and 183 deletions
-1
View File
@@ -6,7 +6,6 @@ import u8aToU8a from './toU8a';
/**
* @name u8aConcat
* @signature u8aConcat (...values: Array<Uint8Array | string>): Uint8Array
* @summary Creates a concatenated Uint8Array from the inputs.
* @description
* Concatenates the input arrays into a single `UInt8Array`.
-1
View File
@@ -4,7 +4,6 @@
/**
* @name u8aFixLength
* @signature u8aFixLength (value: string, bitLength: number = -1, withPadding: boolean = false): string
* @summary Shifts a Uint8Array to a specific bitLength
* @description
* Returns a uint8Array with the specified number of bits contained in the return value. (If bitLength is -1, length checking is not done). Values with more bits are trimmed to the specified length.
-1
View File
@@ -10,7 +10,6 @@ import { ToBnOptions } from '../types';
/**
* @name u8aToBn
* @signature u8aToHex (value?: Uint8Array, options: ToBnOptions | boolean = { isLe: true, isNegative: false }): BN
* @summary Creates a BN from a Uint8Array object.
* @description
* `UInt8Array` input values return the actual BN. `null` or `undefined` values returns an `0x0` value.
+1 -2
View File
@@ -4,7 +4,6 @@
/**
* @name u8aToBuffer
* @signature u8aToBuffer (value?: UInt8Array): Buffer
* @summary Creates a Buffer object from a hex string.
* @description
* `null` inputs returns an empty `Buffer` result. `UInt8Array` input values return the actual bytes value converted to a `Buffer`. Anything that is not a `UInt8Array` throws an error.
@@ -17,7 +16,7 @@
* console.log('Buffer', u8aToBuffer('0x123480001f'));
* ```
*/
export default function u8aToBuffer (value?: Uint8Array): Buffer {
export default function u8aToBuffer (value?: Uint8Array | null): Buffer {
if (!value) {
return Buffer.from([]);
}
@@ -13,7 +13,7 @@ describe('u8aToHex', () => {
it('returns empty as "" (unprefixed)', () => {
expect(
u8aToHex('', -1, false)
u8aToHex(null, -1, false)
).toEqual('');
});
@@ -45,7 +45,7 @@ describe('u8aToHex', () => {
it('returns the hex value where allowed < max', () => {
expect(
u8aToHex(
new Uint8Array([128, 0, 10, 11], 64)
new Uint8Array(Uint8Array.from([128, 0, 10, 11]), 64)
)
).toEqual('0x80000a0b');
});
-1
View File
@@ -6,7 +6,6 @@ const ALPHABET = '0123456789abcdef';
/**
* @name u8aToHex
* @signature u8aToHex (value?: UInt8Array): string
* @summary Creates a hex string from a Uint8Array object.
* @description
* `UInt8Array` input values return the actual hex string. `null` or `undefined` values returns an `0x` string.
+1 -2
View File
@@ -20,7 +20,6 @@ try {
/**
* @name u8aToString
* @signature u8aToString (value?: UInt8Array): string
* @summary Creates a utf-8 string from a Uint8Array object.
* @description
* `UInt8Array` input values return the actual decoded utf-8 string. `null` or `undefined` values returns an empty string.
@@ -33,7 +32,7 @@ try {
* u8aToString(new Uint8Array([0x68, 0x65, 0x6c, 0x6c, 0x6f])); // hello
* ```
*/
export default function u8aToString (value?: Uint8Array): string {
export default function u8aToString (value?: Uint8Array | null): string {
if (!value || !value.length) {
return '';
}
-1
View File
@@ -11,7 +11,6 @@ import stringToU8a from '../string/toU8a';
/**
* @name u8aToU8a
* @signature u8aToU8a (value?: Array<number> | Buffer | Uint8Array | string | null): Uint8Array
* @summary Creates a Uint8Array value from a Uint8Array bignumber or hex input.
* @description
* `null` inputs returns a `[]` result, Uint8Array values returns the value, hex strings returns a Uint8Array representation.