Skip to content

Instantly share code, notes, and snippets.

@ProfAvery
Created July 17, 2024 23:55
Show Gist options
  • Save ProfAvery/c3e69ff4364f4f9d67f6afcb585565ee to your computer and use it in GitHub Desktop.
Save ProfAvery/c3e69ff4364f4f9d67f6afcb585565ee to your computer and use it in GitHub Desktop.
Updated Listing 8-26 - Summer 2024 AMSE Bootcamp
/**
* @jest-environment jsdom
*/
import { act, render, fireEvent } from "@testing-library/react";
import PageComponentWeather from "../../../pages/components/weather";
describe("PageComponentWeather", () => {
test("renders correctly", async () => {
let component: any;
await act(async () => {
component =
await render(<PageComponentWeather></PageComponentWeather>);
});
expect(component.asFragment()).toMatchSnapshot();
});
test("clicks the h1 element and updates the state", async () => {
let component: any;
await act(async () => {
component = await render(<PageComponentWeather></PageComponentWeather>);
});
fireEvent.click(component.container.querySelector("h1"));
expect(component.asFragment()).toMatchSnapshot();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment