вот так добавляю ref
setinputTaskItemName = (ref) => {
this.inputTaskItemName = ref;
};
<input type="text" className="task-item-name" name="title" placeholder="Enter task item name" required="" ref={this.setinputTaskItemName} />
вот так тестирую
it('should render Input', () => {
expect(component.find(".task-item-name").at(0)).toHaveLength(1);
expect(component.instance().inputTaskItemName).toBeTruthy();
})
вот такая ошибка
● FormTaskItem New › should render Input
TypeError: component.ref is not a function
● FormTaskItem New › should render Input
expect(received).toBeTruthy()
Received: undefined
49 | it('should render Input', () => {
50 | expect(component.find(".task-item-name").at(0)).toHaveLength(1);
> 51 | expect(component.instance().inputTaskItemName).toBeTruthy();
| ^
52 | })
53 |