-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8314 from marmelab/fix-rti-value-update
Fix `RichTextInput` doesn't update when record field updates
- Loading branch information
Showing
2 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import * as React from 'react'; | ||
import expect from 'expect'; | ||
import { render, waitFor } from '@testing-library/react'; | ||
import { Basic } from './RichTextInput.stories'; | ||
|
||
describe('<RichTextInput />', () => { | ||
it('should update its content when fields value changes', async () => { | ||
const record = { id: 123, body: '<h1>Hello world!</h1>' }; | ||
const { container, rerender } = render(<Basic record={record} />); | ||
|
||
await waitFor(() => { | ||
expect(container.querySelector('#body').innerHTML).toEqual( | ||
'<h1>Hello world!</h1>' | ||
); | ||
}); | ||
|
||
const newRecord = { id: 123, body: '<h1>Goodbye world!</h1>' }; | ||
rerender(<Basic record={newRecord} />); | ||
|
||
await waitFor(() => { | ||
expect(container.querySelector('#body').innerHTML).toEqual( | ||
'<h1>Goodbye world!</h1>' | ||
); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters