Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
owens1127 committed Dec 2, 2024
1 parent dbedd4e commit c8637d1
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 26 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/bun-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ jobs:
- uses: ./.github/actions/setup-bun

- name: Apply database schema
run: bun db:push
run: |
bun prisma db push \
--schema=./packages/db/prisma/schema.prisma
- name: Run tests
run: bun test
2 changes: 1 addition & 1 deletion apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
"typecheck": "tsc --noEmit --emitDeclarationOnly false"
},
"dependencies": {
"@good-dog/tailwind": "workspace:*",
"@good-dog/components": "workspace:*",
"@good-dog/env": "workspace:*",
"@good-dog/tailwind": "workspace:*",
"@good-dog/trpc": "workspace:*",
"@good-dog/ui": "workspace:*",
"next": "14.2.18",
Expand Down
Binary file modified bun.lockb
Binary file not shown.
46 changes: 24 additions & 22 deletions tests/frontend/signin.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import { fireEvent, screen } from "@testing-library/react";
import { afterEach, beforeAll, expect, test } from "bun:test";
import { afterEach, beforeAll, describe, expect, test } from "bun:test";

import { SignInForm } from "@good-dog/components/registration";

Expand All @@ -9,35 +9,37 @@ import { renderWithShell } from "./util";

const mockNavigation = new MockNextNavigation();

beforeAll(async () => {
await mockNavigation.apply();
});
describe("SignInForm", () => {
beforeAll(async () => {
await mockNavigation.apply();
});

afterEach(() => {
mockNavigation.clear();
});
afterEach(() => {
mockNavigation.clear();
});

test("Renders the sign in form with email and password fields", () => {
renderWithShell(<SignInForm />);
test("Renders the sign in form with email and password fields", () => {
renderWithShell(<SignInForm />);

const signInForm = screen.getByRole("form");
expect(signInForm).toBeInTheDocument();
const signInForm = screen.getByRole("form");
expect(signInForm).toBeInTheDocument();

const emailField = screen.getByLabelText(/email/i);
expect(emailField).toBeInTheDocument();
const emailField = screen.getByLabelText(/email/i);
expect(emailField).toBeInTheDocument();

const passwordField = screen.getByLabelText(/password/i);
expect(passwordField).toBeInTheDocument();
const passwordField = screen.getByLabelText(/password/i);
expect(passwordField).toBeInTheDocument();

const submitButton = screen.getByRole("button", { name: /continue/i });
const submitButton = screen.getByRole("button", { name: /continue/i });

fireEvent.change(emailField, { target: { value: "test@example.com" } });
fireEvent.change(passwordField, { target: { value: "password123" } });
fireEvent.change(emailField, { target: { value: "test@example.com" } });
fireEvent.change(passwordField, { target: { value: "password123" } });

expect(emailField).toHaveValue("test@example.com");
expect(passwordField).toHaveValue("password123");
expect(emailField).toHaveValue("test@example.com");
expect(passwordField).toHaveValue("password123");

fireEvent.click(submitButton);
fireEvent.click(submitButton);

// TODO: we need to build out an app shell that allows us to test trpc mutations/queries
// TODO: we need to build out an app shell that allows us to test trpc mutations/queries
});
});
12 changes: 10 additions & 2 deletions tests/mocks/MockNextNavigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,19 @@ export class MockNextNavigation {
this.useParams.mockClear();
this.usePathname.mockClear();
this.useSearchParams.mockClear();
this.useRouter.mockClear();
this.useRouter.clear();
}

readonly useSearchParams = mock();
readonly usePathname = mock();
readonly useRouter = mock();
readonly useRouter = new MockRouter();
readonly useParams = mock();
}

class MockRouter {
clear() {
this.push.mockClear();
}

readonly push = mock();
}
1 change: 1 addition & 0 deletions tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"@testing-library/react": "^16.0.1",
"@types/bun": "^1.1.10",
"eslint": "9.10.0",
"next": "14.2.18",
"prettier": "3.2.5",
"typescript": "5.4.5",
"zod": "3.23.8"
Expand Down

0 comments on commit c8637d1

Please sign in to comment.