Skip to content

Commit

Permalink
cover async fn mock
Browse files Browse the repository at this point in the history
  • Loading branch information
darky committed Dec 30, 2024
1 parent bd1d2d4 commit 5c106ab
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,33 @@ test('8 params sync, mock via fn', async () => {
)
})

test('8 params sync, mock via async fn', async () => {
const fn = klubok(
pure('incNumber', (ctx: { number: number }) => ctx.number + 1),
pure('strNumber', ({ incNumber }) => incNumber.toString()),
pure('strLength', ({ strNumber }) => strNumber.length),
pure('strLengthPositive', ({ strLength }) => strLength > 0),
pure('sum', ({ strLength, incNumber }) => strLength + incNumber),
pure('numbersArray', ({ number, incNumber, strLength, sum }) => [number, incNumber, strLength, sum]),
pure('arrLength', ({ numbersArray }) => numbersArray.length),
pure('isMocked', ({ numbersArray }) => numbersArray.length === 0)
)
assert.deepStrictEqual(
await fn({ number: 1 }, { numbersArray: async ({ strNumber }) => (assert.strictEqual(strNumber, '2'), []) }),
{
number: 1,
incNumber: 2,
strNumber: '2',
strLength: 1,
strLengthPositive: true,
sum: 3,
numbersArray: [],
arrLength: 0,
isMocked: true,
}
)
})

test('9 params sync, only', async () => {
const fn = klubok(
pure('incNumber', (ctx: { number: number }) => ctx.number + 1),
Expand Down

0 comments on commit 5c106ab

Please sign in to comment.