Skip to content

Commit

Permalink
fix(SystemsTable): Remove redundant removeFilter call
Browse files Browse the repository at this point in the history
  • Loading branch information
bastilian committed Sep 22, 2023
1 parent 0340bad commit eb9c80e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/Helpers/TableToolbarHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ export const buildActiveFilters = (currentFilters, filterRuleValues = []) => {

export const removeFilters = (chips, apply, reset = false, defaultFilters = {}) => {
if (reset) {
removeFilters(chips, apply);
apply({ ...defaultFilters, page: 1 });
return;
}
Expand Down
10 changes: 10 additions & 0 deletions src/Helpers/TableToolbarHelper.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ const mockGeneralChip = {
const mockApply = jest.fn();

describe('TableToolbarHelper', () => {
afterEach(() => {
jest.clearAllMocks();
});

it('Should handleChangePage apply with provided page', () => {
const testPage = 1;
const testApply = jest.fn();
Expand Down Expand Up @@ -149,6 +153,12 @@ describe('TableToolbarHelper', () => {
expect(mockApply).toHaveBeenCalledWith({ rule_presence: undefined, rule: '', page: 1 });
});

it('Should reset to default filters when given and reset is ture', () => {
removeFilters([mockGeneralChip], mockApply, true, { rule_presence: "true" });
expect(mockApply).toHaveBeenCalledTimes(1);
expect(mockApply).toHaveBeenCalledWith({ rule_presence: 'true', page: 1 });
});

it('Should remove search filters and multi value filters with only one value safely', () => {
const mockSingleValueChips = [
{
Expand Down

0 comments on commit eb9c80e

Please sign in to comment.