Skip to content

Commit

Permalink
fix: missing optional parameter for emitted (#276)
Browse files Browse the repository at this point in the history
  • Loading branch information
thunderer199 committed Jul 16, 2022
1 parent 20ceb25 commit 6dd4847
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/__tests__/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,6 @@ test('Review form submits', async () => {

// Assert the right event has been emitted.
expect(emitted()).toHaveProperty('submit')
expect(emitted().submit[0][0]).toMatchObject(fakeReview)
expect(emitted('submit')[0][0]).toMatchObject(fakeReview)
expect(console.warn).not.toHaveBeenCalled()
})
2 changes: 1 addition & 1 deletion src/__tests__/user-event.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ test('User events in a form', async () => {
expect(submitButton).toHaveFocus()
expect(submitButton).toBeEnabled()
userEvent.type(submitButton, '{enter}')
expect(emitted().submit[0][0]).toMatchObject(fakeReview)
expect(emitted('submit')[0][0]).toMatchObject(fakeReview)

expect(console.warn).not.toHaveBeenCalled()
})
Expand Down
2 changes: 1 addition & 1 deletion src/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Check out the test examples on GitHub for further details.`)
: console.log(prettyDOM(el, maxLength, options)),
unmount: () => wrapper.unmount(),
html: () => wrapper.html(),
emitted: () => wrapper.emitted(),
emitted: name => wrapper.emitted(name),
rerender: props => wrapper.setProps(props),
...getQueriesForElement(baseElement),
}
Expand Down
1 change: 1 addition & 0 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export interface RenderResult extends BoundFunctions<typeof queries> {
unmount(): void
html(): string
emitted<T = unknown>(): Record<string, T[]>
emitted<T = unknown>(name?: string): T[]
rerender(props: object): Promise<void>
}

Expand Down
1 change: 1 addition & 0 deletions types/index.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ export function testOptions() {
export function testEmitted() {
const {emitted} = render(SomeComponent)
expectType<unknown[]>(emitted().foo)
expectType<unknown[]>(emitted('foo'))
}

/*
Expand Down

0 comments on commit 6dd4847

Please sign in to comment.