Skip to content

Commit 1faf4db

Browse files
committed
Rename number-display -> update-props
1 parent 5d2a434 commit 1faf4db

File tree

2 files changed

+19
-15
lines changed

2 files changed

+19
-15
lines changed

tests/__tests__/number-display.js

Lines changed: 0 additions & 15 deletions
This file was deleted.

tests/__tests__/update-props.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import NumberDisplay from './components/NumberDisplay.vue'
2+
import { render } from '@testing-library/vue'
3+
import 'jest-dom/extend-expect'
4+
5+
test('calling render with the same component but different props does not remount', async () => {
6+
const { getByTestId, updateProps } = render(NumberDisplay, {
7+
props: { number: 1 }
8+
})
9+
10+
expect(getByTestId('number-display')).toHaveTextContent('1')
11+
12+
await updateProps({ number: 2 })
13+
14+
expect(getByTestId('number-display')).toHaveTextContent('2')
15+
16+
// Assert that, even after updating props, the component hasn't remounted,
17+
// meaning we are testing the same component instance we rendered initially.
18+
expect(getByTestId('instance-id')).toHaveTextContent('1')
19+
})

0 commit comments

Comments
 (0)