Last active
October 31, 2019 11:13
-
-
Save gildniy/c815a960bd98a24ee57bed6e0983c5c9 to your computer and use it in GitHub Desktop.
Testing a React Functional Component using Enzyme
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import {shallow} from "enzyme"; | |
const numbersArr = ["One", "Two", "Three"]; | |
const Count123array = () => ( | |
<div className="my-text"> | |
{numbersArr[1]} | |
</div> | |
); | |
describe("['One', 'Two', 'Three']", () => { | |
test("Should have 'Two' as innerText", () => { | |
const wrapper = shallow(<Count123array/>); | |
const myText = wrapper.find(".my-text"); | |
expect(myText.exists()).toBe(true); | |
expect(myText.text()).toBe("Two"); | |
}) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment