2017-10-07 04:02:02 +00:00
|
|
|
import React from 'react'
|
|
|
|
import TestUtils from 'react-dom/test-utils'
|
2017-11-09 06:41:57 +00:00
|
|
|
import Picker from '../src/components/picker'
|
2017-02-02 18:43:26 +00:00
|
|
|
|
2017-10-07 04:02:02 +00:00
|
|
|
const { click } = TestUtils.Simulate
|
2017-02-02 18:43:26 +00:00
|
|
|
|
|
|
|
const {
|
|
|
|
renderIntoDocument,
|
|
|
|
scryRenderedComponentsWithType,
|
|
|
|
findRenderedComponentWithType,
|
2017-10-07 04:02:02 +00:00
|
|
|
} = TestUtils
|
2017-02-02 18:43:26 +00:00
|
|
|
|
2017-11-09 06:41:57 +00:00
|
|
|
const render = (props = {}) => {
|
|
|
|
const defaultProps = {}
|
|
|
|
return renderIntoDocument(<Picker {...defaultProps} {...props} />)
|
|
|
|
}
|
|
|
|
|
2017-02-02 18:43:26 +00:00
|
|
|
describe('Picker', () => {
|
2017-10-07 04:02:02 +00:00
|
|
|
let subject
|
2017-02-02 18:43:26 +00:00
|
|
|
|
|
|
|
it('works', () => {
|
2017-10-07 04:02:02 +00:00
|
|
|
subject = render()
|
|
|
|
expect(subject).toBeDefined()
|
|
|
|
})
|
2017-02-02 18:43:26 +00:00
|
|
|
|
2017-02-17 14:47:14 +00:00
|
|
|
describe('categories', () => {
|
|
|
|
it('shows 10 by default', () => {
|
2017-10-07 04:02:02 +00:00
|
|
|
subject = render()
|
|
|
|
expect(subject.categories.length).toEqual(10)
|
|
|
|
})
|
2017-02-17 14:47:14 +00:00
|
|
|
|
|
|
|
it('will not show some based upon our filter', () => {
|
2017-10-07 04:02:02 +00:00
|
|
|
subject = render({ emojisToShowFilter: unified => false })
|
|
|
|
expect(subject.categories.length).toEqual(2)
|
|
|
|
})
|
2017-12-22 03:24:36 +00:00
|
|
|
|
|
|
|
it('maintains category ids after it is filtered', () => {
|
2018-01-09 20:20:18 +00:00
|
|
|
subject = render({ emojisToShowFilter: emoji => true })
|
|
|
|
const categoriesWithIds = subject.categories.filter(
|
|
|
|
category => category.id
|
|
|
|
)
|
|
|
|
expect(categoriesWithIds.length).toEqual(10)
|
|
|
|
})
|
2017-10-07 04:02:02 +00:00
|
|
|
})
|
|
|
|
})
|