Skip to content

Commit

Permalink
Merge pull request #46 from hack4impact-calpoly/19-connect-backend-fo…
Browse files Browse the repository at this point in the history
…r-new-tree-form

feat: connected backend to form
  • Loading branch information
elhagen13 authored Mar 1, 2025
2 parents a90ac01 + 19d2cbd commit de94ed9
Show file tree
Hide file tree
Showing 9 changed files with 233 additions and 36 deletions.
2 changes: 1 addition & 1 deletion .env
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
40 changes: 39 additions & 1 deletion __tests__/TreeEntryForm.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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", () => {
Expand Down Expand Up @@ -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.",
};
});
Loading

0 comments on commit de94ed9

Please sign in to comment.