Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jacogr committed Sep 11, 2019
1 parent f68c93f commit 34f8b40
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
19 changes: 19 additions & 0 deletions packages/util/src/hex/toString.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// 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 { hexToString } from '.';

describe('hexToString', (): void => {
it('converts an empty to ""', (): void => {
expect(
hexToString()
).toEqual('');
});

it('converts to a string from hex', (): void => {
expect(
hexToString('0x68656c6c6f')
).toEqual('hello');
});
});
19 changes: 19 additions & 0 deletions packages/util/src/string/toHex.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// 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 { stringToHex } from '.';

describe('hexToString', (): void => {
it('converts an empty to ""', (): void => {
expect(
stringToHex()
).toEqual('0x');
});

it('converts to a hex from string', (): void => {
expect(
stringToHex('hello')
).toEqual('0x68656c6c6f');
});
});

0 comments on commit 34f8b40

Please sign in to comment.