From d80d8f2bca6f1e24376152a15246e7071ad1fd11 Mon Sep 17 00:00:00 2001 From: elric97 Date: Mon, 29 Nov 2021 18:18:24 -0500 Subject: [PATCH] Modifying dashboard tests --- src/__tests__/Dashboard.tests.js | 49 ++++++++++++++++++++++++++------ 1 file changed, 40 insertions(+), 9 deletions(-) diff --git a/src/__tests__/Dashboard.tests.js b/src/__tests__/Dashboard.tests.js index 51ecfc6..86de31a 100644 --- a/src/__tests__/Dashboard.tests.js +++ b/src/__tests__/Dashboard.tests.js @@ -6,6 +6,7 @@ import "@testing-library/jest-dom/extend-expect"; import Dashboard from "../Components/Dashboard"; import "../setupTests"; +import Login from "../Components/Login"; /** * This file tests Dashboard.js @@ -32,35 +33,65 @@ describe("Dashboard tests", () => { const history = createMemoryHistory(); history.push("/:id"); - const { getByTestId, getByText, getByPlaceholderText } = render( - - - + const { getByTestId, getByText, getByRole, getByPlaceholderText } = render( +
+ + + +
); + const loginb = getByTestId("login_button"); + fireEvent.click(loginb); + + const sub = getByRole("button", { name: /Submit/i }); + expect(sub).toBeInTheDocument(); + + const can = getByRole("button", { name: /Cancel/i }); + expect(can).toBeInTheDocument(); + + fireEvent.click(can); + fireEvent.click(loginb); + + const add = getByTestId("login_inputEmail"); + const ress = "test@test.com"; + + const pass = getByTestId("login_inputPassword"); + const word = "abcd"; + + fireEvent.change(pass, { target: { value: word } }); + fireEvent.change(add, { target: { value: ress } }); + + fireEvent.click(sub); + + render ( + + + + ); // check presence of sort by const popular = getByText(/POPULAR/i); const latest = getByText(/LATEST/i); - const yourproj = getByText(/YOUR PROJECTS-/i); + // const yourproj = getByText(/YOUR PROJECTS-/i); const alertm = getByText(/You are logged in as/i); expect(popular).toBeInTheDocument(); expect(latest).toBeInTheDocument(); - expect(yourproj).toBeInTheDocument(); + // expect(yourproj).toBeInTheDocument(); expect(alertm).toBeInTheDocument(); // header const search = getByPlaceholderText(/Search Features.../i); expect(search).toBeInTheDocument(); - const headproj = getByText("Your Projects"); - expect(headproj).toBeInTheDocument(); + // const headproj = getByText("Your Projects"); + // expect(headproj).toBeInTheDocument(); // uncomment the two lines below in VS Code. // In the terminal, enter: npm run test. // The document should appear. - //const whee = screen.getByText("whee"); + // const whee = screen.getByText("whee"); // expect(whee).toBeInTheDocument(); });