Last active
August 14, 2022 17:12
-
-
Save trooperandz/e8fb960ed8736974cb97f0de2e8063e2 to your computer and use it in GitHub Desktop.
Testing philosophies engineer test example
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
describe("EngineerTest", () => { | |
it("Creates the touchable area for the shipment card", () => { | |
const renderedView = renderComponent(); | |
expect(renderedView.type).toBe(TouchableOpacity); | |
expect(renderedView.props.activeOpacity).toBe(0.6); | |
expect(renderedView.props.accessibilityRole).toBe("button"); | |
}); | |
it("Calls useState", () => { | |
renderComponent(); | |
expect(useState).toHaveBeenCalledTimes(3); | |
}); | |
it("Calls useEffect", () => { | |
renderComponent(); | |
expect(useEffect).toHaveBeenCalledTimes(1); | |
}); | |
it("Renders the shipment number", async () => { | |
const renderedView = renderComponent(); | |
const [, , renderedShipment] = renderedView.props.children; | |
expect(renderedShipment.type).toBe(ContainerView); | |
const [, renderedHeading] = renderedShipment.props.children; | |
expect(renderedHeading.type).toBe(ThemedText); | |
expect(renderedHeading.props.style).toStrictEqual({ flexDirection: "row" }); | |
expect(renderedHeading.props.children).toBe("123456"); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment