Skip to content

Instantly share code, notes, and snippets.

@trooperandz
Last active August 14, 2022 17:12
Show Gist options
  • Save trooperandz/e8fb960ed8736974cb97f0de2e8063e2 to your computer and use it in GitHub Desktop.
Save trooperandz/e8fb960ed8736974cb97f0de2e8063e2 to your computer and use it in GitHub Desktop.
Testing philosophies engineer test example
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