diff --git a/app/soapbox/components/polls/__tests__/poll-footer.test.tsx b/app/soapbox/components/polls/__tests__/poll-footer.test.tsx index 2f4f21a6f..7265f7e1c 100644 --- a/app/soapbox/components/polls/__tests__/poll-footer.test.tsx +++ b/app/soapbox/components/polls/__tests__/poll-footer.test.tsx @@ -1,12 +1,16 @@ +import userEvent from '@testing-library/user-event'; import React from 'react'; +import { IntlProvider } from 'react-intl'; +import { Provider } from 'react-redux'; +import { __stub } from 'soapbox/api'; import { normalizePoll } from 'soapbox/normalizers/poll'; -import { render, screen } from '../../../jest/test-helpers'; +import { mockStore, render, rootReducer, screen } from '../../../jest/test-helpers'; import PollFooter from '../poll-footer'; - let poll = normalizePoll({ + id: 1, options: [{ title: 'Apples', votes_count: 0 }], emojis: [], expired: false, @@ -26,6 +30,30 @@ describe('', () => { expect(screen.getByTestId('poll-footer')).toHaveTextContent('Refresh'); }); + it('responds to the Refresh button', async() => { + __stub((mock) => { + mock.onGet('/api/v1/polls/1').reply(200, {}); + }); + + const user = userEvent.setup(); + const store = mockStore(rootReducer(undefined, {})); + render( + + + + + , + ); + + await user.click(screen.getByTestId('poll-refresh')); + const actions = store.getActions(); + expect(actions).toEqual([ + { type: 'POLL_FETCH_REQUEST' }, + { type: 'POLLS_IMPORT', polls: [{}] }, + { type: 'POLL_FETCH_SUCCESS', poll: {} }, + ]); + }); + it('does not render the Vote button', () => { render(); diff --git a/app/soapbox/components/polls/poll-footer.tsx b/app/soapbox/components/polls/poll-footer.tsx index ad3db5dbd..bfa105ebd 100644 --- a/app/soapbox/components/polls/poll-footer.tsx +++ b/app/soapbox/components/polls/poll-footer.tsx @@ -47,7 +47,7 @@ const PollFooter: React.FC = ({ poll, showResults, selected }): JSX {showResults && ( <> -