Skip to content

Instantly share code, notes, and snippets.

@scriptschat
Created May 25, 2020 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scriptschat/8cbecd2cb7ffc29efb42271934fe1b52 to your computer and use it in GitHub Desktop.
Save scriptschat/8cbecd2cb7ffc29efb42271934fe1b52 to your computer and use it in GitHub Desktop.
import { shallow } from "enzyme";
import React from "react";
import { findByTestAttribute } from "../test/utils/testUtils";
import workouts from "./data/worksouts.json";
import Workout from "./Workout";
function setup() {
return shallow(<Workout {...workouts[0]} />);
}
describe("Workout renders", () => {
test("without error", () => {
const wrapper = setup();
const container = findByTestAttribute(wrapper, "workout-container");
expect(container.exists()).toBe(true);
expect(container.length).toBe(1);
});
test("workout name, target and group", () => {
const wrapper = setup();
const workoutName = findByTestAttribute(wrapper, "workout-name");
expect(workoutName.exists()).toBe(true);
expect(workoutName.text()).toContain("Bench Press");
const workoutTarget = findByTestAttribute(wrapper, "workout-target");
expect(workoutTarget.exists()).toBe(true);
expect(workoutTarget.text()).toContain("Chest");
const workoutGroup = findByTestAttribute(wrapper, "workout-group");
expect(workoutGroup.exists()).toBe(true);
expect(workoutGroup.text()).toContain("Upper Body");
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment