Skip to content

Commit fdcced0

Browse files
authored
Fix publish date filter all option not working (#1189)
1 parent c4a29af commit fdcced0

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

src/PresentationalComponents/Filters/PublishDateFilter.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const publishDateFilter = (apply, currentFilter = {}) => {
77
let { public_date: currentValue } = currentFilter;
88

99
const filterByPublicDate = value => {
10-
apply({ filter: { public_date: (value !== 'all' && value) || '' } });
10+
apply({ filter: { public_date: value === 'all' ? '' : value } });
1111
};
1212

1313
return {
@@ -18,7 +18,7 @@ const publishDateFilter = (apply, currentFilter = {}) => {
1818
filterByPublicDate(value);
1919
},
2020
items: publicDateOptions,
21-
value: currentValue,
21+
value: currentValue ?? 'all',
2222
placeholder: intl.formatMessage(messages.labelsFiltersPublishDatePlaceholder)
2323
}
2424
};

src/PresentationalComponents/Filters/PublishDateFilter.test.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ import publishDateFilter from './PublishDateFilter';
33
const apply = jest.fn();
44
const currentFilter = { public_date: 'filter' };
55

6-
describe('PublishDateFitler', () => {
7-
it('Should set currentValue to zero and init', () => {
6+
describe('PublishDateFilter', () => {
7+
it('Should set currentValue to "all" by default', () => {
88
const response = publishDateFilter(apply);
9-
expect(response.filterValues.value).toEqual(undefined);
9+
expect(response.filterValues.value).toEqual('all');
1010
expect(response.label).toEqual('Publish date');
1111
expect(response.type).toEqual('radio');
1212
});
@@ -17,10 +17,10 @@ describe('PublishDateFitler', () => {
1717
expect(apply).toHaveBeenCalledWith({ filter: { public_date: 'testValue' } });
1818
});
1919

20-
it('Should call apply with empty string ', () => {
20+
it('Should call apply with undefined', () => {
2121
const response = publishDateFilter(apply);
2222
response.filterValues.onChange();
23-
expect(apply).toHaveBeenCalledWith({ filter: { public_date: '' } });
23+
expect(apply).toHaveBeenCalledWith({ filter: { public_date: undefined } });
2424
});
2525
});
2626
/* eslint-enable */

0 commit comments

Comments
 (0)