-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🔒wrote preliminary login function and tests
- Loading branch information
1 parent
481bcec
commit 3ee4f56
Showing
5 changed files
with
69 additions
and
13 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,3 +1,5 @@ | ||
DATABASE_URL="postgres://postgres:postgres@localhost:5432" | ||
DIRECT_URL="postgres://postgres:postgres@localhost:5432" | ||
NODE_ENV=test | ||
NODE_ENV=test | ||
REDIS_PORT=6380 | ||
SESSION_SECRET=notsecret |
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
This file was deleted.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
//test/sample.test.ts | ||
import { expect, test, vi, describe } from "vitest"; // 👈🏻 Added the `vi` import | ||
import prisma from "../src/prisma"; | ||
import request from "supertest"; | ||
import app from "../src/index"; | ||
|
||
describe("Tests", () => { | ||
test("register test", async () => { | ||
const { status, body } = await request(app).post("/auth/register").send({ | ||
username: "shinjisatoo", | ||
password: "testpassword", | ||
email: "[email protected]", | ||
userType: "ATTENDEE", | ||
}); | ||
|
||
const newUser = await prisma.user.findFirst({ | ||
where: { | ||
email: "[email protected]", | ||
}, | ||
}); | ||
|
||
expect(status).toBe(201); | ||
expect(newUser).not.toBeNull(); | ||
expect(body.newUser).toStrictEqual({ | ||
username: "shinjisatoo", | ||
id: newUser?.id, | ||
}); | ||
}); | ||
|
||
test("Email already exists", async () => { | ||
await request(app).post("/auth/register").send({ | ||
username: "shinjisatoo", | ||
password: "testpassword", | ||
email: "[email protected]", | ||
userType: "ATTENDEE", | ||
}); | ||
|
||
const { status, body } = await request(app).post("/auth/register").send({ | ||
username: "shinjisatoo2", | ||
password: "testpassword2", | ||
email: "[email protected]", | ||
userType: "ATTENDEE", | ||
}); | ||
|
||
expect(status).toBe(400); | ||
}) | ||
}); |