Just what it says. Some example code:
let wrapper = shallow();
const b = wrapper
I ran into this post when searching for ways to select all/some of the text within a textarea
within jest
and enzyme
. For those who are looking for the same thing, you do can the following to select some text (provided you already know the length):
let wrapper;
let textareaNode;
beforeEach(() => {
wrapper = mount();
textareaNode = () => wrapper.find("textarea").getDOMNode();
});
it("selects all of the select within the given range", () => {
textareaNode().setSelectionRange(0, 6);
wrapper.find("button").simulate("click"); // this would delete the selection via a ref
expect(wrapper.find("textarea").props().value).toEqual("world");
});