Skip to content

Commit 6dd4847

Browse files
authored
fix: missing optional parameter for emitted (#276)
1 parent 20ceb25 commit 6dd4847

File tree

5 files changed

+5
-3
lines changed

5 files changed

+5
-3
lines changed

src/__tests__/form.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,6 @@ test('Review form submits', async () => {
6262

6363
// Assert the right event has been emitted.
6464
expect(emitted()).toHaveProperty('submit')
65-
expect(emitted().submit[0][0]).toMatchObject(fakeReview)
65+
expect(emitted('submit')[0][0]).toMatchObject(fakeReview)
6666
expect(console.warn).not.toHaveBeenCalled()
6767
})

src/__tests__/user-event.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ test('User events in a form', async () => {
5353
expect(submitButton).toHaveFocus()
5454
expect(submitButton).toBeEnabled()
5555
userEvent.type(submitButton, '{enter}')
56-
expect(emitted().submit[0][0]).toMatchObject(fakeReview)
56+
expect(emitted('submit')[0][0]).toMatchObject(fakeReview)
5757

5858
expect(console.warn).not.toHaveBeenCalled()
5959
})

src/render.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ Check out the test examples on GitHub for further details.`)
4545
: console.log(prettyDOM(el, maxLength, options)),
4646
unmount: () => wrapper.unmount(),
4747
html: () => wrapper.html(),
48-
emitted: () => wrapper.emitted(),
48+
emitted: name => wrapper.emitted(name),
4949
rerender: props => wrapper.setProps(props),
5050
...getQueriesForElement(baseElement),
5151
}

types/index.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export interface RenderResult extends BoundFunctions<typeof queries> {
2424
unmount(): void
2525
html(): string
2626
emitted<T = unknown>(): Record<string, T[]>
27+
emitted<T = unknown>(name?: string): T[]
2728
rerender(props: object): Promise<void>
2829
}
2930

types/index.test-d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ export function testOptions() {
8686
export function testEmitted() {
8787
const {emitted} = render(SomeComponent)
8888
expectType<unknown[]>(emitted().foo)
89+
expectType<unknown[]>(emitted('foo'))
8990
}
9091

9192
/*

0 commit comments

Comments
 (0)