Fix more types in tests

This commit is contained in:
Alex Gleason 2022-07-06 12:31:11 -05:00
parent 590e85ac59
commit 0c7f1628b0
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7
6 changed files with 29 additions and 28 deletions

View file

@ -6,7 +6,7 @@ import CaptchaField, { NativeCaptchaField } from '../captcha';
describe('<CaptchaField />', () => {
it('renders null by default', () => {
render(<CaptchaField />);
render(<CaptchaField idempotencyKey='' value='' />);
expect(screen.queryAllByRole('textbox')).toHaveLength(0);
});
@ -24,7 +24,9 @@ describe('<NativeCaptchaField />', () => {
render(
<NativeCaptchaField
captcha={captcha}
onChange={() => {}} // eslint-disable-line react/jsx-no-bind
onChange={() => {}}
onClick={() => {}}
value=''
/>,
);

View file

@ -13,7 +13,7 @@ describe('<LoginForm />', () => {
}),
};
render(<LoginForm handleSubmit={mockFn} isLoading={false} />, null, store);
render(<LoginForm handleSubmit={mockFn} isLoading={false} />, undefined, store);
expect(screen.getByRole('heading')).toHaveTextContent(/sign in/i);
});
@ -26,7 +26,7 @@ describe('<LoginForm />', () => {
}),
};
render(<LoginForm handleSubmit={mockFn} isLoading={false} />, null, store);
render(<LoginForm handleSubmit={mockFn} isLoading={false} />, undefined, store);
expect(screen.getByRole('heading')).toHaveTextContent(/sign in/i);
});

View file

@ -12,7 +12,7 @@ describe('<LoginPage />', () => {
}),
};
render(<LoginPage />, null, store);
render(<LoginPage />, undefined, store);
expect(screen.getByRole('heading')).toHaveTextContent('Sign In');
});

View file

@ -1,9 +1,10 @@
// @ts-ignore
import { emojiIndex } from 'emoji-mart';
import pick from 'lodash/pick';
import { search } from '../emoji_mart_search_light';
const trimEmojis = emoji => pick(emoji, ['id', 'unified', 'native', 'custom']);
const trimEmojis = (emoji: any) => pick(emoji, ['id', 'unified', 'native', 'custom']);
describe('emoji_index', () => {
it('should give same result for emoji_index_light and emoji-mart', () => {
@ -46,7 +47,7 @@ describe('emoji_index', () => {
});
it('can include/exclude categories', () => {
expect(search('flag', { include: ['people'] })).toEqual([]);
expect(search('flag', { include: ['people'] } as any)).toEqual([]);
expect(emojiIndex.search('flag', { include: ['people'] })).toEqual([]);
});
@ -63,9 +64,8 @@ describe('emoji_index', () => {
custom: true,
},
];
search('', { custom });
search('', { custom } as any);
emojiIndex.search('', { custom });
const expected = [];
const lightExpected = [
{
id: 'mastodon',
@ -73,7 +73,7 @@ describe('emoji_index', () => {
},
];
expect(search('masto').map(trimEmojis)).toEqual(lightExpected);
expect(emojiIndex.search('masto').map(trimEmojis)).toEqual(expected);
expect(emojiIndex.search('masto').map(trimEmojis)).toEqual([]);
});
it('(different behavior from emoji-mart) erases custom emoji if another is passed', () => {
@ -89,11 +89,10 @@ describe('emoji_index', () => {
custom: true,
},
];
search('', { custom });
search('', { custom } as any);
emojiIndex.search('', { custom });
const expected = [];
expect(search('masto', { custom: [] }).map(trimEmojis)).toEqual(expected);
expect(emojiIndex.search('masto').map(trimEmojis)).toEqual(expected);
expect(search('masto', { custom: [] } as any).map(trimEmojis)).toEqual([]);
expect(emojiIndex.search('masto').map(trimEmojis)).toEqual([]);
});
it('handles custom emoji', () => {
@ -109,7 +108,7 @@ describe('emoji_index', () => {
custom: true,
},
];
search('', { custom });
search('', { custom } as any);
emojiIndex.search('', { custom });
const expected = [
{
@ -117,15 +116,15 @@ describe('emoji_index', () => {
custom: true,
},
];
expect(search('masto', { custom }).map(trimEmojis)).toEqual(expected);
expect(search('masto', { custom } as any).map(trimEmojis)).toEqual(expected);
expect(emojiIndex.search('masto', { custom }).map(trimEmojis)).toEqual(expected);
});
it('should filter only emojis we care about, exclude pineapple', () => {
const emojisToShowFilter = emoji => emoji.unified !== '1F34D';
expect(search('apple', { emojisToShowFilter }).map((obj) => obj.id))
const emojisToShowFilter = (emoji: any) => emoji.unified !== '1F34D';
expect(search('apple', { emojisToShowFilter } as any).map((obj: any) => obj.id))
.not.toContain('pineapple');
expect(emojiIndex.search('apple', { emojisToShowFilter }).map((obj) => obj.id))
expect(emojiIndex.search('apple', { emojisToShowFilter }).map((obj: any) => obj.id))
.not.toContain('pineapple');
});

View file

@ -18,7 +18,7 @@ jest.mock('../../../hooks/useDimensions', () => ({
};
describe('<FeedCarousel />', () => {
let store;
let store: any;
describe('with "feedUserFiltering" disabled', () => {
beforeEach(() => {
@ -35,7 +35,7 @@ describe('<FeedCarousel />', () => {
});
it('should render nothing', () => {
render(<FeedCarousel />, null, store);
render(<FeedCarousel />, undefined, store);
expect(screen.queryAllByTestId('feed-carousel')).toHaveLength(0);
});
@ -56,7 +56,7 @@ describe('<FeedCarousel />', () => {
});
it('should render the Carousel', () => {
render(<FeedCarousel />, null, store);
render(<FeedCarousel />, undefined, store);
expect(screen.queryAllByTestId('feed-carousel')).toHaveLength(1);
});
@ -70,7 +70,7 @@ describe('<FeedCarousel />', () => {
});
it('renders the error message', () => {
render(<FeedCarousel />, null, store);
render(<FeedCarousel />, undefined, store);
expect(screen.getByTestId('feed-carousel-error')).toBeInTheDocument();
});
@ -110,7 +110,7 @@ describe('<FeedCarousel />', () => {
it('should render the correct prev/next buttons', async() => {
const user = userEvent.setup();
render(<FeedCarousel />, null, store);
render(<FeedCarousel />, undefined, store);
await waitFor(() => {
expect(screen.getByTestId('next-page')).toBeInTheDocument();

View file

@ -17,7 +17,7 @@ describe('<LandingPage />', () => {
},
});
render(<LandingPage />, null, state);
render(<LandingPage />, undefined, state);
expect(screen.queryByTestId('registrations-open')).toBeInTheDocument();
expect(screen.queryByTestId('registrations-closed')).not.toBeInTheDocument();
@ -34,7 +34,7 @@ describe('<LandingPage />', () => {
},
});
render(<LandingPage />, null, state);
render(<LandingPage />, undefined, state);
expect(screen.queryByTestId('registrations-closed')).toBeInTheDocument();
expect(screen.queryByTestId('registrations-open')).not.toBeInTheDocument();
@ -59,7 +59,7 @@ describe('<LandingPage />', () => {
},
}], rootReducer);
render(<LandingPage />, null, state);
render(<LandingPage />, undefined, state);
expect(screen.queryByTestId('registrations-pepe')).toBeInTheDocument();
expect(screen.queryByTestId('registrations-open')).not.toBeInTheDocument();
@ -81,7 +81,7 @@ describe('<LandingPage />', () => {
},
}], rootReducer);
render(<LandingPage />, null, state);
render(<LandingPage />, undefined, state);
expect(screen.queryByTestId('registrations-closed')).toBeInTheDocument();
expect(screen.queryByTestId('registrations-pepe')).not.toBeInTheDocument();