import { describe, it, afterEach, type TestContext } from 'node:test'
import { cleanup, fireEvent, render, screen, waitFor } from '@testing-library/preact'
import messageFactory from './message_factory.tsx'
import { h } from 'preact'
const Message = messageFactory({})
describe('Message', () => {
afterEach(cleanup)
it('should display initial count', (t: TestContext) => {
render(We are great)
t.assert.ok(screen.getByText('We are great'))
})
it('should dismiss', async (t: TestContext) => {
const dismiss = t.mock.fn()
render(We are great)
t.assert.equal(dismiss.mock.callCount(), 0)
fireEvent.click(screen.getByRole('button'))
await waitFor(() => {
t.assert.equal(dismiss.mock.callCount(), 1)
})
})
})