Skip to content

Commit

Permalink
add type tests
Browse files Browse the repository at this point in the history
  • Loading branch information
noamokman committed Dec 26, 2023
1 parent 711aae8 commit f672a42
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions index.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,33 @@ const sites = [
'https://github.com',
];

const sitesWithPromises = [
'https://sindresorhus.com',
Promise.resolve('https://avajs.dev'),
Promise.resolve('https://github.com'),
];

const sitesAsyncIterable = {
async * [Symbol.asyncIterator]() {
yield 'https://sindresorhus.com';
yield 'https://avajs.dev';
yield 'https://github.com';
},
};

const sitesAsyncIterableWithPromises: AsyncIterable<Promise<string>> = {
[Symbol.asyncIterator]() {
return {
async next() {
return {
done: false,
value: Promise.resolve('https://github.com'),
};
},
};
},
};

const numbers = [
0,
1,
Expand Down Expand Up @@ -50,3 +77,6 @@ expectType<Promise<number[]>>(pMap(numbers, (number: number) => {
}));

expectType<AsyncIterable<string>>(pMapIterable(sites, asyncMapper));
expectType<AsyncIterable<string>>(pMapIterable(sitesWithPromises, asyncMapper));
expectType<AsyncIterable<string>>(pMapIterable(sitesAsyncIterable, asyncMapper));
expectType<AsyncIterable<string>>(pMapIterable(sitesAsyncIterableWithPromises, asyncMapper));

0 comments on commit f672a42

Please sign in to comment.