Skip to content

Commit

Permalink
Added the render test (issue #1)
Browse files Browse the repository at this point in the history
  • Loading branch information
atlasharry committed Dec 6, 2023
1 parent ea5dd30 commit bde7a05
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions src/render.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import React from "react";
// The React testing library simulates the DOM.
import { render, screen, fireEvent } from "@testing-library/react";
import Login from "./login";
import Register from "./Register";
import Viewsong from "./Viewsong";
import Songdisplay from "./Songdisplay.js";
import Updatesong from "./Updatesong";
import Deletesong from "./Deletesong";
import Createsong from "./Createsong";
import { BrowserRouter } from "react-router-dom";
// The jest-dom lets you analyze the rendered simulation.
import "@testing-library/jest-dom";

// Rendering test for the register page
test("Register Login", () => {
render(
<BrowserRouter>
<Register />
</BrowserRouter>
);

const usernameInput = screen.getByPlaceholderText("Username");
const passwordInput = screen.getByPlaceholderText("Password");
const registerButton = screen.getByRole("button", { name: /Register/i });

expect(usernameInput).toBeInTheDocument();
expect(passwordInput).toBeInTheDocument();
expect(registerButton).toBeInTheDocument();
});

// Rendering test for the register page
test("Register Rendering", () => {
render(
<BrowserRouter>
<Register />
</BrowserRouter>
);

const usernameInput = screen.getByPlaceholderText("Username");
const passwordInput = screen.getByPlaceholderText("Password");
const confirmPasswordInput = screen.getByPlaceholderText("Confirm Password");

expect(usernameInput).toBeInTheDocument();
expect(passwordInput).toBeInTheDocument();
expect(confirmPasswordInput).toBeInTheDocument();
});

0 comments on commit bde7a05

Please sign in to comment.