-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[sqllab] fix data grid's instant search function
It looks like any non-string type would break the search feature. of `FilterableTable`
- Loading branch information
1 parent
68dec24
commit 723e77e
Showing
3 changed files
with
46 additions
and
8 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
34 changes: 31 additions & 3 deletions
34
superset/assets/spec/javascripts/components/FilterableTable/FilterableTable_spec.jsx
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,15 +1,43 @@ | ||
import React from 'react'; | ||
import { describe, it } from 'mocha'; | ||
import { expect } from 'chai'; | ||
import { mount } from 'enzyme'; | ||
import FilterableTable from '../../../../javascripts/components/FilterableTable/FilterableTable'; | ||
|
||
describe('FilterableTable', () => { | ||
const mockedProps = { | ||
orderedColumnKeys: [], | ||
data: [], | ||
height: 0, | ||
orderedColumnKeys: ['a', 'b', 'c'], | ||
data: [ | ||
{ a: 'a1', b: 'b1', c: 'c1', d: 0 }, | ||
{ a: 'a2', b: 'b2', c: 'c2', d: 100 }, | ||
], | ||
height: 500, | ||
}; | ||
let wrapper; | ||
beforeEach(() => { | ||
wrapper = mount(<FilterableTable {...mockedProps} />); | ||
}); | ||
it('is valid element', () => { | ||
expect(React.isValidElement(<FilterableTable {...mockedProps} />)).to.equal(true); | ||
}); | ||
it('renders a grid with 2 rows', () => { | ||
expect(wrapper.find('.ReactVirtualized__Grid')).to.have.length(1); | ||
expect(wrapper.find('.ReactVirtualized__Table__row')).to.have.length(2); | ||
}); | ||
it('filters on a string', () => { | ||
const props = { | ||
...mockedProps, | ||
filterText: 'b1', | ||
}; | ||
wrapper = mount(<FilterableTable {...props} />); | ||
expect(wrapper.find('.ReactVirtualized__Table__row')).to.have.length(1); | ||
}); | ||
it('filters on a number', () => { | ||
const props = { | ||
...mockedProps, | ||
filterText: '100', | ||
}; | ||
wrapper = mount(<FilterableTable {...props} />); | ||
expect(wrapper.find('.ReactVirtualized__Table__row')).to.have.length(1); | ||
}); | ||
}); |