Skip to content

Commit

Permalink
saving
Browse files Browse the repository at this point in the history
  • Loading branch information
Crystal Ngai committed Mar 9, 2021
1 parent ef16e19 commit 6b01e99
Show file tree
Hide file tree
Showing 7 changed files with 207 additions and 133 deletions.
142 changes: 139 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"eslint-plugin-react": "^7.21.5",
"eslint-plugin-react-hooks": "^4.2.0",
"jest": "^26.6.3",
"next-page-tester": "^0.23.0",
"prettier": "^2.2.1",
"typescript": "^4.1.3"
}
Expand Down
11 changes: 0 additions & 11 deletions src/__tests__/index.test.jsx

This file was deleted.

65 changes: 65 additions & 0 deletions src/__tests__/index.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import React from "react";
// import { getPage } from "next-page-tester";
import { render, screen } from "@testing-library/react";
import { breadcrumbTitles } from "../constants/labels";
import { searchFields } from "../constants/fields";
import Subjects from "~/config/subjectListConfig";
import LandingPage from "../pages/index";

describe("Renders Landing Page", () => {
beforeEach(async () => {
render(<LandingPage />);
const blah = await screen.findByText("Digital Research Books Beta");
console.log("blah", blah);
});
// test("Renders NYPL header", () => {});
test("Breadcrumbs link to homepage", () => {
expect(
screen.getByRole("link", { name: breadcrumbTitles.home })
).toHaveAttribute("href", "/");
});
test("Shows Heading", () => {
expect(
screen.getByRole("heading", { name: "Digital Research Books Beta" })
).toBeInTheDocument();
});
describe("Landing Page Searchbar", () => {
test("Searchbar select defaults to 'keyword'", () => {
expect(screen.getByRole("combobox")).toHaveValue(searchFields[0]);
});
test("Searchbar has the correct options", () => {
const options = screen.getAllByRole("option");
expect(options[0]).toHaveValue(searchFields[0]);
expect(options[1]).toHaveValue(searchFields[1]);
expect(options[2]).toHaveValue(searchFields[2]);
expect(options[3]).toHaveValue(searchFields[3]);
});
test("Searchbar has empty input", () => {
expect(screen.getByRole("textbox")).toBeInTheDocument;
});
test("Shows link to Advanced Search", () => {
expect(screen.getByText("Advanced Search").closest("a").href).toContain(
"/advanced-search"
);
});
});
test("Shows Search Examples", () => {
expect(screen.getByText("Search Examples")).toBeInTheDocument();
Subjects.forEach((sub) => {
expect(screen.getByText(sub.text)).toBeInTheDocument();
expect(screen.getByText(sub.text).closest("a").href).toContain(
"/search?queries="
);
});
});
test("Renders NYPL footer", () => {});
});

describe("Search using Landing Page Searchbar", () => {
beforeEach(async () => {
const { render } = await getPage({ route: "/" });
render();
});
test("Searching with a field and value calls Search api", () => {});
test("Searching with no search term shows error", () => {});
});
Loading

0 comments on commit 6b01e99

Please sign in to comment.