Fix types in various component tests

This commit is contained in:
Alex Gleason 2022-07-06 12:16:14 -05:00
parent 354395501e
commit bdf00bb692
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7
7 changed files with 20 additions and 19 deletions

View file

@ -15,12 +15,12 @@ const TestableComponent = () => (
<Route path='/login' exact><span data-testid='sign-in'>Sign in</span></Route> <Route path='/login' exact><span data-testid='sign-in'>Sign in</span></Route>
{/* WrappedRount will redirect to /login for logged out users... which will resolve to the route above! */} {/* WrappedRount will redirect to /login for logged out users... which will resolve to the route above! */}
<WrappedRoute path='/notifications' /> <WrappedRoute path='/notifications' component={() => null} />
</Switch> </Switch>
); );
describe('<UI />', () => { describe('<UI />', () => {
let store; let store: any;
beforeEach(() => { beforeEach(() => {
store = { store = {

View file

@ -1,5 +1,4 @@
import { fireEvent, render, screen } from '@testing-library/react'; import { fireEvent, render, screen } from '@testing-library/react';
import { Map as ImmutableMap } from 'immutable';
import React from 'react'; import React from 'react';
import { IntlProvider } from 'react-intl'; import { IntlProvider } from 'react-intl';
import { Provider } from 'react-redux'; import { Provider } from 'react-redux';
@ -11,7 +10,7 @@ import rootReducer from 'soapbox/reducers';
import ComposeButton from '../compose-button'; import ComposeButton from '../compose-button';
const store = mockStore(rootReducer(ImmutableMap(), {})); const store = mockStore(rootReducer(undefined, {} as any));
const renderComposeButton = () => { const renderComposeButton = () => {
render( render(
<Provider store={store}> <Provider store={store}>

View file

@ -14,7 +14,7 @@ describe('<CtaBanner />', () => {
it('renders empty', () => { it('renders empty', () => {
const store = { me: true }; const store = { me: true };
render(<CtaBanner />, null, store); render(<CtaBanner />, undefined, store);
expect(screen.queryAllByTestId('cta-banner')).toHaveLength(0); expect(screen.queryAllByTestId('cta-banner')).toHaveLength(0);
}); });
}); });
@ -23,7 +23,7 @@ describe('<CtaBanner />', () => {
it('renders empty', () => { it('renders empty', () => {
const store = { soapbox: ImmutableMap({ singleUserMode: true }) }; const store = { soapbox: ImmutableMap({ singleUserMode: true }) };
render(<CtaBanner />, null, store); render(<CtaBanner />, undefined, store);
expect(screen.queryAllByTestId('cta-banner')).toHaveLength(0); expect(screen.queryAllByTestId('cta-banner')).toHaveLength(0);
}); });
}); });

View file

@ -5,7 +5,9 @@ import { render, screen } from '../../../../jest/test-helpers';
import { normalizeAccount, normalizeRelationship } from '../../../../normalizers'; import { normalizeAccount, normalizeRelationship } from '../../../../normalizers';
import SubscribeButton from '../subscription-button'; import SubscribeButton from '../subscription-button';
let account = { import type { ReducerAccount } from 'soapbox/reducers/accounts';
const justin = {
id: '1', id: '1',
acct: 'justin-username', acct: 'justin-username',
display_name: 'Justin L', display_name: 'Justin L',
@ -13,13 +15,13 @@ let account = {
}; };
describe('<SubscribeButton />', () => { describe('<SubscribeButton />', () => {
let store; let store: any;
describe('with "accountNotifies" disabled', () => { describe('with "accountNotifies" disabled', () => {
it('renders nothing', () => { it('renders nothing', () => {
account = normalizeAccount({ ...account, relationship: normalizeRelationship({ following: true }) }); const account = normalizeAccount({ ...justin, relationship: normalizeRelationship({ following: true }) }) as ReducerAccount;
render(<SubscribeButton account={account} />, null, store); render(<SubscribeButton account={account} />, undefined, store);
expect(screen.queryAllByTestId('icon-button')).toHaveLength(0); expect(screen.queryAllByTestId('icon-button')).toHaveLength(0);
}); });
}); });

View file

@ -23,7 +23,7 @@ describe('<TrendsPanel />', () => {
})(), })(),
}; };
render(<TrendsPanel limit={1} />, null, store); render(<TrendsPanel limit={1} />, undefined, store);
expect(screen.getByTestId('hashtag')).toHaveTextContent(/hashtag 1/i); expect(screen.getByTestId('hashtag')).toHaveTextContent(/hashtag 1/i);
expect(screen.getByTestId('hashtag')).toHaveTextContent(/180 people talking/i); expect(screen.getByTestId('hashtag')).toHaveTextContent(/180 people talking/i);
expect(screen.getByTestId('sparklines')).toBeInTheDocument(); expect(screen.getByTestId('sparklines')).toBeInTheDocument();
@ -46,7 +46,7 @@ describe('<TrendsPanel />', () => {
})(), })(),
}; };
render(<TrendsPanel limit={3} />, null, store); render(<TrendsPanel limit={3} />, undefined, store);
expect(screen.queryAllByTestId('hashtag')).toHaveLength(2); expect(screen.queryAllByTestId('hashtag')).toHaveLength(2);
}); });
@ -67,7 +67,7 @@ describe('<TrendsPanel />', () => {
})(), })(),
}; };
render(<TrendsPanel limit={1} />, null, store); render(<TrendsPanel limit={1} />, undefined, store);
expect(screen.queryAllByTestId('hashtag')).toHaveLength(1); expect(screen.queryAllByTestId('hashtag')).toHaveLength(1);
}); });
@ -79,7 +79,7 @@ describe('<TrendsPanel />', () => {
})(), })(),
}; };
render(<TrendsPanel limit={1} />, null, store); render(<TrendsPanel limit={1} />, undefined, store);
expect(screen.queryAllByTestId('hashtag')).toHaveLength(0); expect(screen.queryAllByTestId('hashtag')).toHaveLength(0);
}); });
}); });

View file

@ -24,7 +24,7 @@ describe('<WhoToFollow />', () => {
}, },
}; };
render(<WhoToFollowPanel limit={1} />, null, store); render(<WhoToFollowPanel limit={1} />, undefined, store);
expect(screen.getByTestId('account')).toHaveTextContent(/my name/i); expect(screen.getByTestId('account')).toHaveTextContent(/my name/i);
}); });
@ -58,7 +58,7 @@ describe('<WhoToFollow />', () => {
}, },
}; };
render(<WhoToFollowPanel limit={3} />, null, store); render(<WhoToFollowPanel limit={3} />, undefined, store);
expect(screen.queryAllByTestId('account')).toHaveLength(2); expect(screen.queryAllByTestId('account')).toHaveLength(2);
}); });
@ -92,7 +92,7 @@ describe('<WhoToFollow />', () => {
}, },
}; };
render(<WhoToFollowPanel limit={1} />, null, store); render(<WhoToFollowPanel limit={1} />, undefined, store);
expect(screen.queryAllByTestId('account')).toHaveLength(1); expect(screen.queryAllByTestId('account')).toHaveLength(1);
}); });
@ -117,7 +117,7 @@ describe('<WhoToFollow />', () => {
}, },
}; };
render(<WhoToFollowPanel limit={1} />, null, store); render(<WhoToFollowPanel limit={1} />, undefined, store);
expect(screen.queryAllByTestId('account')).toHaveLength(0); expect(screen.queryAllByTestId('account')).toHaveLength(0);
}); });
}); });

View file

@ -9,7 +9,7 @@ import { normalizeAccount, normalizeStatus } from '../../../../../../normalizers
import ReportModal from '../report-modal'; import ReportModal from '../report-modal';
describe('<ReportModal />', () => { describe('<ReportModal />', () => {
let store; let store: any;
beforeEach(() => { beforeEach(() => {
const rules = require('soapbox/__fixtures__/rules.json'); const rules = require('soapbox/__fixtures__/rules.json');