mirror of
https://github.com/better-auth/better-auth.git
synced 2026-06-01 03:46:39 -05:00
chore: cleanup
This commit is contained in:
@@ -19,7 +19,7 @@
|
||||
"prisma:normal:push": "prisma db push --schema src/adapters/prisma-adapter/test/normal-tests/schema.prisma",
|
||||
"prisma:number-id:push": "prisma db push --schema src/adapters/prisma-adapter/test/number-id-tests/schema.prisma",
|
||||
"bump": "bumpp",
|
||||
"typecheck": "tsc --noEmit --project tsconfig.declarations.json"
|
||||
"typecheck": "tsc --noEmit"
|
||||
},
|
||||
"main": "./dist/index.cjs",
|
||||
"module": "./dist/index.mjs",
|
||||
|
||||
@@ -23,11 +23,7 @@ describe("adapter test", async () => {
|
||||
await clearDb();
|
||||
});
|
||||
|
||||
const adapter = mongodbAdapter(db, {
|
||||
debugLogs: {
|
||||
isRunningAdapterTests: true,
|
||||
},
|
||||
});
|
||||
const adapter = mongodbAdapter(db);
|
||||
await runAdapterTest({
|
||||
getAdapter: async (customOptions = {}) => {
|
||||
return adapter({
|
||||
|
||||
@@ -16,11 +16,8 @@ import { BetterAuthError } from "./error";
|
||||
|
||||
export type WithJsDoc<T, D> = Expand<T & D>;
|
||||
|
||||
export const betterAuth = <
|
||||
O extends BetterAuthOptions &
|
||||
Record<Exclude<keyof O, keyof BetterAuthOptions>, never>,
|
||||
>(
|
||||
options: O,
|
||||
export const betterAuth = <O extends BetterAuthOptions>(
|
||||
options: O & Record<never, never>,
|
||||
) => {
|
||||
const authContext = init(options as O);
|
||||
const { api } = getEndpoints(authContext, options as O);
|
||||
|
||||
@@ -108,9 +108,6 @@ describe("multi-session", async () => {
|
||||
});
|
||||
await client.multiSession.revoke(
|
||||
{
|
||||
fetchOptions: {
|
||||
headers,
|
||||
},
|
||||
sessionToken: token,
|
||||
},
|
||||
{
|
||||
@@ -119,6 +116,7 @@ describe("multi-session", async () => {
|
||||
`better-auth.session_token=`,
|
||||
);
|
||||
},
|
||||
headers,
|
||||
},
|
||||
);
|
||||
const res = await client.multiSession.listDeviceSessions({
|
||||
|
||||
@@ -235,7 +235,7 @@ export const username = (options?: UsernameOptions) => {
|
||||
},
|
||||
handler: createAuthMiddleware(async (ctx) => {
|
||||
const username = ctx.body.username;
|
||||
if (username) {
|
||||
if (username !== undefined && typeof username === "string") {
|
||||
const minUsernameLength = options?.minUsernameLength || 3;
|
||||
const maxUsernameLength = options?.maxUsernameLength || 30;
|
||||
if (username.length < minUsernameLength) {
|
||||
|
||||
@@ -101,4 +101,14 @@ describe("username", async (it) => {
|
||||
expect(res.error?.status).toBe(422);
|
||||
expect(res.error?.code).toBe("USERNAME_IS_TOO_SHORT");
|
||||
});
|
||||
|
||||
it("should fail on empty username", async () => {
|
||||
const res = await client.signUp.email({
|
||||
email: "email-4@email.com",
|
||||
username: "",
|
||||
password: "new_password",
|
||||
name: "new-name",
|
||||
});
|
||||
expect(res.error?.status).toBe(422);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -350,7 +350,8 @@ describe("Social Providers", async (c) => {
|
||||
},
|
||||
});
|
||||
|
||||
const authUrl = signInRes.data.url;
|
||||
const authUrl = signInRes.data?.url;
|
||||
if (!authUrl) throw new Error("No auth url found");
|
||||
const mockEndpoint = authUrl.replace(
|
||||
"https://accounts.google.com/o/oauth2/auth",
|
||||
"http://localhost:8080/authorize",
|
||||
|
||||
Reference in New Issue
Block a user