Skip to content

Commit

Permalink
Add tests for provider search
Browse files Browse the repository at this point in the history
  • Loading branch information
remidej committed Jun 8, 2022
1 parent c01c8b0 commit cf22c0f
Showing 1 changed file with 36 additions and 6 deletions.
Expand Up @@ -954,7 +954,7 @@ describe('Marketplace page', () => {
<div
class="c21"
>
Search for a plugin
Search
</div>
</label>
</div>
Expand Down Expand Up @@ -990,7 +990,7 @@ describe('Marketplace page', () => {
class="c28"
id="field-1"
name="searchbar"
placeholder="Search for a plugin"
placeholder="Search"
value=""
/>
</div>
Expand Down Expand Up @@ -1760,20 +1760,50 @@ describe('Marketplace page', () => {
expect(trackUsage).toHaveBeenCalledTimes(1);
});

it('should return search results matching the query', async () => {
it('should return plugin search results matching the query', async () => {
const { container } = render(App);
const input = await getByPlaceholderText(container, 'Search for a plugin');
const input = await getByPlaceholderText(container, 'Search');
fireEvent.change(input, { target: { value: 'comment' } });
const match = screen.getByText('Comments');
const notMatch = screen.queryByText('Sentry');
const provider = screen.queryByText('Cloudinary');

expect(match).toBeVisible();
expect(notMatch).toEqual(null);
expect(provider).toEqual(null);
});

it('should return empty search results given a bad query', async () => {
it('should return provider search results matching the query', async () => {
const { container } = render(App);
const input = await getByPlaceholderText(container, 'Search for a plugin');
const providersTab = screen.getByRole('tab', { selected: false });
fireEvent.click(providersTab);

const input = await getByPlaceholderText(container, 'Search');
fireEvent.change(input, { target: { value: 'cloudina' } });
const match = screen.getByText('Cloudinary');
const notMatch = screen.queryByText('Mailgun');
const plugin = screen.queryByText('Comments');

expect(match).toBeVisible();
expect(notMatch).toEqual(null);
expect(plugin).toEqual(null);
});

it('should return empty plugin search results given a bad query', async () => {
const { container } = render(App);
const input = await getByPlaceholderText(container, 'Search');
const badQuery = 'asdf';
fireEvent.change(input, { target: { value: badQuery } });
const noResult = screen.getByText(`No result for "${badQuery}"`);

expect(noResult).toBeVisible();
});

it('should return empty provider search results given a bad query', async () => {
const { container } = render(App);
const providersTab = screen.getByRole('tab', { selected: false });
fireEvent.click(providersTab);
const input = await getByPlaceholderText(container, 'Search');
const badQuery = 'asdf';
fireEvent.change(input, { target: { value: badQuery } });
const noResult = screen.getByText(`No result for "${badQuery}"`);
Expand Down

0 comments on commit cf22c0f

Please sign in to comment.