mirror of
https://github.com/ahmadk953/tasko.git
synced 2025-05-01 11:19:34 +00:00
Fixed a Small Error and Updated/Added Tests
This commit is contained in:
parent
4f205d7584
commit
3a095e2096
9 changed files with 105 additions and 14 deletions
49
__tests__/board-title-form.test.tsx
Normal file
49
__tests__/board-title-form.test.tsx
Normal file
|
@ -0,0 +1,49 @@
|
|||
import '@testing-library/jest-dom';
|
||||
import { render, screen, fireEvent, act } from '@testing-library/react';
|
||||
|
||||
import { BoardTitleForm } from '@/app/(platform)/(dashboard)/board/[boardId]/_components/board-title-form';
|
||||
import { Board } from '@prisma/client';
|
||||
|
||||
jest.mock('sonner', () => ({
|
||||
toast: {
|
||||
success: jest.fn(),
|
||||
error: jest.fn(),
|
||||
},
|
||||
}));
|
||||
|
||||
jest.mock('@/actions/update-board', () => ({
|
||||
updateBoard: jest.fn(),
|
||||
}));
|
||||
|
||||
describe('BoardTitleForm', () => {
|
||||
const mockBoard: Board = {
|
||||
id: '1',
|
||||
title: 'Test Board',
|
||||
imageId: 'image1',
|
||||
imageThumbUrl: 'thumb-url',
|
||||
imageFullUrl: 'full-url',
|
||||
imageUserName: 'user1',
|
||||
imageLinkHTML: 'link-html',
|
||||
imageDownloadUrl: 'download-url',
|
||||
createdAt: new Date(),
|
||||
updatedAt: new Date(),
|
||||
orgId: 'org1',
|
||||
};
|
||||
|
||||
it('should render correctly in browser environment', () => {
|
||||
render(<BoardTitleForm data={mockBoard} />);
|
||||
|
||||
const titleButton = screen.getByText('Test Board');
|
||||
expect(titleButton).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should switch to edit mode when clicked', async () => {
|
||||
render(<BoardTitleForm data={mockBoard} />);
|
||||
|
||||
const titleButton = screen.getByText('Test Board');
|
||||
fireEvent.click(titleButton);
|
||||
|
||||
const input = await screen.findByDisplayValue('Test Board');
|
||||
expect(input).toBeInTheDocument();
|
||||
});
|
||||
});
|
|
@ -8,6 +8,7 @@ describe('Home', () => {
|
|||
const { container } = render(<Page />);
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('renders a heading', () => {
|
||||
render(<Page />);
|
||||
|
||||
|
@ -15,4 +16,12 @@ describe('Home', () => {
|
|||
|
||||
expect(heading).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('renders a get started button', () => {
|
||||
render(<Page />);
|
||||
|
||||
const link = screen.getByRole('link', { name: /get tasko for free/i });
|
||||
|
||||
expect(link).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue