Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
ryantanbingyang committed Nov 15, 2024
1 parent 7f75bb0 commit 015f3e1
Show file tree
Hide file tree
Showing 5 changed files with 2,011 additions and 69 deletions.
3 changes: 2 additions & 1 deletion frontend-interface/components/DragAndDropGrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -525,4 +525,5 @@ export default function DragAndDropGrid() {
</DragDropContext>
</div>
);
}
}

30 changes: 30 additions & 0 deletions frontend-interface/components/__tests__/DragAndDropGrid.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import React from 'react';
import { render, screen } from '@testing-library/react';
import React from 'react';
import { render, screen } from '@testing-library/react';
import DragAndDropGrid from '../DragAndDropGrid';

test('renders drag and drop grid', () => {
render(<DragAndDropGrid />);
const dragAndDropGridElement = screen.getByText(/drag and drop grid/i);
expect(dragAndDropGridElement).toBeInTheDocument();
});

test('renders grid items', () => {
render(<DragAndDropGrid />);
const gridItemElements = screen.getAllByTestId('grid-item');
expect(gridItemElements.length).toBeGreaterThan(0);
});

test('allows dragging of grid items', () => {
render(<DragAndDropGrid />);
const gridItemElement = screen.getByTestId('grid-item-1');
expect(gridItemElement).toHaveAttribute('draggable', 'true');
});

test('allows dropping of grid items', () => {
render(<DragAndDropGrid />);
const dropZoneElement = screen.getByTestId('drop-zone');
expect(dropZoneElement).toBeInTheDocument();
});
});
4 changes: 4 additions & 0 deletions frontend-interface/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
testEnvironment: 'jsdom',
testMatch: ['**/__tests__/**/*.js?(x)', '**/?(*.)+(spec|test).js?(x)'],
};
Loading

0 comments on commit 015f3e1

Please sign in to comment.