Getting the button working

This commit is contained in:
Steve Kinney
2024-10-02 15:38:54 -05:00
parent 2552cb26d5
commit 25f1a63b96

View File

@@ -1,9 +1,26 @@
import { screen, fireEvent } from '@testing-library/dom';
import userEvent from '@testing-library/user-event';
import { createButton } from './button.js'; import { createButton } from './button.js';
describe.todo('createButton', () => { describe('createButton', () => {
it('should create a button element', () => {}); beforeEach(() => {
document.innerHTML = '';
});
it('should have the text "Click Me"', () => {}); it.skip('should create a button element', () => {
document.body.appendChild(createButton());
it('should change the text to "Clicked!" when clicked', async () => {}); const button = screen.getByRole('button', { name: 'Click Me' });
expect(button).toBeInTheDocument();
});
it('should change the text to "Clicked!" when clicked', async () => {
document.body.appendChild(createButton());
const button = screen.getByRole('button', { name: 'Click Me' });
await userEvent.click(button);
expect(button.textContent).toBe('Clicked!');
});
}); });