Skip to content

Commit

Permalink
Assign selected facets as an empty array if null (#15)
Browse files Browse the repository at this point in the history
* Assign selected facets as an empty array if null

* Update depdendencies and fix snapshot tests

Co-authored-by: amunozpomer <amunoz@ebi.ac.uk>
  • Loading branch information
lingyun1010 and alfonsomunozpomer committed Sep 10, 2020
1 parent 69ddeeb commit f93a6ad
Show file tree
Hide file tree
Showing 18 changed files with 5,962 additions and 3,159 deletions.
4 changes: 2 additions & 2 deletions packages/scxa-faceted-search-results/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"extends": "eslint-config-gene-expression"
}
"extends": "@ebi-gene-expression-group"
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Enzyme from 'enzyme'
import { mount } from 'enzyme'
import Adapter from 'enzyme-adapter-react-16'

import {episodes, ExperimentTableHeader, ExperimentTableCard} from './TestUtils'
import { episodes, ExperimentTableHeader, ExperimentTableCard } from './TestUtils'

import FacetedSearchContainer from '../src/FacetedSearchContainer'
import FilterSidebar from '../src/FilterSidebar'
Expand Down Expand Up @@ -66,7 +66,23 @@ describe(`FacetedSearchContainer`, () => {
})

test(`matches snapshot`, () => {
const tree = renderer.create(<FacetedSearchContainer {...props} />).toJSON()
// The latest version of React Tooltip at the time of writing creates dynamically UID-like generated class names
// that break snapshot tests, so we don’t want descriptions
const withoutTooltips =
episodes.map(episode => (
{
element: episode.element,
facets: episode.facets.map(facet => (
{
group: facet.group,
value: facet.value,
label: facet.label
}
))
}
))

const tree = renderer.create(<FacetedSearchContainer {...props} results={withoutTooltips} />).toJSON()
expect(tree).toMatchSnapshot()
})
})
2 changes: 1 addition & 1 deletion packages/scxa-faceted-search-results/__test__/TestUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,4 +241,4 @@ const episodes = [
}
]

export {getRandomInt, vindicators, episodes, ExperimentTableCard, ExperimentTableHeader}
export { getRandomInt, vindicators, episodes, ExperimentTableCard, ExperimentTableHeader }
Original file line number Diff line number Diff line change
Expand Up @@ -61,40 +61,26 @@ exports[`FacetedSearchContainer matches snapshot 1`] = `
>
<h4>
Guest character
<sup>
<span
className="icon icon-generic"
data-html={true}
data-icon="i"
data-tip="<span>Guest characters that tag along for the<br>adventures in this episodes</span>"
style={
Object {
"color": "lightgrey",
"fontSize": "smaller",
}
}
/>
</sup>
</h4>
<div
className="css-1pcexqc-container"
className=" css-2b097c-container"
onKeyDown={[Function]}
>
<div
className="css-12emboz"
className=" css-15r8ym2-Control"
onMouseDown={[Function]}
onTouchEnd={[Function]}
>
<div
className="css-1hwfws3"
className=" css-g1d714-ValueContainer"
>
<div
className="css-151xaom-placeholder"
className=" css-1wa3eu0-placeholder"
>
Select...
</div>
<div
className="css-1g6gooi"
className="css-b8ldur-Input"
>
<div
className=""
Expand Down Expand Up @@ -152,10 +138,10 @@ exports[`FacetedSearchContainer matches snapshot 1`] = `
</div>
</div>
<div
className="css-1wy0on6"
className=" css-1hb7zxy-IndicatorsContainer"
>
<span
className="sc-bxivhb iCJrRm"
className="sc-AxhCb ifMswC"
cx={[Function]}
/>
</div>
Expand All @@ -167,40 +153,26 @@ exports[`FacetedSearchContainer matches snapshot 1`] = `
>
<h4>
Planet
<sup>
<span
className="icon icon-generic"
data-html={true}
data-icon="i"
data-tip="<span>Planets where events in this episode take<br>place</span>"
style={
Object {
"color": "lightgrey",
"fontSize": "smaller",
}
}
/>
</sup>
</h4>
<div
className="css-1pcexqc-container"
className=" css-2b097c-container"
onKeyDown={[Function]}
>
<div
className="css-12emboz"
className=" css-15r8ym2-Control"
onMouseDown={[Function]}
onTouchEnd={[Function]}
>
<div
className="css-1hwfws3"
className=" css-g1d714-ValueContainer"
>
<div
className="css-151xaom-placeholder"
className=" css-1wa3eu0-placeholder"
>
Select...
</div>
<div
className="css-1g6gooi"
className="css-b8ldur-Input"
>
<div
className=""
Expand Down Expand Up @@ -258,10 +230,10 @@ exports[`FacetedSearchContainer matches snapshot 1`] = `
</div>
</div>
<div
className="css-1wy0on6"
className=" css-1hb7zxy-IndicatorsContainer"
>
<span
className="sc-bxivhb iCJrRm"
className="sc-AxhCb ifMswC"
cx={[Function]}
/>
</div>
Expand All @@ -277,16 +249,16 @@ exports[`FacetedSearchContainer matches snapshot 1`] = `
</h4>
<div
className="sc-htpNat jYhomY"
className="sc-AxiKw ivgkfy"
>
<div
className="sc-bdVaJa edgMnc"
className="sc-AxjAm feCCqm"
onClick={[Function]}
>
Meow
</div>
<div
className="sc-bwzfXH laSsVf"
className="sc-AxirZ gEVUAG"
onClick={[Function]}
>
Wow wow
Expand Down Expand Up @@ -329,9 +301,5 @@ exports[`FacetedSearchContainer matches snapshot 1`] = `
</div>
</div>
</div>
<div
className="__react_component_tooltip place-top type-dark "
data-id="tooltip"
/>
</div>
`;
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ exports[`FilterList matches snapshot 1`] = `
</h4>
<div
className="sc-htpNat jYhomY"
className="sc-AxiKw ivgkfy"
>
<div
className="sc-bdVaJa edgMnc"
className="sc-AxjAm feCCqm"
onClick={[Function]}
>
Meow
</div>
<div
className="sc-bwzfXH laSsVf"
className="sc-AxirZ gEVUAG"
onClick={[Function]}
>
Wow wow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,24 +72,24 @@ Array [
</sup>
</h4>
<div
className="css-1pcexqc-container"
className=" css-2b097c-container"
onKeyDown={[Function]}
>
<div
className="css-12emboz"
className=" css-15r8ym2-Control"
onMouseDown={[Function]}
onTouchEnd={[Function]}
>
<div
className="css-1hwfws3"
className=" css-g1d714-ValueContainer"
>
<div
className="css-151xaom-placeholder"
className=" css-1wa3eu0-placeholder"
>
Select...
</div>
<div
className="css-1g6gooi"
className="css-b8ldur-Input"
>
<div
className=""
Expand Down Expand Up @@ -147,10 +147,10 @@ Array [
</div>
</div>
<div
className="css-1wy0on6"
className=" css-1hb7zxy-IndicatorsContainer"
>
<span
className="sc-bxivhb iCJrRm"
className="sc-AxhCb ifMswC"
cx={[Function]}
/>
</div>
Expand Down Expand Up @@ -178,24 +178,24 @@ Array [
</sup>
</h4>
<div
className="css-1pcexqc-container"
className=" css-2b097c-container"
onKeyDown={[Function]}
>
<div
className="css-12emboz"
className=" css-15r8ym2-Control"
onMouseDown={[Function]}
onTouchEnd={[Function]}
>
<div
className="css-1hwfws3"
className=" css-g1d714-ValueContainer"
>
<div
className="css-151xaom-placeholder"
className=" css-1wa3eu0-placeholder"
>
Select...
</div>
<div
className="css-1g6gooi"
className="css-b8ldur-Input"
>
<div
className=""
Expand Down Expand Up @@ -253,10 +253,10 @@ Array [
</div>
</div>
<div
className="css-1wy0on6"
className=" css-1hb7zxy-IndicatorsContainer"
>
<span
className="sc-bxivhb iCJrRm"
className="sc-AxhCb ifMswC"
cx={[Function]}
/>
</div>
Expand All @@ -270,24 +270,24 @@ Array [
Show
</h4>
<div
className="css-1pcexqc-container"
className=" css-2b097c-container"
onKeyDown={[Function]}
>
<div
className="css-12emboz"
className=" css-15r8ym2-Control"
onMouseDown={[Function]}
onTouchEnd={[Function]}
>
<div
className="css-1hwfws3"
className=" css-g1d714-ValueContainer"
>
<div
className="css-151xaom-placeholder"
className=" css-1wa3eu0-placeholder"
>
Select...
</div>
<div
className="css-1g6gooi"
className="css-b8ldur-Input"
>
<div
className=""
Expand Down Expand Up @@ -345,10 +345,10 @@ Array [
</div>
</div>
<div
className="css-1wy0on6"
className=" css-1hb7zxy-IndicatorsContainer"
>
<span
className="sc-bxivhb iCJrRm"
className="sc-AxhCb ifMswC"
cx={[Function]}
/>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,24 @@ exports[`MultiselectDropdownFacetGroup matches snapshot 1`] = `
</sup>
</h4>
<div
className="css-1pcexqc-container"
className=" css-2b097c-container"
onKeyDown={[Function]}
>
<div
className="css-12emboz"
className=" css-15r8ym2-Control"
onMouseDown={[Function]}
onTouchEnd={[Function]}
>
<div
className="css-1hwfws3"
className=" css-g1d714-ValueContainer"
>
<div
className="css-151xaom-placeholder"
className=" css-1wa3eu0-placeholder"
>
Select...
</div>
<div
className="css-1g6gooi"
className="css-b8ldur-Input"
>
<div
className=""
Expand Down Expand Up @@ -97,10 +97,10 @@ exports[`MultiselectDropdownFacetGroup matches snapshot 1`] = `
</div>
</div>
<div
className="css-1wy0on6"
className=" css-1hb7zxy-IndicatorsContainer"
>
<span
className="sc-bxivhb iCJrRm"
className="sc-AxhCb ifMswC"
cx={[Function]}
/>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react'
import PropTypes from 'prop-types'
import styled from 'styled-components'
import formatNumber from 'format-number'
import EbiSpeciesIcon from 'react-ebi-species'
import EbiSpeciesIcon from '@ebi-gene-expression-group/react-ebi-species'

const _formatNumber = formatNumber()

Expand Down
Loading

0 comments on commit f93a6ad

Please sign in to comment.