@better-auth/test-utils 1.5.6 → 1.6.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,8 +2,9 @@ import { Logger, testAdapter } from "./test-adapter.mjs";
2
2
  import { InsertRandomFn, TestEntry, TestSuiteStats, createTestSuite } from "./create-test-suite.mjs";
3
3
  import { authFlowTestSuite } from "./suites/auth-flow.mjs";
4
4
  import { enableJoinTests, getNormalTestSuiteTests, normalTestSuite } from "./suites/basic.mjs";
5
+ import { caseInsensitiveTestSuite } from "./suites/case-insensitive.mjs";
5
6
  import { joinsTestSuite } from "./suites/joins.mjs";
6
7
  import { numberIdTestSuite } from "./suites/number-id.mjs";
7
8
  import { transactionsTestSuite } from "./suites/transactions.mjs";
8
9
  import { uuidTestSuite } from "./suites/uuid.mjs";
9
- export { type InsertRandomFn, type Logger, type TestEntry, type TestSuiteStats, authFlowTestSuite, createTestSuite, enableJoinTests, getNormalTestSuiteTests, joinsTestSuite, normalTestSuite, numberIdTestSuite, testAdapter, transactionsTestSuite, uuidTestSuite };
10
+ export { type InsertRandomFn, type Logger, type TestEntry, type TestSuiteStats, authFlowTestSuite, caseInsensitiveTestSuite, createTestSuite, enableJoinTests, getNormalTestSuiteTests, joinsTestSuite, normalTestSuite, numberIdTestSuite, testAdapter, transactionsTestSuite, uuidTestSuite };
package/dist/adapter.mjs CHANGED
@@ -1,11 +1,10 @@
1
1
  import { createTestSuite } from "./create-test-suite.mjs";
2
2
  import { authFlowTestSuite } from "./suites/auth-flow.mjs";
3
3
  import { enableJoinTests, getNormalTestSuiteTests, normalTestSuite } from "./suites/basic.mjs";
4
+ import { caseInsensitiveTestSuite } from "./suites/case-insensitive.mjs";
4
5
  import { joinsTestSuite } from "./suites/joins.mjs";
5
6
  import { numberIdTestSuite } from "./suites/number-id.mjs";
6
7
  import { transactionsTestSuite } from "./suites/transactions.mjs";
7
8
  import { uuidTestSuite } from "./suites/uuid.mjs";
8
- import "./suites/index.mjs";
9
9
  import { testAdapter } from "./test-adapter.mjs";
10
-
11
- export { authFlowTestSuite, createTestSuite, enableJoinTests, getNormalTestSuiteTests, joinsTestSuite, normalTestSuite, numberIdTestSuite, testAdapter, transactionsTestSuite, uuidTestSuite };
10
+ export { authFlowTestSuite, caseInsensitiveTestSuite, createTestSuite, enableJoinTests, getNormalTestSuiteTests, joinsTestSuite, normalTestSuite, numberIdTestSuite, testAdapter, transactionsTestSuite, uuidTestSuite };
@@ -114,5 +114,4 @@ declare const createTestSuite: <Tests extends Record<string, TestEntry>, Additio
114
114
  transformIdOutput?: (id: any) => string | undefined;
115
115
  }) => Promise<void>;
116
116
  //#endregion
117
- export { InsertRandomFn, TestEntry, TestSuiteStats, createTestSuite };
118
- //# sourceMappingURL=create-test-suite.d.mts.map
117
+ export { InsertRandomFn, TestEntry, TestSuiteStats, createTestSuite };
@@ -4,7 +4,6 @@ import { TTY_COLORS } from "@better-auth/core/env";
4
4
  import { generateId } from "@better-auth/core/utils/id";
5
5
  import { betterAuth } from "better-auth";
6
6
  import { test } from "vitest";
7
-
8
7
  //#region src/adapter/create-test-suite.ts
9
8
  /**
10
9
  * Deep equality comparison for BetterAuthOptions.
@@ -456,7 +455,5 @@ const createTestSuite = (suiteName, config, tests) => {
456
455
  };
457
456
  };
458
457
  };
459
-
460
458
  //#endregion
461
459
  export { createTestSuite };
462
- //# sourceMappingURL=create-test-suite.mjs.map
@@ -26,5 +26,4 @@ declare const authFlowTestSuite: (options?: ({
26
26
  transformIdOutput?: ((id: any) => string | undefined) | undefined;
27
27
  }) => Promise<void>;
28
28
  //#endregion
29
- export { authFlowTestSuite };
30
- //# sourceMappingURL=auth-flow.d.mts.map
29
+ export { authFlowTestSuite };
@@ -1,7 +1,6 @@
1
1
  import { createTestSuite } from "../create-test-suite.mjs";
2
2
  import { expect } from "vitest";
3
3
  import { setCookieToHeader } from "better-auth/cookies";
4
-
5
4
  //#region src/adapter/suites/auth-flow.ts
6
5
  /**
7
6
  * This test suite tests basic authentication flow using the adapter.
@@ -92,23 +91,27 @@ const authFlowTestSuite = createTestSuite("auth-flow", { defaultBetterAuthOption
92
91
  expect(error).toBeDefined();
93
92
  },
94
93
  "should store and retrieve timestamps correctly across timezones": async () => {
95
- using _ = recoverProcessTZ();
96
- const auth = await getAuth();
97
- const user = await generate("user");
98
- const password = crypto.randomUUID();
99
- const userSignUp = await auth.api.signUpEmail({ body: {
100
- email: user.email,
101
- password,
102
- name: user.name,
103
- image: user.image || ""
104
- } });
105
- process.env.TZ = "Europe/London";
106
- const userSignIn = await auth.api.signInEmail({ body: {
107
- email: user.email,
108
- password
109
- } });
110
- process.env.TZ = "America/Los_Angeles";
111
- expect(userSignUp.user.createdAt.toISOString()).toStrictEqual(userSignIn.user.createdAt.toISOString());
94
+ const originalTZ = process.env.TZ;
95
+ try {
96
+ const auth = await getAuth();
97
+ const user = await generate("user");
98
+ const password = crypto.randomUUID();
99
+ const userSignUp = await auth.api.signUpEmail({ body: {
100
+ email: user.email,
101
+ password,
102
+ name: user.name,
103
+ image: user.image || ""
104
+ } });
105
+ process.env.TZ = "Europe/London";
106
+ const userSignIn = await auth.api.signInEmail({ body: {
107
+ email: user.email,
108
+ password
109
+ } });
110
+ process.env.TZ = "America/Los_Angeles";
111
+ expect(userSignUp.user.createdAt.toISOString()).toStrictEqual(userSignIn.user.createdAt.toISOString());
112
+ } finally {
113
+ process.env.TZ = originalTZ;
114
+ }
112
115
  },
113
116
  "should sign up with additional fields": async () => {
114
117
  await modifyBetterAuthOptions({ user: { additionalFields: { dateField: { type: "date" } } } }, true);
@@ -129,13 +132,5 @@ const authFlowTestSuite = createTestSuite("auth-flow", { defaultBetterAuthOption
129
132
  expect((await auth.api.getSession({ headers }))?.user.dateField).toStrictEqual(dateField);
130
133
  }
131
134
  }));
132
- function recoverProcessTZ() {
133
- const originalTZ = process.env.TZ;
134
- return { [Symbol.dispose]: () => {
135
- process.env.TZ = originalTZ;
136
- } };
137
- }
138
-
139
135
  //#endregion
140
136
  export { authFlowTestSuite };
141
- //# sourceMappingURL=auth-flow.mjs.map
@@ -7,7 +7,7 @@ import * as better_auth0 from "better-auth";
7
7
  * This test suite tests the basic CRUD operations of the adapter.
8
8
  */
9
9
  declare const normalTestSuite: (options?: ({
10
- disableTests?: Partial<Record<"init - tests" | "create - should create a model" | "create - should always return an id" | "create - should use generateId if provided" | "create - should return null for nullable foreign keys" | "create - should apply default values to fields" | "findOne - should find a model" | "findOne - should not apply defaultValue if value not found" | "findOne - should find a model using a reference field" | "findOne - should not throw on record not found" | "findOne - should find a model without id" | "findOne - should find a model with join" | "findOne - should find a model with modified field name" | "findOne - should find a model with modified model name" | "findOne - should find a model with additional fields" | "findOne - should select fields" | "findOne - should select fields with one-to-many join" | "findOne - should select fields with one-to-one join" | "findOne - should select fields with multiple joins" | "findOne - should find model with date field" | "findOne - should perform backwards joins" | "findOne - should return an object for one-to-one joins" | "findOne - should return an array for one-to-many joins" | "findOne - should work with both one-to-one and one-to-many joins" | "findOne - should return null for failed base model lookup that has joins" | "findOne - should join a model with modified field name" | "findMany - should find many models" | "findMany - should find many models with date fields" | "findMany - should find many models with join" | "findMany - should find many with join and limit" | "findMany - should select fields" | "findMany - should select fields with one-to-many join" | "findMany - should select fields with one-to-one join" | "findMany - should select fields with multiple joins" | "findMany - should find many with join and offset" | "findMany - should find many with join and sortBy" | "findMany - should find many with join and where clause" | "findMany - should find many with join, where, limit, and offset" | "findMany - should find many with one-to-one join" | "findMany - should find many with both one-to-one and one-to-many joins" | "findMany - should return an empty array when no models are found" | "findMany - should return empty array when base records don't exist with joins" | "findMany - should find many models with starts_with operator" | "findMany - starts_with should not interpret regex patterns" | "findMany - ends_with should not interpret regex patterns" | "findMany - contains should not interpret regex patterns" | "findMany - should find many models with ends_with operator" | "findMany - should find many models with contains operator" | "findMany - should handle multiple where conditions with different operators" | "findMany - should find many models with contains operator (using symbol)" | "findMany - should find many models with eq operator" | "findMany - should find many models with ne operator" | "findMany - should find many models with gt operator" | "findMany - should find many models with gte operator" | "findMany - should find many models with lte operator" | "findMany - should find many models with lt operator" | "findMany - should find many models with in operator" | "findMany - should find many models with not_in operator" | "findMany - should find many models with sortBy" | "findMany - should find many models with limit" | "findMany - should find many models with offset" | "findMany - should find many models with limit and offset" | "findMany - should find many models with sortBy and offset" | "findMany - should find many models with sortBy and limit" | "findMany - should find many models with sortBy and limit and offset" | "findMany - should find many models with sortBy and limit and offset and where" | "update - should update a model" | "updateMany - should update all models when where is empty" | "updateMany - should update many models with a specific where" | "updateMany - should update many models with a multiple where" | "delete - should delete a model" | "delete - should not throw on record not found" | "delete - should delete by non-unique field" | "deleteMany - should delete many models" | "deleteMany - starts_with should not interpret regex patterns" | "deleteMany - ends_with should not interpret regex patterns" | "deleteMany - contains should not interpret regex patterns" | "deleteMany - should delete many models with numeric values" | "deleteMany - should delete many models with boolean values" | "count - should count many models" | "count - should return 0 with no rows to count" | "count - should count with where clause" | "update - should correctly return record when updating a field used in where clause" | "update - should handle updating multiple fields including where clause field" | "update - should work when updated field is not in where clause" | "findOne - backwards join should only return single record not array" | "findMany - backwards join should only return single record not array" | "findOne - backwards join with modified field name (session base, users-table join)" | "findOne - multiple joins should return result even when some joined tables have no matching rows" | "findOne - should be able to perform a limited join" | "findOne - should be able to perform a complex limited join" | "findMany - should be able to perform a limited join" | "findMany - should be able to perform a complex limited join" | "findOne - should return null for one-to-one join when joined record doesn't exist" | "findMany - should return null for one-to-one join when joined records don't exist" | "findMany - should return empty array for one-to-many join when joined records don't exist" | "findMany - should handle mixed joins correctly when some are missing" | "create - should support arrays" | "create - should support json" | "update - should support multiple where conditions under AND connector with unique field", boolean> & {
10
+ disableTests?: Partial<Record<"init - tests" | "create - should create a model" | "create - should always return an id" | "create - should use generateId if provided" | "create - should return null for nullable foreign keys" | "create - should apply default values to fields" | "findOne - should find a model" | "findOne - should not apply defaultValue if value not found" | "findOne - should find a model using a reference field" | "findOne - should not throw on record not found" | "findOne - should find a model without id" | "findOne - should find a model with join" | "findOne - should find a model with modified field name" | "findOne - should find a model with modified model name" | "findOne - should find a model with additional fields" | "findOne - should select fields" | "findOne - should select fields with one-to-many join" | "findOne - should select fields with one-to-one join" | "findOne - should select fields with multiple joins" | "findOne - should find model with date field" | "findOne - should perform backwards joins" | "findOne - should return an object for one-to-one joins" | "findOne - should return an array for one-to-many joins" | "findOne - should work with both one-to-one and one-to-many joins" | "findOne - should return null for failed base model lookup that has joins" | "findOne - should join a model with modified field name" | "findMany - should find many models" | "findMany - should find many models with date fields" | "findMany - should find many models with join" | "findMany - should find many with join and limit" | "findMany - should select fields" | "findMany - should select fields with one-to-many join" | "findMany - should select fields with one-to-one join" | "findMany - should select fields with multiple joins" | "findMany - should find many with join and offset" | "findMany - should find many with join and sortBy" | "findMany - should find many with join and where clause" | "findMany - should find many with join, where, limit, and offset" | "findMany - should find many with one-to-one join" | "findMany - should find many with both one-to-one and one-to-many joins" | "findMany - should return an empty array when no models are found" | "findMany - should return empty array when base records don't exist with joins" | "findMany - should find many models with starts_with operator" | "findMany - starts_with should not interpret regex patterns" | "findMany - ends_with should not interpret regex patterns" | "findMany - contains should not interpret regex patterns" | "findMany - should find many models with ends_with operator" | "findMany - should find many models with contains operator" | "findMany - should handle multiple where conditions with different operators" | "findMany - should find many models with contains operator (using symbol)" | "findMany - should find many models with eq operator" | "findMany - should find many models with ne operator" | "findMany - should find many models with gt operator" | "findMany - should find many models with gte operator" | "findMany - should find many models with lte operator" | "findMany - should find many models with lt operator" | "findMany - should find many models with in operator" | "findMany - should find many models with not_in operator" | "findMany - should find many models with sortBy" | "findMany - should find many models with limit" | "findMany - should find many models with offset" | "findMany - should find many models with limit and offset" | "findMany - should find many models with sortBy and offset" | "findMany - should find many models with sortBy and limit" | "findMany - should find many models with sortBy and limit and offset" | "findMany - should find many models with sortBy and limit and offset and where" | "update - should update a model" | "updateMany - should update all models when where is empty" | "updateMany - should update many models with a specific where" | "updateMany - should update many models with a multiple where" | "delete - should delete a model" | "delete - should not throw on record not found" | "delete - should delete by non-unique field" | "deleteMany - should delete many models" | "deleteMany - starts_with should not interpret regex patterns" | "deleteMany - ends_with should not interpret regex patterns" | "deleteMany - contains should not interpret regex patterns" | "deleteMany - should delete many models with numeric values" | "deleteMany - should delete many models with boolean values" | "count - should count many models" | "count - should return 0 with no rows to count" | "count - should count with where clause" | "update - should correctly return record when updating a field used in where clause" | "update - should handle updating multiple fields including where clause field" | "update - should work when updated field is not in where clause" | "findOne - backwards join should only return single record not array" | "findMany - backwards join should only return single record not array" | "findOne - backwards join with modified field name (session base, users-table join)" | "findOne - multiple joins should return result even when some joined tables have no matching rows" | "findOne - should be able to perform a limited join" | "findOne - should be able to perform a complex limited join" | "findMany - should be able to perform a limited join" | "findMany - should be able to perform a complex limited join" | "findOne - should return null for one-to-one join when joined record doesn't exist" | "findMany - should return null for one-to-one join when joined records don't exist" | "findMany - should return empty array for one-to-many join when joined records don't exist" | "findMany - should handle mixed joins correctly when some are missing" | "create - should support arrays" | "create - should support json" | "update - should support multiple where conditions under AND connector with unique field" | "findMany - eq operator with null value (single condition) should use IS NULL" | "findMany - eq and ne operators with null value in AND group should use IS NULL / IS NOT NULL" | "findMany - eq and ne operators with null value in OR group should use IS NULL / IS NOT NULL" | "update - should return updated record when where condition uses null value", boolean> & {
11
11
  ALL?: boolean;
12
12
  }> | undefined;
13
13
  } & {
@@ -199,8 +199,11 @@ declare const getNormalTestSuiteTests: ({
199
199
  test: () => Promise<void>;
200
200
  };
201
201
  "update - should support multiple where conditions under AND connector with unique field": () => Promise<void>;
202
+ "findMany - eq operator with null value (single condition) should use IS NULL": () => Promise<void>;
203
+ "findMany - eq and ne operators with null value in AND group should use IS NULL / IS NOT NULL": () => Promise<void>;
204
+ "findMany - eq and ne operators with null value in OR group should use IS NULL / IS NOT NULL": () => Promise<void>;
205
+ "update - should return updated record when where condition uses null value": () => Promise<void>;
202
206
  };
203
- declare const enableJoinTests: Partial<Record<"create - should create a model" | "create - should always return an id" | "create - should use generateId if provided" | "create - should return null for nullable foreign keys" | "create - should apply default values to fields" | "findOne - should find a model" | "findOne - should not apply defaultValue if value not found" | "findOne - should find a model using a reference field" | "findOne - should not throw on record not found" | "findOne - should find a model without id" | "findOne - should find a model with join" | "findOne - should find a model with modified field name" | "findOne - should find a model with modified model name" | "findOne - should find a model with additional fields" | "findOne - should select fields" | "findOne - should select fields with one-to-many join" | "findOne - should select fields with one-to-one join" | "findOne - should select fields with multiple joins" | "findOne - should find model with date field" | "findOne - should perform backwards joins" | "findOne - should return an object for one-to-one joins" | "findOne - should return an array for one-to-many joins" | "findOne - should work with both one-to-one and one-to-many joins" | "findOne - should return null for failed base model lookup that has joins" | "findOne - should join a model with modified field name" | "findMany - should find many models" | "findMany - should find many models with date fields" | "findMany - should find many models with join" | "findMany - should find many with join and limit" | "findMany - should select fields" | "findMany - should select fields with one-to-many join" | "findMany - should select fields with one-to-one join" | "findMany - should select fields with multiple joins" | "findMany - should find many with join and offset" | "findMany - should find many with join and sortBy" | "findMany - should find many with join and where clause" | "findMany - should find many with join, where, limit, and offset" | "findMany - should find many with one-to-one join" | "findMany - should find many with both one-to-one and one-to-many joins" | "findMany - should return an empty array when no models are found" | "findMany - should return empty array when base records don't exist with joins" | "findMany - should find many models with starts_with operator" | "findMany - starts_with should not interpret regex patterns" | "findMany - ends_with should not interpret regex patterns" | "findMany - contains should not interpret regex patterns" | "findMany - should find many models with ends_with operator" | "findMany - should find many models with contains operator" | "findMany - should handle multiple where conditions with different operators" | "findMany - should find many models with contains operator (using symbol)" | "findMany - should find many models with eq operator" | "findMany - should find many models with ne operator" | "findMany - should find many models with gt operator" | "findMany - should find many models with gte operator" | "findMany - should find many models with lte operator" | "findMany - should find many models with lt operator" | "findMany - should find many models with in operator" | "findMany - should find many models with not_in operator" | "findMany - should find many models with sortBy" | "findMany - should find many models with limit" | "findMany - should find many models with offset" | "findMany - should find many models with limit and offset" | "findMany - should find many models with sortBy and offset" | "findMany - should find many models with sortBy and limit" | "findMany - should find many models with sortBy and limit and offset" | "findMany - should find many models with sortBy and limit and offset and where" | "update - should update a model" | "updateMany - should update all models when where is empty" | "updateMany - should update many models with a specific where" | "updateMany - should update many models with a multiple where" | "delete - should delete a model" | "delete - should not throw on record not found" | "delete - should delete by non-unique field" | "deleteMany - should delete many models" | "deleteMany - starts_with should not interpret regex patterns" | "deleteMany - ends_with should not interpret regex patterns" | "deleteMany - contains should not interpret regex patterns" | "deleteMany - should delete many models with numeric values" | "deleteMany - should delete many models with boolean values" | "count - should count many models" | "count - should return 0 with no rows to count" | "count - should count with where clause" | "update - should correctly return record when updating a field used in where clause" | "update - should handle updating multiple fields including where clause field" | "update - should work when updated field is not in where clause" | "findOne - backwards join should only return single record not array" | "findMany - backwards join should only return single record not array" | "findOne - backwards join with modified field name (session base, users-table join)" | "findOne - multiple joins should return result even when some joined tables have no matching rows" | "findOne - should be able to perform a limited join" | "findOne - should be able to perform a complex limited join" | "findMany - should be able to perform a limited join" | "findMany - should be able to perform a complex limited join" | "findOne - should return null for one-to-one join when joined record doesn't exist" | "findMany - should return null for one-to-one join when joined records don't exist" | "findMany - should return empty array for one-to-many join when joined records don't exist" | "findMany - should handle mixed joins correctly when some are missing" | "create - should support arrays" | "create - should support json" | "update - should support multiple where conditions under AND connector with unique field", boolean>>;
207
+ declare const enableJoinTests: Partial<Record<"create - should create a model" | "create - should always return an id" | "create - should use generateId if provided" | "create - should return null for nullable foreign keys" | "create - should apply default values to fields" | "findOne - should find a model" | "findOne - should not apply defaultValue if value not found" | "findOne - should find a model using a reference field" | "findOne - should not throw on record not found" | "findOne - should find a model without id" | "findOne - should find a model with join" | "findOne - should find a model with modified field name" | "findOne - should find a model with modified model name" | "findOne - should find a model with additional fields" | "findOne - should select fields" | "findOne - should select fields with one-to-many join" | "findOne - should select fields with one-to-one join" | "findOne - should select fields with multiple joins" | "findOne - should find model with date field" | "findOne - should perform backwards joins" | "findOne - should return an object for one-to-one joins" | "findOne - should return an array for one-to-many joins" | "findOne - should work with both one-to-one and one-to-many joins" | "findOne - should return null for failed base model lookup that has joins" | "findOne - should join a model with modified field name" | "findMany - should find many models" | "findMany - should find many models with date fields" | "findMany - should find many models with join" | "findMany - should find many with join and limit" | "findMany - should select fields" | "findMany - should select fields with one-to-many join" | "findMany - should select fields with one-to-one join" | "findMany - should select fields with multiple joins" | "findMany - should find many with join and offset" | "findMany - should find many with join and sortBy" | "findMany - should find many with join and where clause" | "findMany - should find many with join, where, limit, and offset" | "findMany - should find many with one-to-one join" | "findMany - should find many with both one-to-one and one-to-many joins" | "findMany - should return an empty array when no models are found" | "findMany - should return empty array when base records don't exist with joins" | "findMany - should find many models with starts_with operator" | "findMany - starts_with should not interpret regex patterns" | "findMany - ends_with should not interpret regex patterns" | "findMany - contains should not interpret regex patterns" | "findMany - should find many models with ends_with operator" | "findMany - should find many models with contains operator" | "findMany - should handle multiple where conditions with different operators" | "findMany - should find many models with contains operator (using symbol)" | "findMany - should find many models with eq operator" | "findMany - should find many models with ne operator" | "findMany - should find many models with gt operator" | "findMany - should find many models with gte operator" | "findMany - should find many models with lte operator" | "findMany - should find many models with lt operator" | "findMany - should find many models with in operator" | "findMany - should find many models with not_in operator" | "findMany - should find many models with sortBy" | "findMany - should find many models with limit" | "findMany - should find many models with offset" | "findMany - should find many models with limit and offset" | "findMany - should find many models with sortBy and offset" | "findMany - should find many models with sortBy and limit" | "findMany - should find many models with sortBy and limit and offset" | "findMany - should find many models with sortBy and limit and offset and where" | "update - should update a model" | "updateMany - should update all models when where is empty" | "updateMany - should update many models with a specific where" | "updateMany - should update many models with a multiple where" | "delete - should delete a model" | "delete - should not throw on record not found" | "delete - should delete by non-unique field" | "deleteMany - should delete many models" | "deleteMany - starts_with should not interpret regex patterns" | "deleteMany - ends_with should not interpret regex patterns" | "deleteMany - contains should not interpret regex patterns" | "deleteMany - should delete many models with numeric values" | "deleteMany - should delete many models with boolean values" | "count - should count many models" | "count - should return 0 with no rows to count" | "count - should count with where clause" | "update - should correctly return record when updating a field used in where clause" | "update - should handle updating multiple fields including where clause field" | "update - should work when updated field is not in where clause" | "findOne - backwards join should only return single record not array" | "findMany - backwards join should only return single record not array" | "findOne - backwards join with modified field name (session base, users-table join)" | "findOne - multiple joins should return result even when some joined tables have no matching rows" | "findOne - should be able to perform a limited join" | "findOne - should be able to perform a complex limited join" | "findMany - should be able to perform a limited join" | "findMany - should be able to perform a complex limited join" | "findOne - should return null for one-to-one join when joined record doesn't exist" | "findMany - should return null for one-to-one join when joined records don't exist" | "findMany - should return empty array for one-to-many join when joined records don't exist" | "findMany - should handle mixed joins correctly when some are missing" | "create - should support arrays" | "create - should support json" | "update - should support multiple where conditions under AND connector with unique field" | "findMany - eq operator with null value (single condition) should use IS NULL" | "findMany - eq and ne operators with null value in AND group should use IS NULL / IS NOT NULL" | "findMany - eq and ne operators with null value in OR group should use IS NULL / IS NOT NULL" | "update - should return updated record when where condition uses null value", boolean>>;
204
208
  //#endregion
205
- export { enableJoinTests, getNormalTestSuiteTests, normalTestSuite };
206
- //# sourceMappingURL=basic.d.mts.map
209
+ export { enableJoinTests, getNormalTestSuiteTests, normalTestSuite };
@@ -1,7 +1,6 @@
1
1
  import { createTestSuite } from "../create-test-suite.mjs";
2
2
  import { expect } from "vitest";
3
3
  import { organization } from "better-auth/plugins/organization";
4
-
5
4
  //#region src/adapter/suites/basic.ts
6
5
  /**
7
6
  * This test suite tests the basic CRUD operations of the adapter.
@@ -2728,6 +2727,188 @@ const getNormalTestSuiteTests = ({ adapter, generate, insertRandom, modifyBetter
2728
2727
  expect(result.name).toBe("Updated Name");
2729
2728
  expect(result.email).toBe(user.email);
2730
2729
  expect(result.id).toBe(user.id);
2730
+ },
2731
+ "findMany - eq operator with null value (single condition) should use IS NULL": async () => {
2732
+ const withNull = await adapter.create({
2733
+ model: "user",
2734
+ data: {
2735
+ ...await generate("user"),
2736
+ image: null
2737
+ },
2738
+ forceAllowId: true
2739
+ });
2740
+ const withImage = await adapter.create({
2741
+ model: "user",
2742
+ data: {
2743
+ ...await generate("user"),
2744
+ image: "https://example.com/avatar.png"
2745
+ },
2746
+ forceAllowId: true
2747
+ });
2748
+ const nullIds = (await adapter.findMany({
2749
+ model: "user",
2750
+ where: [{
2751
+ field: "image",
2752
+ operator: "eq",
2753
+ value: null
2754
+ }]
2755
+ })).map((u) => u.id);
2756
+ expect(nullIds).toContain(withNull.id);
2757
+ expect(nullIds).not.toContain(withImage.id);
2758
+ const notNullIds = (await adapter.findMany({
2759
+ model: "user",
2760
+ where: [{
2761
+ field: "image",
2762
+ operator: "ne",
2763
+ value: null
2764
+ }]
2765
+ })).map((u) => u.id);
2766
+ expect(notNullIds).not.toContain(withNull.id);
2767
+ expect(notNullIds).toContain(withImage.id);
2768
+ },
2769
+ "findMany - eq and ne operators with null value in AND group should use IS NULL / IS NOT NULL": async () => {
2770
+ const nullVerified = await adapter.create({
2771
+ model: "user",
2772
+ data: {
2773
+ ...await generate("user"),
2774
+ image: null,
2775
+ emailVerified: true
2776
+ },
2777
+ forceAllowId: true
2778
+ });
2779
+ const nullUnverified = await adapter.create({
2780
+ model: "user",
2781
+ data: {
2782
+ ...await generate("user"),
2783
+ image: null,
2784
+ emailVerified: false
2785
+ },
2786
+ forceAllowId: true
2787
+ });
2788
+ const imageVerified = await adapter.create({
2789
+ model: "user",
2790
+ data: {
2791
+ ...await generate("user"),
2792
+ image: "https://example.com/avatar.png",
2793
+ emailVerified: true
2794
+ },
2795
+ forceAllowId: true
2796
+ });
2797
+ const eqIds = (await adapter.findMany({
2798
+ model: "user",
2799
+ where: [{
2800
+ field: "image",
2801
+ operator: "eq",
2802
+ value: null,
2803
+ connector: "AND"
2804
+ }, {
2805
+ field: "emailVerified",
2806
+ value: true,
2807
+ connector: "AND"
2808
+ }]
2809
+ })).map((u) => u.id);
2810
+ expect(eqIds).toContain(nullVerified.id);
2811
+ expect(eqIds).not.toContain(nullUnverified.id);
2812
+ expect(eqIds).not.toContain(imageVerified.id);
2813
+ const neIds = (await adapter.findMany({
2814
+ model: "user",
2815
+ where: [{
2816
+ field: "image",
2817
+ operator: "ne",
2818
+ value: null,
2819
+ connector: "AND"
2820
+ }, {
2821
+ field: "emailVerified",
2822
+ value: true,
2823
+ connector: "AND"
2824
+ }]
2825
+ })).map((u) => u.id);
2826
+ expect(neIds).not.toContain(nullVerified.id);
2827
+ expect(neIds).not.toContain(nullUnverified.id);
2828
+ expect(neIds).toContain(imageVerified.id);
2829
+ },
2830
+ "findMany - eq and ne operators with null value in OR group should use IS NULL / IS NOT NULL": async () => {
2831
+ const withNull = await adapter.create({
2832
+ model: "user",
2833
+ data: {
2834
+ ...await generate("user"),
2835
+ image: null
2836
+ },
2837
+ forceAllowId: true
2838
+ });
2839
+ const targetImage = await adapter.create({
2840
+ model: "user",
2841
+ data: {
2842
+ ...await generate("user"),
2843
+ image: "https://example.com/target.png"
2844
+ },
2845
+ forceAllowId: true
2846
+ });
2847
+ const otherImage = await adapter.create({
2848
+ model: "user",
2849
+ data: {
2850
+ ...await generate("user"),
2851
+ image: "https://example.com/other.png"
2852
+ },
2853
+ forceAllowId: true
2854
+ });
2855
+ const eqIds = (await adapter.findMany({
2856
+ model: "user",
2857
+ where: [{
2858
+ field: "image",
2859
+ operator: "eq",
2860
+ value: null,
2861
+ connector: "OR"
2862
+ }, {
2863
+ field: "email",
2864
+ value: targetImage.email,
2865
+ connector: "OR"
2866
+ }]
2867
+ })).map((u) => u.id);
2868
+ expect(eqIds).toContain(withNull.id);
2869
+ expect(eqIds).toContain(targetImage.id);
2870
+ expect(eqIds).not.toContain(otherImage.id);
2871
+ const neIds = (await adapter.findMany({
2872
+ model: "user",
2873
+ where: [{
2874
+ field: "image",
2875
+ operator: "ne",
2876
+ value: null,
2877
+ connector: "OR"
2878
+ }, {
2879
+ field: "email",
2880
+ value: withNull.email,
2881
+ connector: "OR"
2882
+ }]
2883
+ })).map((u) => u.id);
2884
+ expect(neIds).toContain(withNull.id);
2885
+ expect(neIds).toContain(targetImage.id);
2886
+ expect(neIds).toContain(otherImage.id);
2887
+ },
2888
+ "update - should return updated record when where condition uses null value": async () => {
2889
+ const withNull = await adapter.create({
2890
+ model: "user",
2891
+ data: {
2892
+ ...await generate("user"),
2893
+ image: null
2894
+ },
2895
+ forceAllowId: true
2896
+ });
2897
+ const result = await adapter.update({
2898
+ model: "user",
2899
+ where: [{
2900
+ field: "id",
2901
+ value: withNull.id
2902
+ }, {
2903
+ field: "image",
2904
+ operator: "eq",
2905
+ value: null
2906
+ }],
2907
+ update: { name: "null-where-updated" }
2908
+ });
2909
+ expect(result).toBeDefined();
2910
+ expect(result.id).toBe(withNull.id);
2911
+ expect(result.name).toBe("null-where-updated");
2731
2912
  }
2732
2913
  };
2733
2914
  };
@@ -2736,7 +2917,5 @@ const enableJoinTests = getTestKeys().reduce((acc, test) => {
2736
2917
  if (test.includes("join")) acc[test] = false;
2737
2918
  return acc;
2738
2919
  }, {});
2739
-
2740
2920
  //#endregion
2741
2921
  export { enableJoinTests, getNormalTestSuiteTests, normalTestSuite };
2742
- //# sourceMappingURL=basic.mjs.map
@@ -0,0 +1,27 @@
1
+ import * as better_auth0 from "better-auth";
2
+ import * as _better_auth_test_utils_adapter0 from "@better-auth/test-utils/adapter";
3
+
4
+ //#region src/adapter/suites/case-insensitive.d.ts
5
+ /**
6
+ * Test suite for case-insensitive string operations across adapters.
7
+ * Tests eq, ne, in, not_in, contains, starts_with, ends_with with mode: "insensitive".
8
+ */
9
+ declare const caseInsensitiveTestSuite: (options?: {
10
+ disableTests?: Partial<Record<"findOne - eq with mode insensitive should match regardless of case" | "findOne - eq with mode sensitive (default) should not match different case" | "findMany - eq with mode insensitive" | "findMany - ne with mode insensitive" | "findMany - in with mode insensitive" | "findMany - not_in with mode insensitive" | "findMany - contains with mode insensitive" | "findMany - starts_with with mode insensitive" | "findMany - ends_with with mode insensitive" | "count - with mode insensitive" | "update - where with mode insensitive" | "deleteMany - where with mode insensitive", boolean> & {
11
+ ALL?: boolean;
12
+ }> | undefined;
13
+ } | undefined) => (helpers: {
14
+ adapter: () => Promise<better_auth0.DBAdapter<better_auth0.BetterAuthOptions>>;
15
+ log: _better_auth_test_utils_adapter0.Logger;
16
+ adapterDisplayName: string;
17
+ getBetterAuthOptions: () => better_auth0.BetterAuthOptions;
18
+ modifyBetterAuthOptions: (options: better_auth0.BetterAuthOptions) => Promise<better_auth0.BetterAuthOptions>;
19
+ cleanup: () => Promise<void>;
20
+ runMigrations: () => Promise<void>;
21
+ prefixTests?: string | undefined;
22
+ onTestFinish: (stats: _better_auth_test_utils_adapter0.TestSuiteStats) => Promise<void>;
23
+ customIdGenerator?: (() => any | Promise<any> | undefined) | undefined;
24
+ transformIdOutput?: ((id: any) => string | undefined) | undefined;
25
+ }) => Promise<void>;
26
+ //#endregion
27
+ export { caseInsensitiveTestSuite };