emoji-mart-lazyload/spec/picker-spec.js

48 lines
1.2 KiB
JavaScript
Raw Normal View History

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-10-07 04:02:02 +00:00
const { click } = TestUtils.Simulate
const {
renderIntoDocument,
scryRenderedComponentsWithType,
findRenderedComponentWithType,
2017-10-07 04:02:02 +00:00
} = TestUtils
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
it('works', () => {
2017-10-07 04:02:02 +00:00
subject = render()
expect(subject).toBeDefined()
})
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)
})
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
})
})