forked from mastodon/mastodon
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace to testing-library from enzyme (mastodon#14152)
- Loading branch information
Showing
5 changed files
with
159 additions
and
312 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
15 changes: 7 additions & 8 deletions
15
app/javascript/mastodon/features/ui/components/__tests__/column-test.js
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 |
---|---|---|
@@ -1,25 +1,24 @@ | ||
import { render, fireEvent, screen } from '@testing-library/react'; | ||
import React from 'react'; | ||
import { mount } from 'enzyme'; | ||
import Column from '../column'; | ||
import ColumnHeader from '../column_header'; | ||
|
||
describe('<Column />', () => { | ||
describe('<ColumnHeader /> click handler', () => { | ||
it('runs the scroll animation if the column contains scrollable content', () => { | ||
const wrapper = mount( | ||
const scrollToMock = jest.fn(); | ||
const { container } = render( | ||
<Column heading='notifications'> | ||
<div className='scrollable' /> | ||
</Column>, | ||
); | ||
const scrollToMock = jest.fn(); | ||
wrapper.find(Column).find('.scrollable').getDOMNode().scrollTo = scrollToMock; | ||
wrapper.find(ColumnHeader).find('button').simulate('click'); | ||
container.querySelector('.scrollable').scrollTo = scrollToMock; | ||
fireEvent.click(screen.getByText('notifications')); | ||
expect(scrollToMock).toHaveBeenCalledWith({ behavior: 'smooth', top: 0 }); | ||
}); | ||
|
||
it('does not try to scroll if there is no scrollable content', () => { | ||
const wrapper = mount(<Column heading='notifications' />); | ||
wrapper.find(ColumnHeader).find('button').simulate('click'); | ||
render(<Column heading='notifications' />); | ||
fireEvent.click(screen.getByText('notifications')); | ||
}); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -1,5 +1 @@ | ||
import { configure } from 'enzyme'; | ||
import Adapter from 'enzyme-adapter-react-16'; | ||
|
||
const adapter = new Adapter(); | ||
configure({ adapter }); | ||
import '@testing-library/jest-dom/extend-expect'; |
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
Oops, something went wrong.