generated from bcgov/quickstart-openshift
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(SILVA-550): Enhance Org Unit and Category Selection with Filterab…
…le Multi-Select Dropdown (#442) Co-authored-by: Paulo Gomes da Cruz Junior <[email protected]> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
- Loading branch information
1 parent
95d2be5
commit 32c6eda
Showing
14 changed files
with
350 additions
and
85 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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 |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// OpeningsSearchProvider.test.tsx | ||
import React from 'react'; | ||
import { describe, it, expect, beforeEach, vi } from 'vitest'; | ||
import { render, screen, fireEvent } from '@testing-library/react'; | ||
import { OpeningsSearchProvider, useOpeningsSearch } from '../../contexts/search/OpeningsSearch'; | ||
|
||
const TestComponent: React.FC = () => { | ||
const { filters, setFilters, searchTerm, setSearchTerm, clearFilters, clearIndividualField } = useOpeningsSearch(); | ||
|
||
return ( | ||
<div> | ||
<p data-testid="searchTerm">{searchTerm}</p> | ||
<p data-testid="startDate">{String(filters.startDate)}</p> | ||
<button onClick={() => setSearchTerm('test search')} data-testid="setSearchTerm">Set Search Term</button> | ||
<button onClick={() => setFilters({ ...filters, startDate: new Date() })} data-testid="setFilters">Set Start Date</button> | ||
<button onClick={() => clearFilters()} data-testid="clearFilters">Clear Filters</button> | ||
<button onClick={() => clearIndividualField('startDate')} data-testid="clearStartDate">Clear Start Date</button> | ||
</div> | ||
); | ||
}; | ||
|
||
describe('OpeningsSearchProvider', () => { | ||
beforeEach(() => { | ||
render( | ||
<OpeningsSearchProvider> | ||
<TestComponent /> | ||
</OpeningsSearchProvider> | ||
); | ||
}); | ||
|
||
it('should initialize with default values', () => { | ||
expect(screen.getByTestId('searchTerm').textContent).toBe(''); | ||
expect(screen.getByTestId('startDate').textContent).toBe('null'); | ||
}); | ||
|
||
it('should update searchTerm', () => { | ||
fireEvent.click(screen.getByTestId('setSearchTerm')); | ||
expect(screen.getByTestId('searchTerm').textContent).toBe('test search'); | ||
}); | ||
|
||
it('should set and then clear filters', () => { | ||
fireEvent.click(screen.getByTestId('setFilters')); | ||
expect(screen.getByTestId('startDate').textContent).not.toBe('null'); | ||
|
||
fireEvent.click(screen.getByTestId('clearFilters')); | ||
expect(screen.getByTestId('startDate').textContent).toBe('null'); | ||
}); | ||
|
||
it('should clear individual field', () => { | ||
fireEvent.click(screen.getByTestId('setFilters')); | ||
expect(screen.getByTestId('startDate').textContent).not.toBe('null'); | ||
|
||
fireEvent.click(screen.getByTestId('clearStartDate')); | ||
expect(screen.getByTestId('startDate').textContent).toBe('null'); | ||
}); | ||
}); |
Oops, something went wrong.