Skip to content

Commit

Permalink
feat(vadcDataDictionaryTable): linted test file
Browse files Browse the repository at this point in the history
  • Loading branch information
jarvisraymond-uchicago committed Jan 17, 2024
1 parent f516484 commit 8757d96
Showing 1 changed file with 5 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from 'react';
import { render, fireEvent } from '@testing-library/react';
import '@testing-library/jest-dom';
import '@mantine/core/styles.css'; // ensure styles are loaded for testing
import PaginationControls from './PaginationControls';

describe('PaginationControls', () => {
Expand All @@ -15,35 +14,24 @@ describe('PaginationControls', () => {

it('should render PaginationControls with correct initial state', () => {
const { getByTestId, getByLabelText } = render(
<PaginationControls {...defaultProps} />
<PaginationControls {...defaultProps} />,
);

expect(getByTestId('pagination-controls')).toBeInTheDocument();
expect(getByLabelText('Show')).toBeInTheDocument();
expect(getByLabelText('entries')).toBeInTheDocument();
});

it('should call setEntriesShown when select value changes', () => {
const { getByTestId, getByLabelText } = render(
<PaginationControls {...defaultProps} />
);

const { getByTestId } = render(<PaginationControls {...defaultProps} />);
const entriesSelect = getByTestId('entries-select');

fireEvent.change(entriesSelect, { target: { value: '20' } });

expect(defaultProps.setEntriesShown).toHaveBeenCalledWith(20);
});

it('should call setActivePage when pagination button is clicked', () => {
const { getByTestId, getAllByRole } = render(
<PaginationControls {...defaultProps} />
);

const nextButton = getAllByRole('button', { name: /2/i })[0];

fireEvent.click(nextButton);

const { getAllByRole } = render(<PaginationControls {...defaultProps} />);
const twoButton = getAllByRole('button', { name: /2/i })[0];
fireEvent.click(twoButton);
expect(defaultProps.setActivePage).toHaveBeenCalledWith(2);
});
});

0 comments on commit 8757d96

Please sign in to comment.