Skip to content

Commit

Permalink
Modifying dashboard tests
Browse files Browse the repository at this point in the history
  • Loading branch information
elric97 committed Nov 29, 2021
1 parent fdc1efc commit d80d8f2
Showing 1 changed file with 40 additions and 9 deletions.
49 changes: 40 additions & 9 deletions src/__tests__/Dashboard.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -32,35 +33,65 @@ describe("Dashboard tests", () => {
const history = createMemoryHistory();
history.push("/:id");

const { getByTestId, getByText, getByPlaceholderText } = render(
<RRouter history={history}>
<Dashboard />
</RRouter>
const { getByTestId, getByText, getByRole, getByPlaceholderText } = render(
<div>
<RRouter history={history}>
<Login />
</RRouter>
</div>
);

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 (
<RRouter history={history}>
<Dashboard />
</RRouter>
);
// 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();
});

Expand Down

0 comments on commit d80d8f2

Please sign in to comment.