-
-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathindex.test-d.ts
More file actions
17 lines (12 loc) · 636 Bytes
/
Copy pathindex.test-d.ts
File metadata and controls
17 lines (12 loc) · 636 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import {expectType} from 'tsd';
import pDebounce from './index.js';
const expensiveCall = async (input: number) => input;
// Test basic return type
expectType<(input: number) => Promise<number>>(pDebounce(expensiveCall, 200));
// Test with signal option
const controller = new AbortController();
expectType<(input: number) => Promise<number>>(pDebounce(expensiveCall, 200, {signal: controller.signal}));
// Test with before option
expectType<(input: number) => Promise<number>>(pDebounce(expensiveCall, 200, {before: true}));
// Test promise method
expectType<(input: number) => Promise<number>>(pDebounce.promise(expensiveCall));