Create initial App/Search tests and related data

This commit is contained in:
2020-07-30 17:36:22 +02:00
parent 6af8d5db92
commit 5810948275
5 changed files with 529 additions and 15 deletions

38
src/tests/Search.test.tsx Normal file
View File

@@ -0,0 +1,38 @@
import React from 'react';
import { render, cleanup, fireEvent } from '@testing-library/react';
import App from '../components/App';
describe('Search', () => {
afterEach(cleanup);
it('displays Search component', () => {
const { getByText, getByRole } = render(<App />);
const title = getByText('Spoti Search');
const input = getByRole('searchbox', { name: 'Search by artist name' });
expect(title).toBeInTheDocument();
expect(input).toBeInTheDocument();
});
afterEach(cleanup);
it('allows input on the search field', () => {
const { getByRole } = render(<App />);
const input = getByRole('searchbox', { name: 'Search by artist name' });
fireEvent.change(input, { target: { value: 'Kendrik' } });
expect(input.value).toBe('Kendrik');
});
afterEach(cleanup);
it('loads suggestions based on the searchbox input', async () => {
const { getByRole } = render(<App />);
const input = getByRole('searchbox', { name: 'Search by artist name' });
fireEvent.change(input, { target: { value: 'Kendrik' } });
// TODO
// const suggestion = getByRole('generic', { name: 'XXXTENTACION' });
// expect(suggestion).toBe('XXXTENTACION');
});
});