Skip to content

Commit

Permalink
add subnav tests
Browse files Browse the repository at this point in the history
  • Loading branch information
charmingduchess committed Oct 6, 2023
1 parent a782551 commit 0275010
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module.exports = {
browser: true,
es2021: true,
node: true,
jest: true
jest: true,
},
extends: [
"next/core-web-vitals",
Expand Down
21 changes: 21 additions & 0 deletions src/components/SubNav/SubNav.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import React from "react"
import { render, screen, act } from "@testing-library/react"
import userEvent from "@testing-library/user-event"
import mockRouter from "next-router-mock"
// this import, as well as its use on line 15 is to avoid the following error:
// TypeError: Cannot use 'in' operator to search for 'beforePopState' in null
import { MemoryRouterProvider } from "next-router-mock/MemoryRouterProvider"

import SubNav from "./SubNav"

jest.mock("next/router", () => jest.requireActual("next-router-mock"))

describe("SubNav", () => {
it("sends you to Subject Heading Explorer", async () => {
render(<SubNav activePage="search" />, {
wrapper: MemoryRouterProvider,
})
const subNavLinks = screen.getAllByRole("link")
expect(subNavLinks).toHaveLength(3)
})
})

0 comments on commit 0275010

Please sign in to comment.