Skip to content

Commit

Permalink
refactor(expandcollapse): Convert back from a set to an array when ca…
Browse files Browse the repository at this point in the history
…lling onToggle callbacks
  • Loading branch information
ryanoglesby08 committed Nov 6, 2017
1 parent 9e16914 commit 5f9e48b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 3 additions & 1 deletion src/components/ExpandCollapse/ExpandCollapse.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import React from 'react'
import PropTypes from 'prop-types'
import { childrenOfType } from 'airbnb-prop-types'

import Set from 'core-js/es6/set'
import arrayFrom from 'core-js/fn/array/from'

import safeRest from '../../utils/safeRest'
import { isEqual } from '../../utils/sets'
Expand Down Expand Up @@ -45,7 +47,7 @@ class ExpandCollapse extends React.Component {
},
() => {
if (onToggle) {
onToggle(this.state.panels)
onToggle(arrayFrom(this.state.panels))
}
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,14 +168,13 @@ describe('ExpandCollapse', () => {
)

clickPanel('panel-1')
// TODO: Can I convert back to an array?
expect(onToggle).toHaveBeenCalledWith(new Set(['panel-1']))
expect(onToggle).toHaveBeenCalledWith(['panel-1'])

// TODO: Can I just clear the onToggle mock?
// TODO: Can I clear JUST the onToggle mock?
jest.clearAllMocks()

clickPanel('panel-2')
expect(onToggle).toHaveBeenCalledWith(new Set(['panel-1', 'panel-2']))
expect(onToggle).toHaveBeenCalledWith(['panel-1', 'panel-2'])
})
})

Expand Down

0 comments on commit 5f9e48b

Please sign in to comment.