fix(FilterBox): treat empty defaultValues as null (#13109)

* fix(FilterBox): treat empty defaultValues as null

* Add a unit test and move constant around
This commit is contained in:
Jesse Yang
2021-02-15 06:35:47 -10:00
committed by GitHub
parent d0b00bc08f
commit 613945a200
6 changed files with 60 additions and 64 deletions

View File

@@ -56,13 +56,25 @@ describe('getFilterConfigsFromFormdata', () => {
});
});
it('should use default value from form_data', () => {
it('should use default value and treat empty defaults as null', () => {
const result = getFilterConfigsFromFormdata({
...testFormdata,
show_sqla_time_column: true,
filter_configs: [
...testFormdata.filter_configs,
{
asc: false,
clearable: true,
column: 'country',
defaultValue: '',
key: 'foo',
multiple: true,
},
],
});
expect(result.columns).toMatchObject({
state: ['CA'],
country: null,
});
});