@better-auth/test-utils 1.5.6 → 1.5.7-beta.1
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.
- package/dist/adapter.mjs +1 -2
- package/dist/create-test-suite.mjs +1 -2
- package/dist/create-test-suite.mjs.map +1 -1
- package/dist/suites/auth-flow.mjs +1 -2
- package/dist/suites/auth-flow.mjs.map +1 -1
- package/dist/suites/basic.d.mts +6 -2
- package/dist/suites/basic.mjs +183 -2
- package/dist/suites/basic.mjs.map +1 -1
- package/dist/suites/index.mjs +7 -8
- package/dist/suites/joins.d.mts +1 -1
- package/dist/suites/joins.mjs +1 -2
- package/dist/suites/joins.mjs.map +1 -1
- package/dist/suites/number-id.d.mts +1 -1
- package/dist/suites/number-id.mjs +1 -2
- package/dist/suites/number-id.mjs.map +1 -1
- package/dist/suites/transactions.mjs +1 -2
- package/dist/suites/transactions.mjs.map +1 -1
- package/dist/suites/uuid.d.mts +1 -1
- package/dist/suites/uuid.mjs +1 -2
- package/dist/suites/uuid.mjs.map +1 -1
- package/dist/test-adapter.mjs +1 -2
- package/dist/test-adapter.mjs.map +1 -1
- package/package.json +6 -6
package/dist/suites/index.mjs
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
export { };
|
|
1
|
+
import "./auth-flow.mjs";
|
|
2
|
+
import "./basic.mjs";
|
|
3
|
+
import "./joins.mjs";
|
|
4
|
+
import "./number-id.mjs";
|
|
5
|
+
import "./transactions.mjs";
|
|
6
|
+
import "./uuid.mjs";
|
|
7
|
+
export {};
|
package/dist/suites/joins.d.mts
CHANGED
|
@@ -4,7 +4,7 @@ import * as better_auth0 from "better-auth";
|
|
|
4
4
|
|
|
5
5
|
//#region src/adapter/suites/joins.d.ts
|
|
6
6
|
declare const joinsTestSuite: (options?: {
|
|
7
|
-
disableTests?: Partial<Record<"init - tests" | "create - should create a model" | "create - should always return an id" | "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> & {
|
|
7
|
+
disableTests?: Partial<Record<"init - tests" | "create - should create a model" | "create - should always return an id" | "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> & {
|
|
8
8
|
ALL?: boolean;
|
|
9
9
|
}> | undefined;
|
|
10
10
|
} | undefined) => (helpers: {
|
package/dist/suites/joins.mjs
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { createTestSuite } from "../create-test-suite.mjs";
|
|
2
2
|
import { getNormalTestSuiteTests } from "./basic.mjs";
|
|
3
3
|
import { expect } from "vitest";
|
|
4
|
-
|
|
5
4
|
//#region src/adapter/suites/joins.ts
|
|
6
5
|
const joinsTestSuite = createTestSuite("joins", {
|
|
7
6
|
defaultBetterAuthOptions: { experimental: { joins: true } },
|
|
@@ -16,7 +15,7 @@ const joinsTestSuite = createTestSuite("joins", {
|
|
|
16
15
|
...normalTests
|
|
17
16
|
};
|
|
18
17
|
});
|
|
19
|
-
|
|
20
18
|
//#endregion
|
|
21
19
|
export { joinsTestSuite };
|
|
20
|
+
|
|
22
21
|
//# sourceMappingURL=joins.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"joins.mjs","names":[],"sources":["../../src/adapter/suites/joins.ts"],"sourcesContent":["import { expect } from \"vitest\";\nimport { createTestSuite } from \"../create-test-suite\";\nimport { getNormalTestSuiteTests } from \"./basic\";\n\nexport const joinsTestSuite = createTestSuite(\n\t\"joins\",\n\t{\n\t\tdefaultBetterAuthOptions: {\n\t\t\texperimental: {\n\t\t\t\tjoins: true,\n\t\t\t},\n\t\t},\n\t\talwaysMigrate: true,\n\t\tprefixTests: \"joins\",\n\t},\n\t(helpers) => {\n\t\tconst { \"create - should use generateId if provided\": _, ...normalTests } =\n\t\t\tgetNormalTestSuiteTests({ ...helpers });\n\n\t\treturn {\n\t\t\t\"init - tests\": async () => {\n\t\t\t\tconst opts = helpers.getBetterAuthOptions();\n\t\t\t\texpect(opts.experimental?.joins).toBe(true);\n\t\t\t},\n\t\t\t...normalTests,\n\t\t};\n\t},\n);\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"joins.mjs","names":[],"sources":["../../src/adapter/suites/joins.ts"],"sourcesContent":["import { expect } from \"vitest\";\nimport { createTestSuite } from \"../create-test-suite\";\nimport { getNormalTestSuiteTests } from \"./basic\";\n\nexport const joinsTestSuite = createTestSuite(\n\t\"joins\",\n\t{\n\t\tdefaultBetterAuthOptions: {\n\t\t\texperimental: {\n\t\t\t\tjoins: true,\n\t\t\t},\n\t\t},\n\t\talwaysMigrate: true,\n\t\tprefixTests: \"joins\",\n\t},\n\t(helpers) => {\n\t\tconst { \"create - should use generateId if provided\": _, ...normalTests } =\n\t\t\tgetNormalTestSuiteTests({ ...helpers });\n\n\t\treturn {\n\t\t\t\"init - tests\": async () => {\n\t\t\t\tconst opts = helpers.getBetterAuthOptions();\n\t\t\t\texpect(opts.experimental?.joins).toBe(true);\n\t\t\t},\n\t\t\t...normalTests,\n\t\t};\n\t},\n);\n"],"mappings":";;;;AAIA,MAAa,iBAAiB,gBAC7B,SACA;CACC,0BAA0B,EACzB,cAAc,EACb,OAAO,MACP,EACD;CACD,eAAe;CACf,aAAa;CACb,GACA,YAAY;CACZ,MAAM,EAAE,8CAA8C,GAAG,GAAG,gBAC3D,wBAAwB,EAAE,GAAG,SAAS,CAAC;AAExC,QAAO;EACN,gBAAgB,YAAY;AAE3B,UADa,QAAQ,sBAAsB,CAC/B,cAAc,MAAM,CAAC,KAAK,KAAK;;EAE5C,GAAG;EACH;EAEF"}
|
|
@@ -4,7 +4,7 @@ import * as better_auth0 from "better-auth";
|
|
|
4
4
|
|
|
5
5
|
//#region src/adapter/suites/number-id.d.ts
|
|
6
6
|
declare const numberIdTestSuite: (options?: {
|
|
7
|
-
disableTests?: Partial<Record<"init - tests" | "create - should create a model" | "create - should always return an id" | "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" | "create - should return a number id", boolean> & {
|
|
7
|
+
disableTests?: Partial<Record<"init - tests" | "create - should create a model" | "create - should always return an id" | "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" | "create - should return a number id", boolean> & {
|
|
8
8
|
ALL?: boolean;
|
|
9
9
|
}> | undefined;
|
|
10
10
|
} | undefined) => (helpers: {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { createTestSuite } from "../create-test-suite.mjs";
|
|
2
2
|
import { getNormalTestSuiteTests } from "./basic.mjs";
|
|
3
3
|
import { expect } from "vitest";
|
|
4
|
-
|
|
5
4
|
//#region src/adapter/suites/number-id.ts
|
|
6
5
|
const numberIdTestSuite = createTestSuite("number-id", {
|
|
7
6
|
defaultBetterAuthOptions: { advanced: { database: { generateId: "serial" } } },
|
|
@@ -27,7 +26,7 @@ const numberIdTestSuite = createTestSuite("number-id", {
|
|
|
27
26
|
...normalTests
|
|
28
27
|
};
|
|
29
28
|
});
|
|
30
|
-
|
|
31
29
|
//#endregion
|
|
32
30
|
export { numberIdTestSuite };
|
|
31
|
+
|
|
33
32
|
//# sourceMappingURL=number-id.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"number-id.mjs","names":[],"sources":["../../src/adapter/suites/number-id.ts"],"sourcesContent":["import type { User } from \"better-auth/types\";\nimport { expect } from \"vitest\";\nimport { createTestSuite } from \"../create-test-suite\";\nimport { getNormalTestSuiteTests } from \"./basic\";\n\nexport const numberIdTestSuite = createTestSuite(\n\t\"number-id\",\n\t{\n\t\tdefaultBetterAuthOptions: {\n\t\t\tadvanced: {\n\t\t\t\tdatabase: {\n\t\t\t\t\tgenerateId: \"serial\",\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\talwaysMigrate: true,\n\t\tprefixTests: \"number-id\",\n\t},\n\t(helpers) => {\n\t\tconst { \"create - should use generateId if provided\": _, ...normalTests } =\n\t\t\tgetNormalTestSuiteTests({ ...helpers });\n\n\t\treturn {\n\t\t\t\"init - tests\": async () => {\n\t\t\t\tconst opts = helpers.getBetterAuthOptions();\n\t\t\t\texpect(opts.advanced?.database?.generateId === \"serial\").toBe(true);\n\t\t\t},\n\t\t\t\"create - should return a number id\": async () => {\n\t\t\t\tconst user = await helpers.generate(\"user\");\n\t\t\t\tconst res = await helpers.adapter.create<User>({\n\t\t\t\t\tmodel: \"user\",\n\t\t\t\t\tdata: user,\n\t\t\t\t\tforceAllowId: true,\n\t\t\t\t});\n\t\t\t\texpect(res).toHaveProperty(\"id\");\n\t\t\t\texpect(typeof res.id).toBe(\"string\");\n\t\t\t\texpect(Number(res.id)).toBeGreaterThan(0);\n\t\t\t},\n\t\t\t...normalTests,\n\t\t};\n\t},\n);\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"number-id.mjs","names":[],"sources":["../../src/adapter/suites/number-id.ts"],"sourcesContent":["import type { User } from \"better-auth/types\";\nimport { expect } from \"vitest\";\nimport { createTestSuite } from \"../create-test-suite\";\nimport { getNormalTestSuiteTests } from \"./basic\";\n\nexport const numberIdTestSuite = createTestSuite(\n\t\"number-id\",\n\t{\n\t\tdefaultBetterAuthOptions: {\n\t\t\tadvanced: {\n\t\t\t\tdatabase: {\n\t\t\t\t\tgenerateId: \"serial\",\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\talwaysMigrate: true,\n\t\tprefixTests: \"number-id\",\n\t},\n\t(helpers) => {\n\t\tconst { \"create - should use generateId if provided\": _, ...normalTests } =\n\t\t\tgetNormalTestSuiteTests({ ...helpers });\n\n\t\treturn {\n\t\t\t\"init - tests\": async () => {\n\t\t\t\tconst opts = helpers.getBetterAuthOptions();\n\t\t\t\texpect(opts.advanced?.database?.generateId === \"serial\").toBe(true);\n\t\t\t},\n\t\t\t\"create - should return a number id\": async () => {\n\t\t\t\tconst user = await helpers.generate(\"user\");\n\t\t\t\tconst res = await helpers.adapter.create<User>({\n\t\t\t\t\tmodel: \"user\",\n\t\t\t\t\tdata: user,\n\t\t\t\t\tforceAllowId: true,\n\t\t\t\t});\n\t\t\t\texpect(res).toHaveProperty(\"id\");\n\t\t\t\texpect(typeof res.id).toBe(\"string\");\n\t\t\t\texpect(Number(res.id)).toBeGreaterThan(0);\n\t\t\t},\n\t\t\t...normalTests,\n\t\t};\n\t},\n);\n"],"mappings":";;;;AAKA,MAAa,oBAAoB,gBAChC,aACA;CACC,0BAA0B,EACzB,UAAU,EACT,UAAU,EACT,YAAY,UACZ,EACD,EACD;CACD,eAAe;CACf,aAAa;CACb,GACA,YAAY;CACZ,MAAM,EAAE,8CAA8C,GAAG,GAAG,gBAC3D,wBAAwB,EAAE,GAAG,SAAS,CAAC;AAExC,QAAO;EACN,gBAAgB,YAAY;AAE3B,UADa,QAAQ,sBAAsB,CAC/B,UAAU,UAAU,eAAe,SAAS,CAAC,KAAK,KAAK;;EAEpE,sCAAsC,YAAY;GACjD,MAAM,OAAO,MAAM,QAAQ,SAAS,OAAO;GAC3C,MAAM,MAAM,MAAM,QAAQ,QAAQ,OAAa;IAC9C,OAAO;IACP,MAAM;IACN,cAAc;IACd,CAAC;AACF,UAAO,IAAI,CAAC,eAAe,KAAK;AAChC,UAAO,OAAO,IAAI,GAAG,CAAC,KAAK,SAAS;AACpC,UAAO,OAAO,IAAI,GAAG,CAAC,CAAC,gBAAgB,EAAE;;EAE1C,GAAG;EACH;EAEF"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { createTestSuite } from "../create-test-suite.mjs";
|
|
2
2
|
import { expect } from "vitest";
|
|
3
|
-
|
|
4
3
|
//#region src/adapter/suites/transactions.ts
|
|
5
4
|
/**
|
|
6
5
|
* This test suite tests the transaction functionality of the adapter.
|
|
@@ -25,7 +24,7 @@ const transactionsTestSuite = createTestSuite("transactions", {}, ({ adapter, ge
|
|
|
25
24
|
await hardCleanup();
|
|
26
25
|
expect(result.length).toBe(0);
|
|
27
26
|
} }));
|
|
28
|
-
|
|
29
27
|
//#endregion
|
|
30
28
|
export { transactionsTestSuite };
|
|
29
|
+
|
|
31
30
|
//# sourceMappingURL=transactions.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transactions.mjs","names":[],"sources":["../../src/adapter/suites/transactions.ts"],"sourcesContent":["import type { User } from \"better-auth/db\";\nimport { expect } from \"vitest\";\nimport { createTestSuite } from \"../create-test-suite\";\n\n/**\n * This test suite tests the transaction functionality of the adapter.\n */\nexport const transactionsTestSuite = createTestSuite(\n\t\"transactions\",\n\t{},\n\t({ adapter, generate, hardCleanup }) => ({\n\t\t\"transaction - should rollback failing transaction\": async ({ skip }) => {\n\t\t\tconst isEnabled = adapter.options?.adapterConfig.transaction;\n\t\t\tif (!isEnabled) {\n\t\t\t\tskip(\n\t\t\t\t\t`Skipping test: ${adapter.options?.adapterConfig.adapterName} does not support transactions`,\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst user1 = await generate(\"user\");\n\t\t\tconst user2 = await generate(\"user\");\n\t\t\tawait expect(\n\t\t\t\tadapter.transaction(async (tx) => {\n\t\t\t\t\tawait tx.create({ model: \"user\", data: user1, forceAllowId: true });\n\t\t\t\t\tconst users = await tx.findMany({ model: \"user\" });\n\t\t\t\t\texpect(users).toHaveLength(1);\n\t\t\t\t\tthrow new Error(\"Simulated failure\");\n\t\t\t\t\tawait tx.create({ model: \"user\", data: user2, forceAllowId: true });\n\t\t\t\t}),\n\t\t\t).rejects.toThrow(\"Simulated failure\");\n\t\t\tconst result = await adapter.findMany<User>({\n\t\t\t\tmodel: \"user\",\n\t\t\t});\n\t\t\t//Transactions made rows are unable to be automatically cleaned up, so we need to clean them up manually\n\t\t\tawait hardCleanup();\n\t\t\texpect(result.length).toBe(0);\n\t\t},\n\t}),\n);\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"transactions.mjs","names":[],"sources":["../../src/adapter/suites/transactions.ts"],"sourcesContent":["import type { User } from \"better-auth/db\";\nimport { expect } from \"vitest\";\nimport { createTestSuite } from \"../create-test-suite\";\n\n/**\n * This test suite tests the transaction functionality of the adapter.\n */\nexport const transactionsTestSuite = createTestSuite(\n\t\"transactions\",\n\t{},\n\t({ adapter, generate, hardCleanup }) => ({\n\t\t\"transaction - should rollback failing transaction\": async ({ skip }) => {\n\t\t\tconst isEnabled = adapter.options?.adapterConfig.transaction;\n\t\t\tif (!isEnabled) {\n\t\t\t\tskip(\n\t\t\t\t\t`Skipping test: ${adapter.options?.adapterConfig.adapterName} does not support transactions`,\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst user1 = await generate(\"user\");\n\t\t\tconst user2 = await generate(\"user\");\n\t\t\tawait expect(\n\t\t\t\tadapter.transaction(async (tx) => {\n\t\t\t\t\tawait tx.create({ model: \"user\", data: user1, forceAllowId: true });\n\t\t\t\t\tconst users = await tx.findMany({ model: \"user\" });\n\t\t\t\t\texpect(users).toHaveLength(1);\n\t\t\t\t\tthrow new Error(\"Simulated failure\");\n\t\t\t\t\tawait tx.create({ model: \"user\", data: user2, forceAllowId: true });\n\t\t\t\t}),\n\t\t\t).rejects.toThrow(\"Simulated failure\");\n\t\t\tconst result = await adapter.findMany<User>({\n\t\t\t\tmodel: \"user\",\n\t\t\t});\n\t\t\t//Transactions made rows are unable to be automatically cleaned up, so we need to clean them up manually\n\t\t\tawait hardCleanup();\n\t\t\texpect(result.length).toBe(0);\n\t\t},\n\t}),\n);\n"],"mappings":";;;;;;AAOA,MAAa,wBAAwB,gBACpC,gBACA,EAAE,GACD,EAAE,SAAS,UAAU,mBAAmB,EACxC,qDAAqD,OAAO,EAAE,WAAW;AAExE,KAAI,CADc,QAAQ,SAAS,cAAc,aACjC;AACf,OACC,kBAAkB,QAAQ,SAAS,cAAc,YAAY,gCAC7D;AACD;;CAGD,MAAM,QAAQ,MAAM,SAAS,OAAO;AACtB,OAAM,SAAS,OAAO;AACpC,OAAM,OACL,QAAQ,YAAY,OAAO,OAAO;AACjC,QAAM,GAAG,OAAO;GAAE,OAAO;GAAQ,MAAM;GAAO,cAAc;GAAM,CAAC;AAEnE,SADc,MAAM,GAAG,SAAS,EAAE,OAAO,QAAQ,CAAC,CACrC,CAAC,aAAa,EAAE;AAC7B,QAAM,IAAI,MAAM,oBAAoB;GAEnC,CACF,CAAC,QAAQ,QAAQ,oBAAoB;CACtC,MAAM,SAAS,MAAM,QAAQ,SAAe,EAC3C,OAAO,QACP,CAAC;AAEF,OAAM,aAAa;AACnB,QAAO,OAAO,OAAO,CAAC,KAAK,EAAE;GAE9B,EACD"}
|
package/dist/suites/uuid.d.mts
CHANGED
|
@@ -4,7 +4,7 @@ import * as better_auth0 from "better-auth";
|
|
|
4
4
|
|
|
5
5
|
//#region src/adapter/suites/uuid.d.ts
|
|
6
6
|
declare const uuidTestSuite: (options?: {
|
|
7
|
-
disableTests?: Partial<Record<"init - tests" | "create - should create a model" | "create - should always return an id" | "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" | "create - should return a uuid" | "findOne - should find a model using a uuid", boolean> & {
|
|
7
|
+
disableTests?: Partial<Record<"init - tests" | "create - should create a model" | "create - should always return an id" | "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" | "create - should return a uuid" | "findOne - should find a model using a uuid", boolean> & {
|
|
8
8
|
ALL?: boolean;
|
|
9
9
|
}> | undefined;
|
|
10
10
|
} | undefined) => (helpers: {
|
package/dist/suites/uuid.mjs
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { createTestSuite } from "../create-test-suite.mjs";
|
|
2
2
|
import { getNormalTestSuiteTests } from "./basic.mjs";
|
|
3
3
|
import { expect } from "vitest";
|
|
4
|
-
|
|
5
4
|
//#region src/adapter/suites/uuid.ts
|
|
6
5
|
const uuidTestSuite = createTestSuite("uuid", {
|
|
7
6
|
defaultBetterAuthOptions: { advanced: { database: { generateId: "uuid" } } },
|
|
@@ -49,7 +48,7 @@ const uuidTestSuite = createTestSuite("uuid", {
|
|
|
49
48
|
...normalTests
|
|
50
49
|
};
|
|
51
50
|
});
|
|
52
|
-
|
|
53
51
|
//#endregion
|
|
54
52
|
export { uuidTestSuite };
|
|
53
|
+
|
|
55
54
|
//# sourceMappingURL=uuid.mjs.map
|
package/dist/suites/uuid.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uuid.mjs","names":[],"sources":["../../src/adapter/suites/uuid.ts"],"sourcesContent":["import type { User } from \"@better-auth/core/db\";\nimport { expect } from \"vitest\";\nimport { createTestSuite } from \"../create-test-suite\";\nimport { getNormalTestSuiteTests } from \"./basic\";\n\nexport const uuidTestSuite = createTestSuite(\n\t\"uuid\",\n\t{\n\t\tdefaultBetterAuthOptions: {\n\t\t\tadvanced: {\n\t\t\t\tdatabase: {\n\t\t\t\t\tgenerateId: \"uuid\",\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\tprefixTests: \"uuid\",\n\t\talwaysMigrate: true,\n\t\t// This is here to overwrite `generateId` functions to generate UUIDs instead of the default.\n\t\t// Since existing tests often use generated IDs as well as `forceAllowId` to be true, this is needed to ensure the tests pass.\n\t\tcustomIdGenerator() {\n\t\t\treturn crypto.randomUUID();\n\t\t},\n\t},\n\t(helpers) => {\n\t\tconst { \"create - should use generateId if provided\": _, ...normalTests } =\n\t\t\tgetNormalTestSuiteTests(helpers);\n\t\treturn {\n\t\t\t\"init - tests\": async () => {\n\t\t\t\tconst opts = helpers.getBetterAuthOptions();\n\t\t\t\texpect(opts.advanced?.database?.generateId === \"uuid\").toBe(true);\n\t\t\t},\n\t\t\t\"create - should return a uuid\": async () => {\n\t\t\t\tconst user = await helpers.generate(\"user\");\n\t\t\t\tconst res = await helpers.adapter.create<User>({\n\t\t\t\t\tmodel: \"user\",\n\t\t\t\t\tdata: {\n\t\t\t\t\t\t...user,\n\t\t\t\t\t\t//@ts-expect-error - remove id from `user`\n\t\t\t\t\t\tid: undefined,\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t\texpect(res).toHaveProperty(\"id\");\n\t\t\t\texpect(typeof res.id).toBe(\"string\");\n\t\t\t\tconst uuidRegex =\n\t\t\t\t\t/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\n\t\t\t\texpect(res.id).toMatch(uuidRegex);\n\t\t\t\tconsole.log(res);\n\t\t\t},\n\t\t\t\"findOne - should find a model using a uuid\": async () => {\n\t\t\t\tconst { id: _, ...user } = await helpers.generate(\"user\");\n\t\t\t\tconst res = await helpers.adapter.create<User>({\n\t\t\t\t\tmodel: \"user\",\n\t\t\t\t\tdata: user,\n\t\t\t\t});\n\n\t\t\t\tconst result = await helpers.adapter.findOne<User>({\n\t\t\t\t\tmodel: \"user\",\n\t\t\t\t\twhere: [{ field: \"id\", value: res.id }],\n\t\t\t\t});\n\t\t\t\tconst uuidRegex =\n\t\t\t\t\t/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\n\t\t\t\texpect(result?.id).toMatch(uuidRegex);\n\t\t\t\texpect(result).toEqual(res);\n\t\t\t},\n\t\t\t...normalTests,\n\t\t};\n\t},\n);\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"uuid.mjs","names":[],"sources":["../../src/adapter/suites/uuid.ts"],"sourcesContent":["import type { User } from \"@better-auth/core/db\";\nimport { expect } from \"vitest\";\nimport { createTestSuite } from \"../create-test-suite\";\nimport { getNormalTestSuiteTests } from \"./basic\";\n\nexport const uuidTestSuite = createTestSuite(\n\t\"uuid\",\n\t{\n\t\tdefaultBetterAuthOptions: {\n\t\t\tadvanced: {\n\t\t\t\tdatabase: {\n\t\t\t\t\tgenerateId: \"uuid\",\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\tprefixTests: \"uuid\",\n\t\talwaysMigrate: true,\n\t\t// This is here to overwrite `generateId` functions to generate UUIDs instead of the default.\n\t\t// Since existing tests often use generated IDs as well as `forceAllowId` to be true, this is needed to ensure the tests pass.\n\t\tcustomIdGenerator() {\n\t\t\treturn crypto.randomUUID();\n\t\t},\n\t},\n\t(helpers) => {\n\t\tconst { \"create - should use generateId if provided\": _, ...normalTests } =\n\t\t\tgetNormalTestSuiteTests(helpers);\n\t\treturn {\n\t\t\t\"init - tests\": async () => {\n\t\t\t\tconst opts = helpers.getBetterAuthOptions();\n\t\t\t\texpect(opts.advanced?.database?.generateId === \"uuid\").toBe(true);\n\t\t\t},\n\t\t\t\"create - should return a uuid\": async () => {\n\t\t\t\tconst user = await helpers.generate(\"user\");\n\t\t\t\tconst res = await helpers.adapter.create<User>({\n\t\t\t\t\tmodel: \"user\",\n\t\t\t\t\tdata: {\n\t\t\t\t\t\t...user,\n\t\t\t\t\t\t//@ts-expect-error - remove id from `user`\n\t\t\t\t\t\tid: undefined,\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t\texpect(res).toHaveProperty(\"id\");\n\t\t\t\texpect(typeof res.id).toBe(\"string\");\n\t\t\t\tconst uuidRegex =\n\t\t\t\t\t/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\n\t\t\t\texpect(res.id).toMatch(uuidRegex);\n\t\t\t\tconsole.log(res);\n\t\t\t},\n\t\t\t\"findOne - should find a model using a uuid\": async () => {\n\t\t\t\tconst { id: _, ...user } = await helpers.generate(\"user\");\n\t\t\t\tconst res = await helpers.adapter.create<User>({\n\t\t\t\t\tmodel: \"user\",\n\t\t\t\t\tdata: user,\n\t\t\t\t});\n\n\t\t\t\tconst result = await helpers.adapter.findOne<User>({\n\t\t\t\t\tmodel: \"user\",\n\t\t\t\t\twhere: [{ field: \"id\", value: res.id }],\n\t\t\t\t});\n\t\t\t\tconst uuidRegex =\n\t\t\t\t\t/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\n\t\t\t\texpect(result?.id).toMatch(uuidRegex);\n\t\t\t\texpect(result).toEqual(res);\n\t\t\t},\n\t\t\t...normalTests,\n\t\t};\n\t},\n);\n"],"mappings":";;;;AAKA,MAAa,gBAAgB,gBAC5B,QACA;CACC,0BAA0B,EACzB,UAAU,EACT,UAAU,EACT,YAAY,QACZ,EACD,EACD;CACD,aAAa;CACb,eAAe;CAGf,oBAAoB;AACnB,SAAO,OAAO,YAAY;;CAE3B,GACA,YAAY;CACZ,MAAM,EAAE,8CAA8C,GAAG,GAAG,gBAC3D,wBAAwB,QAAQ;AACjC,QAAO;EACN,gBAAgB,YAAY;AAE3B,UADa,QAAQ,sBAAsB,CAC/B,UAAU,UAAU,eAAe,OAAO,CAAC,KAAK,KAAK;;EAElE,iCAAiC,YAAY;GAC5C,MAAM,OAAO,MAAM,QAAQ,SAAS,OAAO;GAC3C,MAAM,MAAM,MAAM,QAAQ,QAAQ,OAAa;IAC9C,OAAO;IACP,MAAM;KACL,GAAG;KAEH,IAAI,KAAA;KACJ;IACD,CAAC;AACF,UAAO,IAAI,CAAC,eAAe,KAAK;AAChC,UAAO,OAAO,IAAI,GAAG,CAAC,KAAK,SAAS;AAGpC,UAAO,IAAI,GAAG,CAAC,QADd,kEACgC;AACjC,WAAQ,IAAI,IAAI;;EAEjB,8CAA8C,YAAY;GACzD,MAAM,EAAE,IAAI,GAAG,GAAG,SAAS,MAAM,QAAQ,SAAS,OAAO;GACzD,MAAM,MAAM,MAAM,QAAQ,QAAQ,OAAa;IAC9C,OAAO;IACP,MAAM;IACN,CAAC;GAEF,MAAM,SAAS,MAAM,QAAQ,QAAQ,QAAc;IAClD,OAAO;IACP,OAAO,CAAC;KAAE,OAAO;KAAM,OAAO,IAAI;KAAI,CAAC;IACvC,CAAC;AAGF,UAAO,QAAQ,GAAG,CAAC,QADlB,kEACoC;AACrC,UAAO,OAAO,CAAC,QAAQ,IAAI;;EAE5B,GAAG;EACH;EAEF"}
|
package/dist/test-adapter.mjs
CHANGED
|
@@ -2,7 +2,6 @@ import { deepmerge, initGetModelName } from "@better-auth/core/db/adapter";
|
|
|
2
2
|
import { TTY_COLORS } from "@better-auth/core/env";
|
|
3
3
|
import { afterAll, beforeAll, describe } from "vitest";
|
|
4
4
|
import { getAuthTables } from "better-auth/db";
|
|
5
|
-
|
|
6
5
|
//#region src/adapter/test-adapter.ts
|
|
7
6
|
const testAdapter = async ({ adapter: getAdapter, runMigrations, overrideBetterAuthOptions, additionalCleanups, tests, prefixTests, onFinish, customIdGenerator, transformIdOutput }) => {
|
|
8
7
|
const defaultBAOptions = {};
|
|
@@ -157,7 +156,7 @@ const testAdapter = async ({ adapter: getAdapter, runMigrations, overrideBetterA
|
|
|
157
156
|
});
|
|
158
157
|
} };
|
|
159
158
|
};
|
|
160
|
-
|
|
161
159
|
//#endregion
|
|
162
160
|
export { testAdapter };
|
|
161
|
+
|
|
163
162
|
//# sourceMappingURL=test-adapter.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-adapter.mjs","names":[],"sources":["../src/adapter/test-adapter.ts"],"sourcesContent":["import type { Awaitable, BetterAuthOptions } from \"@better-auth/core\";\nimport type { DBAdapter } from \"@better-auth/core/db/adapter\";\nimport { deepmerge, initGetModelName } from \"@better-auth/core/db/adapter\";\nimport { TTY_COLORS } from \"@better-auth/core/env\";\nimport { getAuthTables } from \"better-auth/db\";\nimport { afterAll, beforeAll, describe } from \"vitest\";\nimport type { createTestSuite, TestSuiteStats } from \"./create-test-suite\";\n\nexport type Logger = {\n\tinfo: (...args: any[]) => void;\n\tsuccess: (...args: any[]) => void;\n\twarn: (...args: any[]) => void;\n\terror: (...args: any[]) => void;\n\tdebug: (...args: any[]) => void;\n};\n\nexport const testAdapter = async ({\n\tadapter: getAdapter,\n\trunMigrations,\n\toverrideBetterAuthOptions,\n\tadditionalCleanups,\n\ttests,\n\tprefixTests,\n\tonFinish,\n\tcustomIdGenerator,\n\ttransformIdOutput,\n}: {\n\t/**\n\t * A function that will return the adapter instance to test with.\n\t *\n\t * @example\n\t * ```ts\n\t * testAdapter({\n\t * adapter: (options) => drizzleAdapter(drizzle(db), {\n\t * schema: generateSchema(options),\n\t * }),\n\t * })\n\t */\n\tadapter: (\n\t\toptions: BetterAuthOptions,\n\t) => Awaitable<(options: BetterAuthOptions) => DBAdapter<BetterAuthOptions>>;\n\t/**\n\t * A function that will run the database migrations.\n\t */\n\trunMigrations: (betterAuthOptions: BetterAuthOptions) => Promise<void> | void;\n\t/**\n\t * Any potential better-auth options overrides.\n\t */\n\toverrideBetterAuthOptions?: (\n\t\tbetterAuthOptions: BetterAuthOptions,\n\t) => BetterAuthOptions;\n\t/**\n\t * By default we will cleanup all tables automatically,\n\t * but if you have additional cleanup logic, you can pass it here.\n\t *\n\t * Such as deleting a DB file that could had been created.\n\t */\n\tadditionalCleanups?: () => Promise<void> | void;\n\t/**\n\t * A test suite to run.\n\t */\n\ttests: ReturnType<ReturnType<typeof createTestSuite>>[];\n\t/**\n\t * A prefix to add to the test suite name.\n\t */\n\tprefixTests?: string;\n\t/**\n\t * Upon finish of the tests, this function will be called.\n\t */\n\tonFinish?: () => Promise<void> | void;\n\t/**\n\t * Custom ID generator function to be used by the helper functions. (such as `insertRandom`)\n\t */\n\tcustomIdGenerator?: () => any;\n\t/**\n\t * A function that will transform the ID output.\n\t */\n\ttransformIdOutput?: (id: any) => any;\n}) => {\n\tconst defaultBAOptions = {} satisfies BetterAuthOptions;\n\tlet betterAuthOptions = (() => {\n\t\treturn {\n\t\t\t...defaultBAOptions,\n\t\t\t...(overrideBetterAuthOptions?.(defaultBAOptions) || {}),\n\t\t} satisfies BetterAuthOptions;\n\t})();\n\n\tlet adapter: DBAdapter<BetterAuthOptions> = (\n\t\tawait getAdapter(betterAuthOptions)\n\t)(betterAuthOptions);\n\n\tconst adapterName = adapter.options?.adapterConfig.adapterName;\n\tconst adapterId = adapter.options?.adapterConfig.adapterId || adapter.id;\n\tconst adapterDisplayName = adapterName || adapterId;\n\n\tconst refreshAdapter = async (betterAuthOptions: BetterAuthOptions) => {\n\t\tadapter = (await getAdapter(betterAuthOptions))(betterAuthOptions);\n\t};\n\n\t/**\n\t * A helper function to log to the console.\n\t */\n\tconst log: Logger = (() => {\n\t\treturn {\n\t\t\tinfo: (...args: any[]) =>\n\t\t\t\tconsole.log(\n\t\t\t\t\t`${TTY_COLORS.fg.blue}INFO ${TTY_COLORS.reset} [${adapterDisplayName}]`,\n\t\t\t\t\t...args,\n\t\t\t\t),\n\t\t\tsuccess: (...args: any[]) =>\n\t\t\t\tconsole.log(\n\t\t\t\t\t`${TTY_COLORS.fg.green}SUCCESS${TTY_COLORS.reset} [${adapterDisplayName}]`,\n\t\t\t\t\t...args,\n\t\t\t\t),\n\t\t\twarn: (...args: any[]) =>\n\t\t\t\tconsole.log(\n\t\t\t\t\t`${TTY_COLORS.fg.yellow}WARN ${TTY_COLORS.reset} [${adapterDisplayName}]`,\n\t\t\t\t\t...args,\n\t\t\t\t),\n\t\t\terror: (...args: any[]) =>\n\t\t\t\tconsole.log(\n\t\t\t\t\t`${TTY_COLORS.fg.red}ERROR ${TTY_COLORS.reset} [${adapterDisplayName}]`,\n\t\t\t\t\t...args,\n\t\t\t\t),\n\t\t\tdebug: (...args: any[]) =>\n\t\t\t\tconsole.log(\n\t\t\t\t\t`${TTY_COLORS.fg.magenta}DEBUG ${TTY_COLORS.reset} [${adapterDisplayName}]`,\n\t\t\t\t\t...args,\n\t\t\t\t),\n\t\t};\n\t})();\n\n\t/**\n\t * Cleanup function to remove all rows from the database.\n\t */\n\tconst cleanup = async () => {\n\t\tconst start = performance.now();\n\t\tawait refreshAdapter(betterAuthOptions);\n\t\tconst getAllModels = getAuthTables(betterAuthOptions);\n\n\t\t// Clean up all rows from all models\n\t\tfor (const model of Object.keys(getAllModels)) {\n\t\t\tconst getModelName = initGetModelName({\n\t\t\t\tusePlural: adapter.options?.adapterConfig?.usePlural,\n\t\t\t\tschema: getAllModels,\n\t\t\t});\n\t\t\ttry {\n\t\t\t\tconst modelName = getModelName(model);\n\t\t\t\tawait adapter.deleteMany({ model: modelName, where: [] });\n\t\t\t} catch (error) {\n\t\t\t\tconst msg = `Error while cleaning up all rows from ${model}`;\n\t\t\t\tlog.error(msg, error);\n\t\t\t\tthrow new Error(msg, {\n\t\t\t\t\tcause: error,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\t// Run additional cleanups\n\t\ttry {\n\t\t\tawait additionalCleanups?.();\n\t\t} catch (error) {\n\t\t\tconst msg = `Error while running additional cleanups`;\n\t\t\tlog.error(msg, error);\n\t\t\tthrow new Error(msg, {\n\t\t\t\tcause: error,\n\t\t\t});\n\t\t}\n\t\tawait refreshAdapter(betterAuthOptions);\n\t\tlog.success(\n\t\t\t`${TTY_COLORS.bright}CLEAN-UP${TTY_COLORS.reset} completed successfully (${(performance.now() - start).toFixed(3)}ms)`,\n\t\t);\n\t};\n\n\t/**\n\t * A function that will run the database migrations.\n\t */\n\tconst migrate = async () => {\n\t\tconst start = performance.now();\n\n\t\ttry {\n\t\t\tawait runMigrations(betterAuthOptions);\n\t\t} catch (error) {\n\t\t\tconst msg = `Error while running migrations`;\n\t\t\tlog.error(msg, error);\n\t\t\tthrow new Error(msg, {\n\t\t\t\tcause: error,\n\t\t\t});\n\t\t}\n\t\tlog.success(\n\t\t\t`${TTY_COLORS.bright}MIGRATIONS${TTY_COLORS.reset} completed successfully (${(performance.now() - start).toFixed(3)}ms)`,\n\t\t);\n\t};\n\n\treturn {\n\t\texecute: () => {\n\t\t\tdescribe(adapterDisplayName, async () => {\n\t\t\t\t// Collect statistics from all test suites\n\t\t\t\tconst allSuiteStats: TestSuiteStats[] = [];\n\n\t\t\t\tbeforeAll(async () => {\n\t\t\t\t\tawait migrate();\n\t\t\t\t}, 60000);\n\n\t\t\t\tafterAll(async () => {\n\t\t\t\t\tawait cleanup();\n\n\t\t\t\t\t// Display statistics summary\n\t\t\t\t\tif (allSuiteStats.length > 0) {\n\t\t\t\t\t\tconst totalMigrations = allSuiteStats.reduce(\n\t\t\t\t\t\t\t(sum, stats) => sum + stats.migrationCount,\n\t\t\t\t\t\t\t0,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconst totalMigrationTime = allSuiteStats.reduce(\n\t\t\t\t\t\t\t(sum, stats) => sum + stats.totalMigrationTime,\n\t\t\t\t\t\t\t0,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconst totalTests = allSuiteStats.reduce(\n\t\t\t\t\t\t\t(sum, stats) => sum + stats.testCount,\n\t\t\t\t\t\t\t0,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconst totalDuration = allSuiteStats.reduce(\n\t\t\t\t\t\t\t(sum, stats) => sum + stats.suiteDuration,\n\t\t\t\t\t\t\t0,\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tconst dash = \"─\";\n\t\t\t\t\t\tconst separator = `${dash.repeat(80)}`;\n\n\t\t\t\t\t\tconsole.log(`\\n${TTY_COLORS.fg.cyan}${separator}`);\n\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t`${TTY_COLORS.fg.cyan}${TTY_COLORS.bright}TEST SUITE STATISTICS SUMMARY${TTY_COLORS.reset}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t`${TTY_COLORS.fg.cyan}${separator}${TTY_COLORS.reset}\\n`,\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\t// Per-suite breakdown\n\t\t\t\t\t\tfor (const stats of allSuiteStats) {\n\t\t\t\t\t\t\tconst avgMigrationTime =\n\t\t\t\t\t\t\t\tstats.migrationCount > 0\n\t\t\t\t\t\t\t\t\t? (stats.totalMigrationTime / stats.migrationCount).toFixed(2)\n\t\t\t\t\t\t\t\t\t: \"0.00\";\n\t\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t\t`${TTY_COLORS.fg.magenta}${stats.suiteName}${TTY_COLORS.reset}:`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t\t` Tests: ${TTY_COLORS.fg.green}${stats.testCount}${TTY_COLORS.reset}`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t\t` Migrations: ${TTY_COLORS.fg.yellow}${stats.migrationCount}${TTY_COLORS.reset} (avg: ${avgMigrationTime}ms)`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t\t` Total Migration Time: ${TTY_COLORS.fg.yellow}${stats.totalMigrationTime.toFixed(2)}ms${TTY_COLORS.reset}`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t\t` Suite Duration: ${TTY_COLORS.fg.blue}${stats.suiteDuration.toFixed(2)}ms${TTY_COLORS.reset}`,\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t// Display grouping statistics if available\n\t\t\t\t\t\t\tif (stats.groupingStats) {\n\t\t\t\t\t\t\t\tconst {\n\t\t\t\t\t\t\t\t\ttotalGroups,\n\t\t\t\t\t\t\t\t\taverageTestsPerGroup,\n\t\t\t\t\t\t\t\t\tlargestGroupSize,\n\t\t\t\t\t\t\t\t\tsmallestGroupSize,\n\t\t\t\t\t\t\t\t\tgroupsWithMultipleTests,\n\t\t\t\t\t\t\t\t} = stats.groupingStats;\n\t\t\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t\t\t` Test Groups: ${TTY_COLORS.fg.cyan}${totalGroups}${TTY_COLORS.reset}`,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tif (totalGroups > 0) {\n\t\t\t\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t\t\t\t` Avg Tests/Group: ${TTY_COLORS.fg.cyan}${averageTestsPerGroup.toFixed(2)}${TTY_COLORS.reset}`,\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t\t\t\t` Largest Group: ${TTY_COLORS.fg.cyan}${largestGroupSize}${TTY_COLORS.reset}`,\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t\t\t\t` Smallest Group: ${TTY_COLORS.fg.cyan}${smallestGroupSize}${TTY_COLORS.reset}`,\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t\t\t\t` Groups w/ Multiple Tests: ${TTY_COLORS.fg.cyan}${groupsWithMultipleTests}${TTY_COLORS.reset}`,\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tconsole.log(\"\");\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Totals\n\t\t\t\t\t\tconst avgMigrationTime =\n\t\t\t\t\t\t\ttotalMigrations > 0\n\t\t\t\t\t\t\t\t? (totalMigrationTime / totalMigrations).toFixed(2)\n\t\t\t\t\t\t\t\t: \"0.00\";\n\n\t\t\t\t\t\t// Calculate total grouping statistics\n\t\t\t\t\t\tconst totalGroups = allSuiteStats.reduce(\n\t\t\t\t\t\t\t(sum, stats) => sum + (stats.groupingStats?.totalGroups || 0),\n\t\t\t\t\t\t\t0,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconst totalGroupsWithMultipleTests = allSuiteStats.reduce(\n\t\t\t\t\t\t\t(sum, stats) =>\n\t\t\t\t\t\t\t\tsum + (stats.groupingStats?.groupsWithMultipleTests || 0),\n\t\t\t\t\t\t\t0,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconst totalTestsInGroups = allSuiteStats.reduce(\n\t\t\t\t\t\t\t(sum, stats) =>\n\t\t\t\t\t\t\t\tsum + (stats.groupingStats?.totalTestsInGroups || 0),\n\t\t\t\t\t\t\t0,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconst avgTestsPerGroup =\n\t\t\t\t\t\t\ttotalGroups > 0 ? totalTestsInGroups / totalGroups : 0;\n\n\t\t\t\t\t\tconsole.log(`${TTY_COLORS.fg.cyan}${separator}`);\n\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t`${TTY_COLORS.fg.cyan}${TTY_COLORS.bright}TOTALS${TTY_COLORS.reset}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t` Total Tests: ${TTY_COLORS.fg.green}${totalTests}${TTY_COLORS.reset}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t` Total Migrations: ${TTY_COLORS.fg.yellow}${totalMigrations}${TTY_COLORS.reset} (avg: ${avgMigrationTime}ms)`,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t` Total Migration Time: ${TTY_COLORS.fg.yellow}${totalMigrationTime.toFixed(2)}ms${TTY_COLORS.reset}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t` Total Duration: ${TTY_COLORS.fg.blue}${totalDuration.toFixed(2)}ms${TTY_COLORS.reset}`,\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\t// Display total grouping statistics\n\t\t\t\t\t\tif (totalGroups > 0) {\n\t\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t\t` Total Test Groups: ${TTY_COLORS.fg.cyan}${totalGroups}${TTY_COLORS.reset}`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t\t` Avg Tests/Group: ${TTY_COLORS.fg.cyan}${avgTestsPerGroup.toFixed(2)}${TTY_COLORS.reset}`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t\t` Groups w/ Multiple Tests: ${TTY_COLORS.fg.cyan}${totalGroupsWithMultipleTests}${TTY_COLORS.reset}`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t`${TTY_COLORS.fg.cyan}${separator}${TTY_COLORS.reset}\\n`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tawait onFinish?.();\n\t\t\t\t}, 60000);\n\n\t\t\t\tfor (const testSuite of tests) {\n\t\t\t\t\tawait testSuite({\n\t\t\t\t\t\tadapter: async () => {\n\t\t\t\t\t\t\tawait refreshAdapter(betterAuthOptions);\n\t\t\t\t\t\t\treturn adapter;\n\t\t\t\t\t\t},\n\t\t\t\t\t\tadapterDisplayName,\n\t\t\t\t\t\tlog,\n\t\t\t\t\t\tgetBetterAuthOptions: () => betterAuthOptions,\n\t\t\t\t\t\tmodifyBetterAuthOptions: async (options) => {\n\t\t\t\t\t\t\tconst newOptions = deepmerge(defaultBAOptions, options);\n\t\t\t\t\t\t\tbetterAuthOptions = deepmerge(\n\t\t\t\t\t\t\t\tnewOptions,\n\t\t\t\t\t\t\t\toverrideBetterAuthOptions?.(newOptions) || {},\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tawait refreshAdapter(betterAuthOptions);\n\t\t\t\t\t\t\treturn betterAuthOptions;\n\t\t\t\t\t\t},\n\t\t\t\t\t\tcleanup,\n\t\t\t\t\t\tprefixTests,\n\t\t\t\t\t\trunMigrations: migrate,\n\t\t\t\t\t\tonTestFinish: async (stats: TestSuiteStats) => {\n\t\t\t\t\t\t\tallSuiteStats.push(stats);\n\t\t\t\t\t\t},\n\t\t\t\t\t\tcustomIdGenerator,\n\t\t\t\t\t\ttransformIdOutput,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t});\n\t\t},\n\t};\n};\n"],"mappings":";;;;;;AAgBA,MAAa,cAAc,OAAO,EACjC,SAAS,YACT,eACA,2BACA,oBACA,OACA,aACA,UACA,mBACA,wBAqDK;CACL,MAAM,mBAAmB,EAAE;CAC3B,IAAI,oBACI;EACN,GAAG;EACH,GAAI,4BAA4B,iBAAiB,IAAI,EAAE;EACvD;CAGF,IAAI,WACH,MAAM,WAAW,kBAAkB,EAClC,kBAAkB;CAEpB,MAAM,cAAc,QA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M,eAAe,kBAAkB;AACvC,YAAO;;IAER;IACA;IACA,eAAe;IACf,cAAc,OAAO,UAA0B;AAC9C,mBAAc,KAAK,MAAM;;IAE1B;IACA;IACA,CAAC;IAEF;IAEH"}
|
|
1
|
+
{"version":3,"file":"test-adapter.mjs","names":[],"sources":["../src/adapter/test-adapter.ts"],"sourcesContent":["import type { Awaitable, BetterAuthOptions } from \"@better-auth/core\";\nimport type { DBAdapter } from \"@better-auth/core/db/adapter\";\nimport { deepmerge, initGetModelName } from \"@better-auth/core/db/adapter\";\nimport { TTY_COLORS } from \"@better-auth/core/env\";\nimport { getAuthTables } from \"better-auth/db\";\nimport { afterAll, beforeAll, describe } from \"vitest\";\nimport type { createTestSuite, TestSuiteStats } from \"./create-test-suite\";\n\nexport type Logger = {\n\tinfo: (...args: any[]) => void;\n\tsuccess: (...args: any[]) => void;\n\twarn: (...args: any[]) => void;\n\terror: (...args: any[]) => void;\n\tdebug: (...args: any[]) => void;\n};\n\nexport const testAdapter = async ({\n\tadapter: getAdapter,\n\trunMigrations,\n\toverrideBetterAuthOptions,\n\tadditionalCleanups,\n\ttests,\n\tprefixTests,\n\tonFinish,\n\tcustomIdGenerator,\n\ttransformIdOutput,\n}: {\n\t/**\n\t * A function that will return the adapter instance to test with.\n\t *\n\t * @example\n\t * ```ts\n\t * testAdapter({\n\t * adapter: (options) => drizzleAdapter(drizzle(db), {\n\t * schema: generateSchema(options),\n\t * }),\n\t * })\n\t */\n\tadapter: (\n\t\toptions: BetterAuthOptions,\n\t) => Awaitable<(options: BetterAuthOptions) => DBAdapter<BetterAuthOptions>>;\n\t/**\n\t * A function that will run the database migrations.\n\t */\n\trunMigrations: (betterAuthOptions: BetterAuthOptions) => Promise<void> | void;\n\t/**\n\t * Any potential better-auth options overrides.\n\t */\n\toverrideBetterAuthOptions?: (\n\t\tbetterAuthOptions: BetterAuthOptions,\n\t) => BetterAuthOptions;\n\t/**\n\t * By default we will cleanup all tables automatically,\n\t * but if you have additional cleanup logic, you can pass it here.\n\t *\n\t * Such as deleting a DB file that could had been created.\n\t */\n\tadditionalCleanups?: () => Promise<void> | void;\n\t/**\n\t * A test suite to run.\n\t */\n\ttests: ReturnType<ReturnType<typeof createTestSuite>>[];\n\t/**\n\t * A prefix to add to the test suite name.\n\t */\n\tprefixTests?: string;\n\t/**\n\t * Upon finish of the tests, this function will be called.\n\t */\n\tonFinish?: () => Promise<void> | void;\n\t/**\n\t * Custom ID generator function to be used by the helper functions. (such as `insertRandom`)\n\t */\n\tcustomIdGenerator?: () => any;\n\t/**\n\t * A function that will transform the ID output.\n\t */\n\ttransformIdOutput?: (id: any) => any;\n}) => {\n\tconst defaultBAOptions = {} satisfies BetterAuthOptions;\n\tlet betterAuthOptions = (() => {\n\t\treturn {\n\t\t\t...defaultBAOptions,\n\t\t\t...(overrideBetterAuthOptions?.(defaultBAOptions) || {}),\n\t\t} satisfies BetterAuthOptions;\n\t})();\n\n\tlet adapter: DBAdapter<BetterAuthOptions> = (\n\t\tawait getAdapter(betterAuthOptions)\n\t)(betterAuthOptions);\n\n\tconst adapterName = adapter.options?.adapterConfig.adapterName;\n\tconst adapterId = adapter.options?.adapterConfig.adapterId || adapter.id;\n\tconst adapterDisplayName = adapterName || adapterId;\n\n\tconst refreshAdapter = async (betterAuthOptions: BetterAuthOptions) => {\n\t\tadapter = (await getAdapter(betterAuthOptions))(betterAuthOptions);\n\t};\n\n\t/**\n\t * A helper function to log to the console.\n\t */\n\tconst log: Logger = (() => {\n\t\treturn {\n\t\t\tinfo: (...args: any[]) =>\n\t\t\t\tconsole.log(\n\t\t\t\t\t`${TTY_COLORS.fg.blue}INFO ${TTY_COLORS.reset} [${adapterDisplayName}]`,\n\t\t\t\t\t...args,\n\t\t\t\t),\n\t\t\tsuccess: (...args: any[]) =>\n\t\t\t\tconsole.log(\n\t\t\t\t\t`${TTY_COLORS.fg.green}SUCCESS${TTY_COLORS.reset} [${adapterDisplayName}]`,\n\t\t\t\t\t...args,\n\t\t\t\t),\n\t\t\twarn: (...args: any[]) =>\n\t\t\t\tconsole.log(\n\t\t\t\t\t`${TTY_COLORS.fg.yellow}WARN ${TTY_COLORS.reset} [${adapterDisplayName}]`,\n\t\t\t\t\t...args,\n\t\t\t\t),\n\t\t\terror: (...args: any[]) =>\n\t\t\t\tconsole.log(\n\t\t\t\t\t`${TTY_COLORS.fg.red}ERROR ${TTY_COLORS.reset} [${adapterDisplayName}]`,\n\t\t\t\t\t...args,\n\t\t\t\t),\n\t\t\tdebug: (...args: any[]) =>\n\t\t\t\tconsole.log(\n\t\t\t\t\t`${TTY_COLORS.fg.magenta}DEBUG ${TTY_COLORS.reset} [${adapterDisplayName}]`,\n\t\t\t\t\t...args,\n\t\t\t\t),\n\t\t};\n\t})();\n\n\t/**\n\t * Cleanup function to remove all rows from the database.\n\t */\n\tconst cleanup = async () => {\n\t\tconst start = performance.now();\n\t\tawait refreshAdapter(betterAuthOptions);\n\t\tconst getAllModels = getAuthTables(betterAuthOptions);\n\n\t\t// Clean up all rows from all models\n\t\tfor (const model of Object.keys(getAllModels)) {\n\t\t\tconst getModelName = initGetModelName({\n\t\t\t\tusePlural: adapter.options?.adapterConfig?.usePlural,\n\t\t\t\tschema: getAllModels,\n\t\t\t});\n\t\t\ttry {\n\t\t\t\tconst modelName = getModelName(model);\n\t\t\t\tawait adapter.deleteMany({ model: modelName, where: [] });\n\t\t\t} catch (error) {\n\t\t\t\tconst msg = `Error while cleaning up all rows from ${model}`;\n\t\t\t\tlog.error(msg, error);\n\t\t\t\tthrow new Error(msg, {\n\t\t\t\t\tcause: error,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\t// Run additional cleanups\n\t\ttry {\n\t\t\tawait additionalCleanups?.();\n\t\t} catch (error) {\n\t\t\tconst msg = `Error while running additional cleanups`;\n\t\t\tlog.error(msg, error);\n\t\t\tthrow new Error(msg, {\n\t\t\t\tcause: error,\n\t\t\t});\n\t\t}\n\t\tawait refreshAdapter(betterAuthOptions);\n\t\tlog.success(\n\t\t\t`${TTY_COLORS.bright}CLEAN-UP${TTY_COLORS.reset} completed successfully (${(performance.now() - start).toFixed(3)}ms)`,\n\t\t);\n\t};\n\n\t/**\n\t * A function that will run the database migrations.\n\t */\n\tconst migrate = async () => {\n\t\tconst start = performance.now();\n\n\t\ttry {\n\t\t\tawait runMigrations(betterAuthOptions);\n\t\t} catch (error) {\n\t\t\tconst msg = `Error while running migrations`;\n\t\t\tlog.error(msg, error);\n\t\t\tthrow new Error(msg, {\n\t\t\t\tcause: error,\n\t\t\t});\n\t\t}\n\t\tlog.success(\n\t\t\t`${TTY_COLORS.bright}MIGRATIONS${TTY_COLORS.reset} completed successfully (${(performance.now() - start).toFixed(3)}ms)`,\n\t\t);\n\t};\n\n\treturn {\n\t\texecute: () => {\n\t\t\tdescribe(adapterDisplayName, async () => {\n\t\t\t\t// Collect statistics from all test suites\n\t\t\t\tconst allSuiteStats: TestSuiteStats[] = [];\n\n\t\t\t\tbeforeAll(async () => {\n\t\t\t\t\tawait migrate();\n\t\t\t\t}, 60000);\n\n\t\t\t\tafterAll(async () => {\n\t\t\t\t\tawait cleanup();\n\n\t\t\t\t\t// Display statistics summary\n\t\t\t\t\tif (allSuiteStats.length > 0) {\n\t\t\t\t\t\tconst totalMigrations = allSuiteStats.reduce(\n\t\t\t\t\t\t\t(sum, stats) => sum + stats.migrationCount,\n\t\t\t\t\t\t\t0,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconst totalMigrationTime = allSuiteStats.reduce(\n\t\t\t\t\t\t\t(sum, stats) => sum + stats.totalMigrationTime,\n\t\t\t\t\t\t\t0,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconst totalTests = allSuiteStats.reduce(\n\t\t\t\t\t\t\t(sum, stats) => sum + stats.testCount,\n\t\t\t\t\t\t\t0,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconst totalDuration = allSuiteStats.reduce(\n\t\t\t\t\t\t\t(sum, stats) => sum + stats.suiteDuration,\n\t\t\t\t\t\t\t0,\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tconst dash = \"─\";\n\t\t\t\t\t\tconst separator = `${dash.repeat(80)}`;\n\n\t\t\t\t\t\tconsole.log(`\\n${TTY_COLORS.fg.cyan}${separator}`);\n\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t`${TTY_COLORS.fg.cyan}${TTY_COLORS.bright}TEST SUITE STATISTICS SUMMARY${TTY_COLORS.reset}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t`${TTY_COLORS.fg.cyan}${separator}${TTY_COLORS.reset}\\n`,\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\t// Per-suite breakdown\n\t\t\t\t\t\tfor (const stats of allSuiteStats) {\n\t\t\t\t\t\t\tconst avgMigrationTime =\n\t\t\t\t\t\t\t\tstats.migrationCount > 0\n\t\t\t\t\t\t\t\t\t? (stats.totalMigrationTime / stats.migrationCount).toFixed(2)\n\t\t\t\t\t\t\t\t\t: \"0.00\";\n\t\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t\t`${TTY_COLORS.fg.magenta}${stats.suiteName}${TTY_COLORS.reset}:`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t\t` Tests: ${TTY_COLORS.fg.green}${stats.testCount}${TTY_COLORS.reset}`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t\t` Migrations: ${TTY_COLORS.fg.yellow}${stats.migrationCount}${TTY_COLORS.reset} (avg: ${avgMigrationTime}ms)`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t\t` Total Migration Time: ${TTY_COLORS.fg.yellow}${stats.totalMigrationTime.toFixed(2)}ms${TTY_COLORS.reset}`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t\t` Suite Duration: ${TTY_COLORS.fg.blue}${stats.suiteDuration.toFixed(2)}ms${TTY_COLORS.reset}`,\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t// Display grouping statistics if available\n\t\t\t\t\t\t\tif (stats.groupingStats) {\n\t\t\t\t\t\t\t\tconst {\n\t\t\t\t\t\t\t\t\ttotalGroups,\n\t\t\t\t\t\t\t\t\taverageTestsPerGroup,\n\t\t\t\t\t\t\t\t\tlargestGroupSize,\n\t\t\t\t\t\t\t\t\tsmallestGroupSize,\n\t\t\t\t\t\t\t\t\tgroupsWithMultipleTests,\n\t\t\t\t\t\t\t\t} = stats.groupingStats;\n\t\t\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t\t\t` Test Groups: ${TTY_COLORS.fg.cyan}${totalGroups}${TTY_COLORS.reset}`,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tif (totalGroups > 0) {\n\t\t\t\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t\t\t\t` Avg Tests/Group: ${TTY_COLORS.fg.cyan}${averageTestsPerGroup.toFixed(2)}${TTY_COLORS.reset}`,\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t\t\t\t` Largest Group: ${TTY_COLORS.fg.cyan}${largestGroupSize}${TTY_COLORS.reset}`,\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t\t\t\t` Smallest Group: ${TTY_COLORS.fg.cyan}${smallestGroupSize}${TTY_COLORS.reset}`,\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t\t\t\t` Groups w/ Multiple Tests: ${TTY_COLORS.fg.cyan}${groupsWithMultipleTests}${TTY_COLORS.reset}`,\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tconsole.log(\"\");\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Totals\n\t\t\t\t\t\tconst avgMigrationTime =\n\t\t\t\t\t\t\ttotalMigrations > 0\n\t\t\t\t\t\t\t\t? (totalMigrationTime / totalMigrations).toFixed(2)\n\t\t\t\t\t\t\t\t: \"0.00\";\n\n\t\t\t\t\t\t// Calculate total grouping statistics\n\t\t\t\t\t\tconst totalGroups = allSuiteStats.reduce(\n\t\t\t\t\t\t\t(sum, stats) => sum + (stats.groupingStats?.totalGroups || 0),\n\t\t\t\t\t\t\t0,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconst totalGroupsWithMultipleTests = allSuiteStats.reduce(\n\t\t\t\t\t\t\t(sum, stats) =>\n\t\t\t\t\t\t\t\tsum + (stats.groupingStats?.groupsWithMultipleTests || 0),\n\t\t\t\t\t\t\t0,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconst totalTestsInGroups = allSuiteStats.reduce(\n\t\t\t\t\t\t\t(sum, stats) =>\n\t\t\t\t\t\t\t\tsum + (stats.groupingStats?.totalTestsInGroups || 0),\n\t\t\t\t\t\t\t0,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconst avgTestsPerGroup =\n\t\t\t\t\t\t\ttotalGroups > 0 ? totalTestsInGroups / totalGroups : 0;\n\n\t\t\t\t\t\tconsole.log(`${TTY_COLORS.fg.cyan}${separator}`);\n\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t`${TTY_COLORS.fg.cyan}${TTY_COLORS.bright}TOTALS${TTY_COLORS.reset}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t` Total Tests: ${TTY_COLORS.fg.green}${totalTests}${TTY_COLORS.reset}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t` Total Migrations: ${TTY_COLORS.fg.yellow}${totalMigrations}${TTY_COLORS.reset} (avg: ${avgMigrationTime}ms)`,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t` Total Migration Time: ${TTY_COLORS.fg.yellow}${totalMigrationTime.toFixed(2)}ms${TTY_COLORS.reset}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t` Total Duration: ${TTY_COLORS.fg.blue}${totalDuration.toFixed(2)}ms${TTY_COLORS.reset}`,\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\t// Display total grouping statistics\n\t\t\t\t\t\tif (totalGroups > 0) {\n\t\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t\t` Total Test Groups: ${TTY_COLORS.fg.cyan}${totalGroups}${TTY_COLORS.reset}`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t\t` Avg Tests/Group: ${TTY_COLORS.fg.cyan}${avgTestsPerGroup.toFixed(2)}${TTY_COLORS.reset}`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t\t` Groups w/ Multiple Tests: ${TTY_COLORS.fg.cyan}${totalGroupsWithMultipleTests}${TTY_COLORS.reset}`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t`${TTY_COLORS.fg.cyan}${separator}${TTY_COLORS.reset}\\n`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tawait onFinish?.();\n\t\t\t\t}, 60000);\n\n\t\t\t\tfor (const testSuite of tests) {\n\t\t\t\t\tawait testSuite({\n\t\t\t\t\t\tadapter: async () => {\n\t\t\t\t\t\t\tawait refreshAdapter(betterAuthOptions);\n\t\t\t\t\t\t\treturn adapter;\n\t\t\t\t\t\t},\n\t\t\t\t\t\tadapterDisplayName,\n\t\t\t\t\t\tlog,\n\t\t\t\t\t\tgetBetterAuthOptions: () => betterAuthOptions,\n\t\t\t\t\t\tmodifyBetterAuthOptions: async (options) => {\n\t\t\t\t\t\t\tconst newOptions = deepmerge(defaultBAOptions, options);\n\t\t\t\t\t\t\tbetterAuthOptions = deepmerge(\n\t\t\t\t\t\t\t\tnewOptions,\n\t\t\t\t\t\t\t\toverrideBetterAuthOptions?.(newOptions) || {},\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tawait refreshAdapter(betterAuthOptions);\n\t\t\t\t\t\t\treturn betterAuthOptions;\n\t\t\t\t\t\t},\n\t\t\t\t\t\tcleanup,\n\t\t\t\t\t\tprefixTests,\n\t\t\t\t\t\trunMigrations: migrate,\n\t\t\t\t\t\tonTestFinish: async (stats: TestSuiteStats) => {\n\t\t\t\t\t\t\tallSuiteStats.push(stats);\n\t\t\t\t\t\t},\n\t\t\t\t\t\tcustomIdGenerator,\n\t\t\t\t\t\ttransformIdOutput,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t});\n\t\t},\n\t};\n};\n"],"mappings":";;;;;AAgBA,MAAa,cAAc,OAAO,EACjC,SAAS,YACT,eACA,2BACA,oBACA,OACA,aACA,UACA,mBACA,wBAqDK;CACL,MAAM,mBAAmB,EAAE;CAC3B,IAAI,oBACI;EACN,GAAG;EACH,GAAI,4BAA4B,iBAAiB,IAAI,EAAE;EACvD;CAGF,IAAI,WACH,MAAM,WAAW,kBAAkB,EAClC,kBAAkB;CAEpB,MAAM,cAAc,QAAQ,SAAS,cAAc;CACnD,MAAM,YAAY,QAAQ,SAAS,cAAc,aAAa,QAAQ;CACtE,MAAM,qBAAqB,eAAe;CAE1C,MAAM,iBAAiB,OAAO,sBAAyC;AACtE,aAAW,MAAM,WAAW,kBAAkB,EAAE,kBAAkB;;;;;CAMnE,MAAM,MACE;EACN,OAAO,GAAG,SACT,QAAQ,IACP,GAAG,WAAW,GAAG,KAAK,SAAS,WAAW,MAAM,IAAI,mBAAmB,IACvE,GAAG,KACH;EACF,UAAU,GAAG,SACZ,QAAQ,IACP,GAAG,WAAW,GAAG,MAAM,SAAS,WAAW,MAAM,I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,aAAQ,IACP,uBAAuB,WAAW,GAAG,SAAS,kBAAkB,WAAW,MAAM,SAAS,iBAAiB,KAC3G;AACD,aAAQ,IACP,2BAA2B,WAAW,GAAG,SAAS,mBAAmB,QAAQ,EAAE,CAAC,IAAI,WAAW,QAC/F;AACD,aAAQ,IACP,qBAAqB,WAAW,GAAG,OAAO,cAAc,QAAQ,EAAE,CAAC,IAAI,WAAW,QAClF;AAGD,SAAI,cAAc,GAAG;AACpB,cAAQ,IACP,wBAAwB,WAAW,GAAG,OAAO,cAAc,WAAW,QACtE;AACD,cAAQ,IACP,wBAAwB,WAAW,GAAG,OAAO,iBAAiB,QAAQ,EAAE,GAAG,WAAW,QACtF;AACD,cAAQ,IACP,iCAAiC,WAAW,GAAG,OAAO,+BAA+B,WAAW,QAChG;;AAGF,aAAQ,IACP,GAAG,WAAW,GAAG,OAAO,YAAY,WAAW,MAAM,IACrD;;AAGF,UAAM,YAAY;MAChB,IAAM;AAET,QAAK,MAAM,aAAa,MACvB,OAAM,UAAU;IACf,SAAS,YAAY;AACpB,WAAM,eAAe,kBAAkB;AACvC,YAAO;;IAER;IACA;IACA,4BAA4B;IAC5B,yBAAyB,OAAO,YAAY;KAC3C,MAAM,aAAa,UAAU,kBAAkB,QAAQ;AACvD,yBAAoB,UACnB,YACA,4BAA4B,WAAW,IAAI,EAAE,CAC7C;AACD,WAAM,eAAe,kBAAkB;AACvC,YAAO;;IAER;IACA;IACA,eAAe;IACf,cAAc,OAAO,UAA0B;AAC9C,mBAAc,KAAK,MAAM;;IAE1B;IACA;IACA,CAAC;IAEF;IAEH"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@better-auth/test-utils",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.7-beta.1",
|
|
4
4
|
"description": "Testing utilities for Better Auth adapter development",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -30,15 +30,15 @@
|
|
|
30
30
|
}
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"tsdown": "0.21.
|
|
33
|
+
"tsdown": "0.21.1",
|
|
34
34
|
"vitest": "^4.0.18",
|
|
35
|
-
"@better-auth/core": "1.5.
|
|
36
|
-
"better-auth": "1.5.
|
|
35
|
+
"@better-auth/core": "1.5.7-beta.1",
|
|
36
|
+
"better-auth": "1.5.7-beta.1"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"vitest": "^4.0.18",
|
|
40
|
-
"@better-auth/core": "1.5.
|
|
41
|
-
"better-auth": "1.5.
|
|
40
|
+
"@better-auth/core": "1.5.7-beta.1",
|
|
41
|
+
"better-auth": "1.5.7-beta.1"
|
|
42
42
|
},
|
|
43
43
|
"scripts": {
|
|
44
44
|
"build": "tsdown",
|