All files / TreeSelect index.tests.js

0% Statements 0/16
100% Branches 0/0
0% Functions 0/2
0% Lines 0/16
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22                                           
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()
})