This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { render } from '@testing-library/react'; | |
import { axe, toHaveNoViolations } from 'jest-axe'; | |
import { FavoriteFoodSearch } from '../FavoriteFoodSearch'; | |
expect.extend(toHaveNoViolations) | |
describe('FavoriteFoodSearch', () => { | |
it('should not fail any accessibility tests', async () => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useState } from 'react'; | |
function FavoriteFoodSearch() { | |
const [search, setSearch] = useState(''); | |
const handleChange = (event) => { | |
setSearch(event.target.value ?? ''); | |
} | |
return ( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { render, screen, waitFor } from '@testing-library/react'; | |
import { FavoriteFoodList } from '../FavoriteFoodList'; | |
describe('FavoriteFoodList', () => { | |
it('should render my favorites food', async () => { | |
render(<FavoriteFoodList />); | |
await waitFor(() => expect(screen.getAllByRole('listitem')).toHaveLength(3)); | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useEffect, useState } from 'react'; | |
import { getFavoritesFood } from './api'; | |
function FavoriteFoodList() { | |
const [list, setList] = useState([]); | |
const getList = async () => { | |
const newList = await getFavoritesFood(); | |
setList(newList); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useState } from 'react'; | |
function FavoriteFood({ onSubmit }) { | |
const [favoriteFood, setFavoriteFood] = useState(''); | |
const handleChange = (event) => { | |
setFavoriteFood(event.target.value); | |
} | |
const handleSubmit = (event) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { render, screen } from '@testing-library/react'; | |
import userEvent from '@testing-library/user-event'; | |
import { FavoriteFood } from '../FavoriteFood'; | |
describe('FavoriteFood', () => { | |
it('should submit form', () => { | |
const onSubmitMock = jest.fn(); | |
render(<FavoriteFood onSubmit={onSubmitMock} />); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { render, screen } from '@testing-library/react'; | |
import userEvent from '@testing-library/user-event'; | |
import { FavoriteFood } from '../FavoriteFood'; | |
describe('FavoriteFood', () => { | |
it('should disable add food button', () => { | |
render(<FavoriteFood />); | |
expect(screen.getByRole('button')).toBeDisabled(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useState } from 'react'; | |
function FavoriteFood() { | |
const [favoriteFood, setFavoriteFood] = useState(''); | |
const handleChange = (event) => { | |
setFavoriteFood(event.target.value); | |
} | |
return ( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { render, screen } from '@testing-library/react'; | |
import { FavoriteFoodList } from '../FavoriteFoodList'; | |
describe('FavoriteFoodList', () => { | |
it('should render my favorites food', () => { | |
render(<FavoriteFoodList />); | |
screen.debug(); | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { render, screen } from '@testing-library/react'; | |
import { FavoriteFoodList } from '../FavoriteFoodList'; | |
describe('FavoriteFoodList', () => { | |
it('should render my favorites food', () => { | |
render(<FavoriteFoodList />); | |
expect(screen.getAllByRole('listitem')).not.toHaveLength(3); | |
}); | |
}); |
NewerOlder