* Add TS configs and improve dir structure * Add TS configs and improve dir structure * Fix components exports from index * chore: prettier * Add tsconfig and then fix the linter warnings * Add @babel/preset-typescript * Fix eslint rule and update btn component to fix storybook * Fix TS and Jest configs Converted all remaining files to TS as well * Remove TS ignored rules and fixed some TS & jest stuff * Revert to old directory structure * Use absolute versions in package.json * enable ts strict to infer types Co-authored-by: Hamza Waleed <hamza.waleed@arbisoft.com>
26 lines
742 B
TypeScript
26 lines
742 B
TypeScript
import { render, screen } from '@testing-library/react';
|
|
import userEvent from '@testing-library/user-event';
|
|
import React from 'react';
|
|
import { Button } from './button';
|
|
|
|
const onClick = jest.fn();
|
|
|
|
describe('Button', () => {
|
|
it("should have the role 'button' and the correct text", () => {
|
|
render(<Button label='Hello world' onClick={onClick} />);
|
|
expect(
|
|
screen.getByRole('button', { name: /hello world/i })
|
|
).toBeInTheDocument();
|
|
});
|
|
|
|
it('should trigger the onClick prop on click', () => {
|
|
render(<Button label='Hello world' onClick={onClick} />);
|
|
|
|
const button = screen.getByRole('button', { name: /hello world/i });
|
|
|
|
userEvent.click(button);
|
|
|
|
expect(onClick).toHaveBeenCalledTimes(1);
|
|
});
|
|
});
|