Skip to content

Instantly share code, notes, and snippets.

@mariocsantos
Last active January 13, 2021 21:02
Show Gist options
  • Save mariocsantos/84a07fcb2dcf2a312019f6a6ed55dcb2 to your computer and use it in GitHub Desktop.
Save mariocsantos/84a07fcb2dcf2a312019f6a6ed55dcb2 to your computer and use it in GitHub Desktop.
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();
});
it('should enable add food button', () => {
render(<FavoriteFood />);
const input = screen.getByLabelText(/Favorite food/i);
userEvent.type(input, 'Taco 🌮');
expect(screen.getByRole('button')).toBeEnabled();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment