Skip to content

fix: add missed optional prop for emmited function #276

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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