@better-auth/test-utils 1.7.2 → 1.7.3
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/cleanup.mjs +16 -0
- package/dist/adapter/create-test-suite.mjs +22 -23
- package/dist/adapter/suites/basic.d.mts +2 -7
- package/dist/adapter/suites/basic.mjs +0 -53
- package/dist/adapter/suites/joins.d.mts +1 -1
- package/dist/adapter/suites/number-id.d.mts +1 -1
- package/dist/adapter/suites/uuid.d.mts +1 -1
- package/package.json +7 -6
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
//#region src/adapter/cleanup.ts
|
|
2
|
+
async function cleanupRows(trackedRows, cleanupRow) {
|
|
3
|
+
const rowsToRetry = {};
|
|
4
|
+
for (const [model, rows] of Object.entries(trackedRows)) {
|
|
5
|
+
const failedRows = [];
|
|
6
|
+
for (const row of rows) try {
|
|
7
|
+
if (await cleanupRow(model, row) === "retry") failedRows.push(row);
|
|
8
|
+
} catch {
|
|
9
|
+
failedRows.push(row);
|
|
10
|
+
}
|
|
11
|
+
if (failedRows.length > 0) rowsToRetry[model] = failedRows;
|
|
12
|
+
}
|
|
13
|
+
return rowsToRetry;
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
export { cleanupRows };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { cleanupRows } from "./cleanup.mjs";
|
|
2
|
+
import { getAuthTables } from "@better-auth/core/db";
|
|
2
3
|
import { createAdapterFactory, deepmerge, initGetDefaultModelName } from "@better-auth/core/db/adapter";
|
|
3
4
|
import { TTY_COLORS } from "@better-auth/core/env";
|
|
4
5
|
import { generateId } from "@better-auth/core/utils/id";
|
|
@@ -47,7 +48,7 @@ async function tryCatch(promise) {
|
|
|
47
48
|
const createTestSuite = (suiteName, config, tests) => {
|
|
48
49
|
return (options) => {
|
|
49
50
|
return async (helpers) => {
|
|
50
|
-
|
|
51
|
+
let createdRows = {};
|
|
51
52
|
let adapter = await helpers.adapter();
|
|
52
53
|
const wrapperAdapter = (resolvedOptions) => {
|
|
53
54
|
const options = resolvedOptions ?? deepmerge(config?.defaultBetterAuthOptions || {}, helpers.getBetterAuthOptions());
|
|
@@ -113,7 +114,7 @@ const createTestSuite = (suiteName, config, tests) => {
|
|
|
113
114
|
select,
|
|
114
115
|
forceAllowId: true
|
|
115
116
|
});
|
|
116
|
-
createdRows[model]
|
|
117
|
+
(createdRows[model] ??= []).push({ id: res.id });
|
|
117
118
|
return res;
|
|
118
119
|
},
|
|
119
120
|
options: adapter.options
|
|
@@ -129,31 +130,30 @@ const createTestSuite = (suiteName, config, tests) => {
|
|
|
129
130
|
wrapperAdapter()?.adapterTestDebugLogs?.printDebugLogs();
|
|
130
131
|
};
|
|
131
132
|
const cleanupCreatedRows = async () => {
|
|
133
|
+
if (Object.keys(createdRows).length === 0) return;
|
|
132
134
|
adapter = await helpers.adapter();
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
135
|
+
const schema = getAuthTables(helpers.getBetterAuthOptions());
|
|
136
|
+
const getDefaultModelName = initGetDefaultModelName({
|
|
137
|
+
schema,
|
|
138
|
+
usePlural: adapter.options?.adapterConfig.usePlural
|
|
139
|
+
});
|
|
140
|
+
createdRows = await cleanupRows(createdRows, async (model, row) => {
|
|
139
141
|
let defaultModelName;
|
|
140
142
|
try {
|
|
141
143
|
defaultModelName = getDefaultModelName(model);
|
|
142
144
|
} catch {
|
|
143
|
-
|
|
145
|
+
return "retry";
|
|
144
146
|
}
|
|
145
|
-
if (!schema[defaultModelName])
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
if (createdRows[model].length === 1) delete createdRows[model];
|
|
156
|
-
}
|
|
147
|
+
if (!schema[defaultModelName]) return "retry";
|
|
148
|
+
await adapter.delete({
|
|
149
|
+
model,
|
|
150
|
+
where: [{
|
|
151
|
+
field: "id",
|
|
152
|
+
value: row.id
|
|
153
|
+
}]
|
|
154
|
+
});
|
|
155
|
+
return "complete";
|
|
156
|
+
});
|
|
157
157
|
};
|
|
158
158
|
let currentAppliedOptions = null;
|
|
159
159
|
const stats = {
|
|
@@ -229,7 +229,6 @@ const createTestSuite = (suiteName, config, tests) => {
|
|
|
229
229
|
id,
|
|
230
230
|
createdAt: randomDate,
|
|
231
231
|
updatedAt: /* @__PURE__ */ new Date(),
|
|
232
|
-
issuer: createLocalAccountIssuer("test"),
|
|
233
232
|
accountId: generateId(),
|
|
234
233
|
providerId: "test",
|
|
235
234
|
userId: generateId(),
|
|
@@ -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
|
|
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" | "update - should return null when where is empty" | "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" | "incrementOne - guarded set transition returns the row on a matching guard and null on a guard miss" | "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" | "update - should return null when a multi-predicate where matches no row", boolean> & {
|
|
11
11
|
ALL?: boolean;
|
|
12
12
|
}> | undefined;
|
|
13
13
|
} & {
|
|
@@ -40,11 +40,6 @@ declare const getNormalTestSuiteTests: ({
|
|
|
40
40
|
}) => {
|
|
41
41
|
"create - should create a model": () => Promise<void>;
|
|
42
42
|
"create - should always return an id": () => Promise<void>;
|
|
43
|
-
"create - should enforce the issuer-scoped account identity key": ({
|
|
44
|
-
skip
|
|
45
|
-
}: {
|
|
46
|
-
skip: (note?: string | undefined) => never;
|
|
47
|
-
}) => Promise<void>;
|
|
48
43
|
"create - should use generateId if provided": () => Promise<void>;
|
|
49
44
|
"create - should return null for nullable foreign keys": {
|
|
50
45
|
migrateBetterAuth: {
|
|
@@ -212,6 +207,6 @@ declare const getNormalTestSuiteTests: ({
|
|
|
212
207
|
"update - should return updated record when where condition uses null value": () => Promise<void>;
|
|
213
208
|
"update - should return null when a multi-predicate where matches no row": () => Promise<void>;
|
|
214
209
|
};
|
|
215
|
-
declare const enableJoinTests: Partial<Record<"create - should create a model" | "create - should always return an id" | "create - should
|
|
210
|
+
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" | "update - should return null when where is empty" | "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" | "incrementOne - guarded set transition returns the row on a matching guard and null on a guard miss" | "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" | "update - should return null when a multi-predicate where matches no row", boolean>>;
|
|
216
211
|
//#endregion
|
|
217
212
|
export { enableJoinTests, getNormalTestSuiteTests, normalTestSuite };
|
|
@@ -37,59 +37,6 @@ const getNormalTestSuiteTests = ({ adapter, generate, insertRandom, modifyBetter
|
|
|
37
37
|
expect(res).toHaveProperty("id");
|
|
38
38
|
expect(typeof res.id).toEqual("string");
|
|
39
39
|
},
|
|
40
|
-
"create - should enforce the issuer-scoped account identity key": async ({ skip }) => {
|
|
41
|
-
if (adapter.options?.adapterConfig.adapterId === "memory") {
|
|
42
|
-
skip("The memory adapter does not implement database indexes");
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
const firstUser = await adapter.create({
|
|
46
|
-
model: "user",
|
|
47
|
-
data: await generate("user"),
|
|
48
|
-
forceAllowId: true
|
|
49
|
-
});
|
|
50
|
-
const secondUser = await adapter.create({
|
|
51
|
-
model: "user",
|
|
52
|
-
data: await generate("user"),
|
|
53
|
-
forceAllowId: true
|
|
54
|
-
});
|
|
55
|
-
const firstAccount = {
|
|
56
|
-
...await generate("account"),
|
|
57
|
-
userId: firstUser.id,
|
|
58
|
-
providerId: "issuer-key-first-alias",
|
|
59
|
-
issuer: "https://issuer-key.example.com",
|
|
60
|
-
accountId: "shared-subject"
|
|
61
|
-
};
|
|
62
|
-
await adapter.create({
|
|
63
|
-
model: "account",
|
|
64
|
-
data: firstAccount,
|
|
65
|
-
forceAllowId: true
|
|
66
|
-
});
|
|
67
|
-
await expect(adapter.create({
|
|
68
|
-
model: "account",
|
|
69
|
-
data: {
|
|
70
|
-
...await generate("account"),
|
|
71
|
-
userId: secondUser.id,
|
|
72
|
-
providerId: "issuer-key-second-alias",
|
|
73
|
-
issuer: firstAccount.issuer,
|
|
74
|
-
accountId: firstAccount.accountId
|
|
75
|
-
},
|
|
76
|
-
forceAllowId: true
|
|
77
|
-
})).rejects.toThrow();
|
|
78
|
-
await expect(adapter.create({
|
|
79
|
-
model: "account",
|
|
80
|
-
data: {
|
|
81
|
-
...await generate("account"),
|
|
82
|
-
userId: secondUser.id,
|
|
83
|
-
providerId: "issuer-key-other-issuer",
|
|
84
|
-
issuer: "https://other-issuer-key.example.com",
|
|
85
|
-
accountId: firstAccount.accountId
|
|
86
|
-
},
|
|
87
|
-
forceAllowId: true
|
|
88
|
-
})).resolves.toMatchObject({
|
|
89
|
-
issuer: "https://other-issuer-key.example.com",
|
|
90
|
-
accountId: "shared-subject"
|
|
91
|
-
});
|
|
92
|
-
},
|
|
93
40
|
"create - should use generateId if provided": async () => {
|
|
94
41
|
const ID = await customIdGenerator?.() || "MOCK-ID";
|
|
95
42
|
await modifyBetterAuthOptions({ advanced: { database: { generateId: () => ID } } }, false);
|
|
@@ -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
|
|
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" | "update - should return null when where is empty" | "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" | "incrementOne - guarded set transition returns the row on a matching guard and null on a guard miss" | "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" | "update - should return null when a multi-predicate where matches no row", boolean> & {
|
|
8
8
|
ALL?: boolean;
|
|
9
9
|
}> | undefined;
|
|
10
10
|
} | undefined) => (helpers: {
|
|
@@ -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
|
|
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" | "update - should return null when where is empty" | "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" | "incrementOne - guarded set transition returns the row on a matching guard and null on a guard miss" | "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" | "update - should return null when a multi-predicate where matches no row" | "create - should return a number id", boolean> & {
|
|
8
8
|
ALL?: boolean;
|
|
9
9
|
}> | undefined;
|
|
10
10
|
} | undefined) => (helpers: {
|
|
@@ -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
|
|
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" | "update - should return null when where is empty" | "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" | "incrementOne - guarded set transition returns the row on a matching guard and null on a guard miss" | "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" | "update - should return null when a multi-predicate where matches no row" | "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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@better-auth/test-utils",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.3",
|
|
4
4
|
"description": "Testing utilities for Better Auth adapter development",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -38,16 +38,17 @@
|
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"tsdown": "0.21.10",
|
|
40
40
|
"vitest": "^4.1.10",
|
|
41
|
-
"@better-auth/core": "1.7.
|
|
42
|
-
"better-auth": "1.7.
|
|
41
|
+
"@better-auth/core": "1.7.3",
|
|
42
|
+
"better-auth": "1.7.3"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"vitest": "^4.1.10",
|
|
46
|
-
"@better-auth/core": "^1.7.
|
|
47
|
-
"better-auth": "^1.7.
|
|
46
|
+
"@better-auth/core": "^1.7.3",
|
|
47
|
+
"better-auth": "^1.7.3"
|
|
48
48
|
},
|
|
49
49
|
"scripts": {
|
|
50
50
|
"build": "tsdown",
|
|
51
|
-
"dev": "tsdown --watch"
|
|
51
|
+
"dev": "tsdown --watch",
|
|
52
|
+
"test": "vitest"
|
|
52
53
|
}
|
|
53
54
|
}
|