mirror of
https://github.com/pezkuwichain/pezkuwi-common.git
synced 2026-11-06 15:31:11 +00:00
Initial rebrand: @polkadot -> @pezkuwi (14 packages)
- Package namespace: @polkadot/* -> @pezkuwi/* - Repository: polkadot-js/common -> pezkuwichain/pezkuwi-common - Author: Pezkuwi Team <team@pezkuwichain.io> Core packages: - @pezkuwi/util (utilities) - @pezkuwi/util-crypto (crypto primitives) - @pezkuwi/keyring (account management) - @pezkuwi/networks (chain metadata) - @pezkuwi/hw-ledger (Ledger hardware wallet) - @pezkuwi/x-* (10 polyfill packages) Total: 14 packages Upstream: polkadot-js/common v14.0.1
This commit is contained in:
commit
ec06da0ebc
687 files changed
+48096
No files matched your search
@@ -0,0 +1,50 @@
|
||||
// Copyright 2017-2025 @polkadot/util authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
/// <reference types="@polkadot/dev-test/globals.d.ts" />
|
||||
|
||||
import { promisify } from './index.js';
|
||||
|
||||
describe('promisify', (): void => {
|
||||
it('handles functions with no parameters (resolve)', (): Promise<void> => {
|
||||
const fn = (cb: (error: null, value: [boolean, string, number]) => void): void =>
|
||||
cb(null, [true, 'test', 1]);
|
||||
|
||||
return promisify(null, fn).then((result): void => {
|
||||
expect(result).toEqual([true, 'test', 1]);
|
||||
});
|
||||
});
|
||||
|
||||
it('handles functions with no parameters (reject)', (): Promise<void> => {
|
||||
const fn = (cb: (error: Error, result?: boolean) => void): void =>
|
||||
cb(new Error('test reject'));
|
||||
|
||||
return promisify(null, fn)
|
||||
.then((): void => {
|
||||
throw new Error('Received unexpected result');
|
||||
})
|
||||
.catch((error: Error): void => {
|
||||
// eslint-disable-next-line jest/no-conditional-expect
|
||||
expect(error.message).toEqual('test reject');
|
||||
});
|
||||
});
|
||||
|
||||
it('handles functions with parameters (resolve)', (): Promise<void> => {
|
||||
const fn = (a: number, b: boolean, cb: (error: Error | null, result?: [number, boolean]) => void): void =>
|
||||
cb(null, [a, b]);
|
||||
|
||||
return promisify(null, fn, 2, false).then((result: [number, boolean]): void => {
|
||||
expect(result).toEqual([2, false]);
|
||||
});
|
||||
});
|
||||
|
||||
it('handles functions with parameters (reject)', (): Promise<void> => {
|
||||
const fn = (a: number, b: boolean, c: string, cb: (error: Error | null, result?: [number, boolean, string]) => void): void =>
|
||||
cb(new Error(`test reject: ${a},${b.toString()},${c}`));
|
||||
|
||||
return promisify(null, fn, 3, 'string', true).catch((error: Error): void => {
|
||||
// eslint-disable-next-line jest/no-conditional-expect
|
||||
expect(error.message).toEqual('test reject: 3,string,true');
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user