mirror of
https://github.com/ahmadk953/tasko.git
synced 2025-01-30 16:43:37 +00:00
Updated Tests and Caching
This commit is contained in:
parent
5ba9387411
commit
dbecdc0212
3 changed files with 36 additions and 1 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -6,6 +6,7 @@
|
|||
|
||||
# testing
|
||||
/coverage
|
||||
junit.xml
|
||||
|
||||
# next.js
|
||||
/.next/
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import '@testing-library/jest-dom';
|
||||
import { render, screen, fireEvent, act } from '@testing-library/react';
|
||||
import { render, screen, fireEvent, waitFor } from '@testing-library/react';
|
||||
import { toast } from 'sonner';
|
||||
|
||||
import { BoardTitleForm } from '@/app/(platform)/(dashboard)/board/[boardId]/_components/board-title-form';
|
||||
import { Board } from '@prisma/client';
|
||||
|
@ -15,6 +16,16 @@ jest.mock('@/actions/update-board', () => ({
|
|||
updateBoard: jest.fn(),
|
||||
}));
|
||||
|
||||
jest.mock('@/hooks/use-action', () => ({
|
||||
useAction: jest.fn().mockImplementation(() => ({
|
||||
execute: jest.fn().mockImplementation(({ title }) => {
|
||||
Promise.resolve().then(() => {
|
||||
toast.success(`Board "${title}" updated!`);
|
||||
});
|
||||
}),
|
||||
})),
|
||||
}));
|
||||
|
||||
describe('BoardTitleForm', () => {
|
||||
const mockBoard: Board = {
|
||||
id: '1',
|
||||
|
@ -46,4 +57,19 @@ describe('BoardTitleForm', () => {
|
|||
const input = await screen.findByDisplayValue('Test Board');
|
||||
expect(input).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should update board title when form is blurred', async () => {
|
||||
render(<BoardTitleForm data={mockBoard} />);
|
||||
|
||||
const titleButton = screen.getByText('Test Board');
|
||||
fireEvent.click(titleButton);
|
||||
|
||||
const input = await screen.findByDisplayValue('Test Board');
|
||||
fireEvent.change(input, { target: { value: 'New Title' } });
|
||||
fireEvent.blur(input);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(toast.success).toHaveBeenCalledWith('Board "New Title" updated!');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -31,6 +31,14 @@ const nextConfig: NextConfig = {
|
|||
key: 'Document-Policy',
|
||||
value: 'js-profiling',
|
||||
},
|
||||
{
|
||||
key: 'CDN-Cache-Control',
|
||||
value: 'public, s-maxage=15',
|
||||
},
|
||||
{
|
||||
key: 'Vercel-CDN-Cache-Control',
|
||||
value: 'public, s-maxage=30',
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
|
Loading…
Reference in a new issue