-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(vadcDataDictionaryTable): fixed test issues and eslint issues
- Loading branch information
1 parent
7c6b871
commit 0937d7c
Showing
2 changed files
with
22 additions
and
32 deletions.
There are no files selected for viewing
24 changes: 7 additions & 17 deletions
24
src/Analysis/DataDictionary/ColumnHeaders/ColumnHeaders.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,31 @@ | ||
import React from 'react'; | ||
import { render, fireEvent, screen } from '@testing-library/react'; | ||
import { ISortConfig } from '../Interfaces/Interfaces'; | ||
import '@testing-library/jest-dom/extend-expect'; | ||
import ColumnHeaders from './ColumnHeaders'; | ||
import Header from './Header'; // Assuming you've exported the Header component for testing | ||
|
||
interface ISortConfig { | ||
sortKey: string; | ||
sortDirection: 'asc' | 'desc'; | ||
} | ||
|
||
const sortConfig: ISortConfig = { sortKey: '', direction: 'ascending' }; | ||
describe('ColumnHeaders', () => { | ||
it('renders ColumnHeaders ', () => { | ||
const handleSort = jest.fn(); | ||
const sortConfig: ISortConfig = {}; | ||
|
||
render( | ||
<table> | ||
<ColumnHeaders handleSort={handleSort} sortConfig={sortConfig} /> | ||
</table> | ||
</table>, | ||
); | ||
|
||
expect(screen.getByTestId('column-headers')).toBeInTheDocument(); | ||
}); | ||
it('calls handleSort when a column is clicked', () => { | ||
const handleSort = jest.fn(); | ||
const sortConfig: ISortConfig = {}; | ||
|
||
const { getByRole } = render( | ||
render( | ||
<table> | ||
<ColumnHeaders handleSort={handleSort} sortConfig={sortConfig} /> | ||
</table> | ||
</table>, | ||
); | ||
|
||
fireEvent.click( | ||
screen.getAllByRole('presentation', { name: 'caret-up' })[0] | ||
screen.getAllByRole('presentation', { name: 'caret-up' })[0], | ||
); | ||
|
||
expect(handleSort).toHaveBeenCalledWith('vocabularyID'); // or 'desc' depending on the initial sorting state | ||
expect(handleSort).toHaveBeenCalledTimes(1); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters