import React from "react"
import TreeSelect from "."
import renderer from "react-test-renderer"
test("<TreeSelect/> renders correctly", () => {
const nodes = [{ id: 1, label: "it works" }]
const component = renderer.create(<TreeSelect nodes={nodes} />)
expect(component.toJSON()).toMatchSnapshot()
})
test("<TreeSelect/> renders filtered nodes correctly", () => {
const nodes = [{ id: 1, label: "it works" }, { id: 2, label: "#1 hidden, #2 not hidden" }]
const component = renderer.create(<TreeSelect nodes={nodes} />)
const filterInput = component.root.findByType("input")
filterInput.props.onChange({ target: { value: "it works" } })
expect(component.toJSON()).toMatchSnapshot()
const clearBtn = component.root.findByType("button")
clearBtn.props.onClick()
expect(component.toJSON()).toMatchSnapshot()
})
|