Skip to content

Commit

Permalink
Update for_each_pair.test.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
Mqxx committed Feb 13, 2024
1 parent 627cf03 commit 576993b
Showing 1 changed file with 74 additions and 24 deletions.
98 changes: 74 additions & 24 deletions src/array/for_each_pair.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,40 +7,90 @@ import forEachPair from "./for_each_pair.ts";

Deno.test(
'Call function for each pair.',
() => {
async (test) => {
function dummyFunction(
previousValue : number,
currentValue : number
) : void {}
currentValue : number,
currentIndex: number,
array: number[]
) : {
previousValue : number,
currentValue : number,
currentIndex: number,
array: number[]
} {
return {
previousValue,
currentValue,
currentIndex,
array
}
}

const dummyFunctionSpy = spy(dummyFunction);

forEachPair(
[0, 2, 3, 7],
[
0,
2,
3,
7
],
dummyFunctionSpy
)

assertSpyCall(dummyFunctionSpy, 0, {
args: [
0,
2
]
})

assertSpyCall(dummyFunctionSpy, 1, {
args: [
2,
3
]

await test.step({
name: 'Function call arguments.',
fn: () => {
assertSpyCall(dummyFunctionSpy, 0, {
args: [
0,
2,
1,
[
0,
2,
3,
7
]
]
})

assertSpyCall(dummyFunctionSpy, 1, {
args: [
2,
3,
2,
[
0,
2,
3,
7
]
]
})

assertSpyCall(dummyFunctionSpy, 2, {
args: [
3,
7,
3,
[
0,
2,
3,
7
]
]
})
}
})

assertSpyCall(dummyFunctionSpy, 2, {
args: [
3,
7
]
await test.step({
name: 'Function calls.',
fn: () => {
assertSpyCalls(dummyFunctionSpy, 3);
}
})

assertSpyCalls(dummyFunctionSpy, 3);
}
)

0 comments on commit 576993b

Please sign in to comment.