diff options
author | Yamagishi Kazutoshi <ykzts@desire.sh> | 2020-06-29 20:58:07 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-29 13:58:07 +0200 |
commit | 5e8f51b29fccfb7d19d53854f3472f7370593ebf (patch) | |
tree | b075c743ca0c725bb8dda37c8d02122e0f11d571 /app/javascript/mastodon/components | |
parent | d1c6dd2d277fee0cf65b480adc868c69df952622 (diff) |
Replace to testing-library from enzyme (#14152)
Diffstat (limited to 'app/javascript/mastodon/components')
-rw-r--r-- | app/javascript/mastodon/components/__tests__/button-test.js | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/app/javascript/mastodon/components/__tests__/button-test.js b/app/javascript/mastodon/components/__tests__/button-test.js index 160cd3cbc..f5a649f70 100644 --- a/app/javascript/mastodon/components/__tests__/button-test.js +++ b/app/javascript/mastodon/components/__tests__/button-test.js @@ -1,4 +1,4 @@ -import { shallow } from 'enzyme'; +import { render, fireEvent, screen } from '@testing-library/react'; import React from 'react'; import renderer from 'react-test-renderer'; import Button from '../button'; @@ -21,16 +21,16 @@ describe('<Button />', () => { it('handles click events using the given handler', () => { const handler = jest.fn(); - const button = shallow(<Button onClick={handler} />); - button.find('button').simulate('click'); + render(<Button onClick={handler}>button</Button>); + fireEvent.click(screen.getByText('button')); expect(handler.mock.calls.length).toEqual(1); }); it('does not handle click events if props.disabled given', () => { const handler = jest.fn(); - const button = shallow(<Button onClick={handler} disabled />); - button.find('button').simulate('click'); + render(<Button onClick={handler} disabled>button</Button>); + fireEvent.click(screen.getByText('button')); expect(handler.mock.calls.length).toEqual(0); }); |