generated from hack4impact-calpoly/nextjs-app-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #46 from hack4impact-calpoly/19-connect-backend-fo…
…r-new-tree-form feat: connected backend to form
- Loading branch information
Showing
9 changed files
with
233 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# create local copy of this file and rename to .env.local | ||
# make sure to add .env.local to .gitignore!! | ||
MONGO_URI={mongo-uri-here} | ||
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=pk_test_YW11c2luZy1zZWFzbmFpbC01OS5jbGVyay5hY2NvdW50cy5kZXYk | ||
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=pk_test_YW11c2luZy1zZWFzbmFpbC01OS5jbGVyay5hY2NvdW50cy5kZXYk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,12 +2,33 @@ | |
* @jest-environment jsdom | ||
*/ | ||
|
||
import React from "react"; | ||
import React, { ReactNode } from "react"; | ||
import "@testing-library/jest-dom"; | ||
import { render, screen, fireEvent, waitFor } from "@testing-library/react"; | ||
import userEvent from "@testing-library/user-event"; | ||
import { treeIssues } from "@/app/newTreeForm/tree-form-data"; | ||
import TreeEntryForm from "@/app/newTreeForm/page"; | ||
import { ClerkProvider } from "@clerk/nextjs"; | ||
import mockRouter from "next-router-mock"; | ||
|
||
jest.mock("@clerk/nextjs", () => ({ | ||
ClerkProvider: ({ children }: { children: React.ReactNode }) => <div>{children}</div>, | ||
useUser: () => ({ | ||
user: { | ||
primaryEmailAddress: "[email protected]", | ||
fullName: "Test User", | ||
}, | ||
isSignedIn: true, | ||
}), | ||
})); | ||
|
||
jest.mock("mongoose", () => ({ | ||
Types: { | ||
Decimal128: { | ||
fromString: jest.fn((value) => value), // Mock Decimal128.fromString | ||
}, | ||
}, | ||
})); | ||
|
||
describe("TreeEntryForm", () => { | ||
it("renders tree type section", () => { | ||
|
@@ -164,4 +185,21 @@ describe("TreeEntryForm", () => { | |
|
||
expect(screen.getByRole("button", { name: /Submit/i })); | ||
}); | ||
|
||
const mockUser = { | ||
primaryEmailAddress: "[email protected]", | ||
}; | ||
|
||
const mockFormData = { | ||
treeLocation: ["37.7749", "-122.4194"], // Example GPS coordinates | ||
treeType: "Valley Oak", | ||
treeSpecs: { | ||
treeHeight: 20, | ||
canopySpread: 100, | ||
trunkDBH: "2.5", | ||
}, | ||
treeHealth: 8, | ||
treeIssues: ["Dead branches"], | ||
fieldNotes: "Healthy tree with minor issues.", | ||
}; | ||
}); |
Oops, something went wrong.