Untitled
unknown
plain_text
2 years ago
8.9 kB
3
Indexable
<<<<<<< HEAD import { act, screen, fireEvent } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import { vi } from 'vitest'; import App from '../App'; import { drinksFetch } from './moks.ts/Mocks'; import ProviderApp from '../Context/Provider'; import { renderWithRouter } from './moks.ts/RenderWithRouter'; import { mealsFecth } from './moks.ts/mocksMeals'; ======= import { act, screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import { vi } from 'vitest'; import App from '../App'; import { drinksFetch } from './Mocks/MockDrinks'; import ProviderApp from '../Context/Provider'; import { renderWithRouter } from './Mocks/RenderWithRouter'; import { mealsFecth } from './Mocks/MockMeals'; const drinksBtnFooter = 'drinks-bottom-btn'; const searchBtn = 'search-top-btn'; const serchInput = 'search-input'; const inputNameRadio = 'name-search-radio'; const execBtn = 'exec-search-btn'; const firstLetterInput = 'first-letter-search-radio'; >>>>>>> 7b9429235b4619bc5f50d04ed089caf2785606a4 describe('testando o SearchBar', async () => { test('Testando o input Name', async () => { const fetchRevolvedValue = { ok: true, status: 200, json: async () => drinksFetch } as Response; vi.spyOn(global, 'fetch').mockResolvedValueOnce(fetchRevolvedValue); await act(async () => { renderWithRouter( <ProviderApp> <App /> </ProviderApp>, { route: '/drinks' }, ); }); <<<<<<< HEAD screen.debug(); const buttonDrink = await screen.findByTestId('drinks-bottom-btn'); await userEvent.click(buttonDrink); const button = await screen.findByTestId('search-top-btn'); await userEvent.click(button); const inputSearch = await screen.findByTestId('search-input'); await userEvent.type(inputSearch, 'a1'); const inputName = screen.getByTestId('name-search-radio'); await userEvent.click(inputName); const buttonPesquisa = screen.findByTestId('exec-search-btn'); await userEvent.click(await buttonPesquisa); const imgDrink = await screen.findByTestId('recipe-photo'); expect(imgDrink).toBeInTheDocument(); }); ======= const buttonDrink = await screen.findByTestId(drinksBtnFooter); await userEvent.click(buttonDrink); const button = await screen.findByTestId(searchBtn); await userEvent.click(button); const inputSearch = await screen.findByTestId(serchInput); await userEvent.type(inputSearch, 'a1'); const inputName = screen.getByTestId(inputNameRadio); await userEvent.click(inputName); const buttonPesquisa = screen.findByTestId(execBtn); await userEvent.click(await buttonPesquisa); const imgDrink = await screen.findByTestId('recipe-photo'); expect(imgDrink).toBeInTheDocument(); }); >>>>>>> 7b9429235b4619bc5f50d04ed089caf2785606a4 test('Testando o First letter', async () => { const fetchRevolvedValue = { ok: true, status: 200, json: async () => drinksFetch } as Response; vi.spyOn(global, 'fetch').mockResolvedValueOnce(fetchRevolvedValue); await act(async () => { renderWithRouter( <ProviderApp> <App /> </ProviderApp>, { route: '/drinks' }, ); }); screen.debug(); <<<<<<< HEAD const btnDrink = await screen.findByTestId('drinks-bottom-btn'); await userEvent.click(btnDrink); const button = await screen.findByTestId('search-top-btn'); await userEvent.click(button); const inputSearch = await screen.findByTestId('search-input'); await userEvent.type(inputSearch, 'gg'); const inputFirstLetter = screen.getByTestId('first-letter-search-radio'); await userEvent.click(inputFirstLetter); const buttonPesquisa = screen.findByTestId('exec-search-btn'); await userEvent.click(await buttonPesquisa); }); ======= const btnDrink = await screen.findByTestId(drinksBtnFooter); await userEvent.click(btnDrink); const button = await screen.findByTestId(searchBtn); await userEvent.click(button); const inputSearch = await screen.findByTestId(serchInput); await userEvent.type(inputSearch, 'gg'); const inputFirstLetter = screen.getByTestId(firstLetterInput); await userEvent.click(inputFirstLetter); const buttonPesquisa = screen.findByTestId(execBtn); await userEvent.click(await buttonPesquisa); }); >>>>>>> 7b9429235b4619bc5f50d04ed089caf2785606a4 test('Testando o input First letter', async () => { const fetchRevolvedValue = { ok: true, status: 200, json: async () => drinksFetch } as Response; vi.spyOn(global, 'fetch').mockResolvedValueOnce(fetchRevolvedValue); await act(async () => { renderWithRouter( <ProviderApp> <App /> </ProviderApp>, { route: '/drinks' }, ); }); screen.debug(); <<<<<<< HEAD const Search = await screen.findByTestId('search-top-btn'); await userEvent.click(Search); const iptPesquisa = await screen.findByTestId('search-input'); await userEvent.click(iptPesquisa); await userEvent.type(Search, 'g'); const inputFirsLet = screen.getByTestId('first-letter-search-radio'); await userEvent.click(inputFirsLet); const btnBusca = await screen.findByTestId('exec-search-btn'); await userEvent.click(btnBusca); ======= const Search = await screen.findByTestId(searchBtn); await userEvent.click(Search); const iptPesquisa = await screen.findByTestId(serchInput); await userEvent.click(iptPesquisa); await userEvent.type(Search, 'g'); const inputFirsLet = screen.getByTestId(firstLetterInput); await userEvent.click(inputFirsLet); const btnBusca = await screen.findByTestId(execBtn); await userEvent.click(btnBusca); >>>>>>> 7b9429235b4619bc5f50d04ed089caf2785606a4 const imgDrinks = await screen.findByTestId('0-card-name'); expect(imgDrinks).toBeTruthy(); }); }); <<<<<<< HEAD ======= >>>>>>> 7b9429235b4619bc5f50d04ed089caf2785606a4 test('Testando o input Ingredient', async () => { const fetchRevolvedValue = { ok: true, status: 200, json: async () => mealsFecth } as Response; vi.spyOn(global, 'fetch').mockResolvedValueOnce(fetchRevolvedValue); await act(async () => { renderWithRouter( <ProviderApp> <App /> </ProviderApp>, { route: '/meals' }, ); }); <<<<<<< HEAD screen.debug(); const melass = await screen.findByTestId('meals-bottom-btn'); await userEvent.click(melass); const inptSearch = await screen.findByTestId('search-top-btn'); await userEvent.click(inptSearch); const iptPesquisa = await screen.findByTestId('search-input'); await userEvent.click(iptPesquisa); await userEvent.type(inptSearch, 'Carrots'); const inputIngredient = screen.getByTestId('ingredient-search-radio'); await userEvent.click(inputIngredient); const btnPesquisa = await screen.findByTestId('exec-search-btn'); await userEvent.click(btnPesquisa); const imgMeals = await screen.findByTestId('10-card-img'); expect(imgMeals).toBeInTheDocument(); }); ======= const melass = await screen.findByTestId('meals-bottom-btn'); await userEvent.click(melass); const inptSearch = await screen.findByTestId(searchBtn); await userEvent.click(inptSearch); const iptPesquisa = await screen.findByTestId(serchInput); await userEvent.click(iptPesquisa); await userEvent.type(inptSearch, 'Carrots'); const inputIngredient = screen.getByTestId('ingredient-search-radio'); await userEvent.click(inputIngredient); const btnPesquisa = await screen.findByTestId(execBtn); await userEvent.click(btnPesquisa); const imgMeals = await screen.findByTestId('10-card-img'); expect(imgMeals).toBeInTheDocument(); }); >>>>>>> 7b9429235b4619bc5f50d04ed089caf2785606a4 describe('SearchBar component', () => { it('should render all input fields and buttons', () => { renderWithRouter( <ProviderApp> <App /> </ProviderApp>, { route: '/meals' }, ); <<<<<<< HEAD expect(screen.getByTestId('search-top-btn')).toBeInTheDocument(); expect(screen.getByTestId('ingredient-search-radio')).toBeInTheDocument(); expect(screen.getByTestId('name-search-radio')).toBeInTheDocument(); expect(screen.getByTestId('first-letter-search-radio')).toBeInTheDocument(); expect(screen.getByTestId('exec-search-btn')).toBeInTheDocument(); ======= expect(screen.getByTestId(searchBtn)).toBeInTheDocument(); expect(screen.getByTestId('ingredient-search-radio')).toBeInTheDocument(); expect(screen.getByTestId(inputNameRadio)).toBeInTheDocument(); expect(screen.getByTestId(firstLetterInput)).toBeInTheDocument(); expect(screen.getByTestId(execBtn)).toBeInTheDocument(); >>>>>>> 7b9429235b4619bc5f50d04ed089caf2785606a4 }); });
Editor is loading...
Leave a Comment