mirror of
https://github.com/pezkuwichain/pezkuwi-common.git
synced 2026-10-26 13:09:48 +00:00
The header rule takes the current year as the end of the range, as upstream's does; 581 sources still ended at 2025, which failed lint. Lint never ran to completion here, so this went unseen. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
51 lines
1.8 KiB
TypeScript
51 lines
1.8 KiB
TypeScript
// Copyright 2017-2026 @pezkuwi/util authors & contributors
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
/// <reference types="@pezkuwi/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');
|
|
});
|
|
});
|
|
});
|