32 lines
808 B
TypeScript
32 lines
808 B
TypeScript
// Copyright 2017-2021 @polkadot/util authors & contributors
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
import { hexHasPrefix } from '.';
|
|
|
|
describe('hexHasPrefix', (): void => {
|
|
it('returns true when hex prefix is found', (): void => {
|
|
expect(
|
|
hexHasPrefix('0x123')
|
|
).toEqual(true);
|
|
});
|
|
|
|
it('returns false when no prefix attached', (): void => {
|
|
expect(
|
|
hexHasPrefix('123')
|
|
).toEqual(false);
|
|
});
|
|
|
|
it('returns false when null value supplied', (): void => {
|
|
expect(
|
|
hexHasPrefix(null)
|
|
).toEqual(false);
|
|
});
|
|
|
|
it('returns false when non-string value supplied', (): void => {
|
|
expect(
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any,@typescript-eslint/no-unsafe-argument
|
|
hexHasPrefix(false as any)
|
|
).toEqual(false);
|
|
});
|
|
});
|