2017-10-07 04:02:02 +00:00
|
|
|
import React from 'react'
|
|
|
|
import TestUtils from 'react-dom/test-utils'
|
2018-04-30 01:57:52 +00:00
|
|
|
|
|
|
|
import data from '../data/all.json'
|
|
|
|
import { NimblePicker } from '../src/components'
|
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 = {}) => {
|
2018-04-30 01:57:52 +00:00
|
|
|
const defaultProps = { data }
|
|
|
|
return renderIntoDocument(<NimblePicker {...defaultProps} {...props} />)
|
2017-11-09 06:41:57 +00:00
|
|
|
}
|
|
|
|
|
2018-04-30 01:57:52 +00:00
|
|
|
describe('NimblePicker', () => {
|
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', () => {
|
2018-03-27 18:51:26 +00:00
|
|
|
subject = render({ emojisToShowFilter: (unified) => false })
|
2017-10-07 04:02:02 +00:00
|
|
|
expect(subject.categories.length).toEqual(2)
|
|
|
|
})
|
2017-12-22 03:24:36 +00:00
|
|
|
|
|
|
|
it('maintains category ids after it is filtered', () => {
|
2018-03-27 18:51:26 +00:00
|
|
|
subject = render({ emojisToShowFilter: (emoji) => true })
|
2018-01-09 20:20:18 +00:00
|
|
|
const categoriesWithIds = subject.categories.filter(
|
2018-03-27 18:51:26 +00:00
|
|
|
(category) => category.id,
|
2018-01-09 20:20:18 +00:00
|
|
|
)
|
|
|
|
expect(categoriesWithIds.length).toEqual(10)
|
|
|
|
})
|
2017-10-07 04:02:02 +00:00
|
|
|
})
|
|
|
|
})
|