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
+43
View File
@@ -0,0 +1,43 @@
// Copyright 2017-2019 @polkadot/util authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { hexFixLength } from './index';
describe('hexFixLength', () => {
it('returns bitLength === -1 as-is', () => {
expect(
hexFixLength('0x12345678')
).toEqual('0x12345678');
});
it('returns bitLength === -1 as-is (adding missing 0)', () => {
expect(
hexFixLength('0x1234567')
).toEqual('0x01234567');
});
it('does not change when bitlength === length', () => {
expect(
hexFixLength('0x12345678', 32)
).toEqual('0x12345678');
});
it('trims values when bitLength > length', () => {
expect(
hexFixLength('0x12345678', 16)
).toEqual('0x5678');
});
it('returns as-is when bitLength < length', () => {
expect(
hexFixLength('0x1234', 32)
).toEqual('0x1234');
});
it('adds zeros when bitLength < length (withPadded)', () => {
expect(
hexFixLength('0x1234', 32, true)
).toEqual('0x00001234');
});
});