-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: keep order of arguments for .each in custom task collectors (#5640)
- Loading branch information
1 parent
959247e
commit 7d57c11
Showing
2 changed files
with
49 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { expect, test, vi } from 'vitest' | ||
import { createTaskCollector } from 'vitest/suite' | ||
|
||
test('collector keeps the order of arguments', () => { | ||
const fn = vi.fn() | ||
const collector = createTaskCollector(fn) | ||
const cb = vi.fn() | ||
const options = {} | ||
|
||
collector('a', cb, options) | ||
|
||
expect(fn).toHaveBeenNthCalledWith(1, 'a', cb, options) | ||
|
||
collector('a', options, cb) | ||
|
||
expect(fn).toHaveBeenNthCalledWith(2, 'a', options, cb) | ||
|
||
collector.each([1])('a', cb, options) | ||
|
||
expect(fn).toHaveBeenNthCalledWith(3, 'a', expect.any(Function), options) | ||
|
||
collector.each([1])('a', options, cb) | ||
|
||
expect(fn).toHaveBeenNthCalledWith(4, 'a', options, expect.any(Function)) | ||
}) |