Skip to content

Commit

Permalink
fix: allow multiple calling of updateProps (#170)
Browse files Browse the repository at this point in the history
* Changed updateProps to return the Promise created from
wrapper.setProps.
* Updated the `updateProps` test to make sure the function can be called
multiple times without producing errors.
  • Loading branch information
ITenthusiasm committed Nov 15, 2020
1 parent dbcf740 commit 95cc445
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
4 changes: 3 additions & 1 deletion src/__tests__/update-props.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ test('calling render with the same component but different props does not remoun
expect(getByTestId('number-display')).toHaveTextContent('1')

await updateProps({number: 2})

expect(getByTestId('number-display')).toHaveTextContent('2')

await updateProps({number: 3})
expect(getByTestId('number-display')).toHaveTextContent('3')

// Assert that, even after updating props, the component hasn't remounted,
// meaning we are testing the same component instance we rendered initially.
expect(getByTestId('instance-id')).toHaveTextContent('1')
Expand Down
5 changes: 1 addition & 4 deletions src/vue-testing-library.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,7 @@ function render(
isUnmounted: () => wrapper.vm._isDestroyed,
html: () => wrapper.html(),
emitted: () => wrapper.emitted(),
updateProps: _ => {
wrapper.setProps(_)
return waitFor(() => {})
},
updateProps: _ => wrapper.setProps(_),
...getQueriesForElement(baseElement),
}
}
Expand Down

0 comments on commit 95cc445

Please sign in to comment.