lib prompt test passes.

This commit is contained in:
Jordan
2024-02-26 10:41:03 -08:00
parent 24d0aaffcd
commit 29eb059fda
5 changed files with 76 additions and 41 deletions

View File

@ -12,7 +12,7 @@ import { useStore } from '@nanostores/react'
type Composable = (typeof Nugget) | (typeof Operation);
export default function PromptArea({ children }: { children?: any }) {
export default function PromptArea(props) {
const [open, setOpen] = React.useState(false);
const handleClickOpen = () => {
@ -41,9 +41,7 @@ export default function PromptArea({ children }: { children?: any }) {
</Button>
<Masonry columns={Object.keys(Category).length} spacing={2} sequential>
{slottedComposition.map(nugget => {
})}
<div>Something</div>
</Masonry>
</div>
);

View File

@ -5,6 +5,7 @@ import { PromptLibrary } from './PromptLibrary';
import { SimpleDialogProps } from './PromptLibrary';
import { Category, LibraryItem as LibItemType } from '../lib/prompt';
import { randomUUID } from 'crypto';
import { act } from 'react-dom/test-utils';
const mockOnAddItem = jest.fn();
const mockItem: LibItemType = {
@ -38,6 +39,8 @@ test('renders PromptLibrary with add button', () => {
test('calls onAddItem when add button is clicked', async () => {
render(<PromptLibrary {...mockProps} />);
const addButton = screen.getByLabelText('Add');
await userEvent.click(addButton);
act(() => {
userEvent.click(addButton);
})
expect(mockOnAddItem).toHaveBeenCalledWith(mockItem);
});