February 2019
Beginner
694 pages
18h 4m
English
As mentioned earlier, our React application starts with an initial state. The title property is set, the SelectedItem property is set, and the application should render three buttons to the screen. Let's now extend our test suite to check for these elements. Firstly, we will test that the SelectedItem property has been rendered to the DOM correctly, as follows:
it('should render SelectedItem property', () => {
let domNode = ReactDOM.findDOMNode(renderer) as Element;
let selectedItem = domNode.querySelector("#selectedItem") as Element;
expect(selectedItem.innerHTML).toContain("0 -None Selected");
});
Here, we have used the same pattern as our earlier test to find a DOM element with the id of selectedItem. We are then checking ...
Read now
Unlock full access