test: add admin routes tests
Made-with: Cursor
This commit is contained in:
@@ -58,6 +58,22 @@ export function selectChainWhere(resolveAtWhere: unknown[] = []) {
|
||||
};
|
||||
}
|
||||
|
||||
/** Build a select chain for .from().where().orderBy().limit().offset() */
|
||||
export function selectChainOrderedLimitOffset(resolveRows: unknown[] = []) {
|
||||
const offsetFn = vi.fn().mockResolvedValue(resolveRows);
|
||||
return {
|
||||
from: vi.fn().mockReturnValue({
|
||||
where: vi.fn().mockReturnValue({
|
||||
orderBy: vi.fn().mockReturnValue({
|
||||
limit: vi.fn().mockReturnValue({
|
||||
offset: offsetFn,
|
||||
}),
|
||||
}),
|
||||
}),
|
||||
}),
|
||||
};
|
||||
}
|
||||
|
||||
/** Build an insert chain that resolves at .returning() or .values() */
|
||||
export function insertChain(resolveAtReturning: unknown[] = []) {
|
||||
const returningFn = vi.fn().mockResolvedValue(resolveAtReturning);
|
||||
|
||||
Reference in New Issue
Block a user