2022-10-07 11:32:15 -05:00
|
|
|
// Copied from core
|
|
|
|
|
2022-10-21 00:14:17 -05:00
|
|
|
import type { QueryResult, QueryResultRow } from 'slonik';
|
2022-11-21 06:18:32 -05:00
|
|
|
import type { PrimitiveValueExpression } from 'slonik/dist/src/types.js';
|
2022-10-07 11:32:15 -05:00
|
|
|
|
|
|
|
export type QueryType = (
|
|
|
|
sql: string,
|
|
|
|
values: readonly PrimitiveValueExpression[]
|
|
|
|
) => Promise<QueryResult<QueryResultRow>>;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Slonik Query Mock Utils
|
|
|
|
**/
|
|
|
|
export const expectSqlAssert = (sql: string, expectSql: string) => {
|
|
|
|
expect(
|
|
|
|
sql
|
|
|
|
.split('\n')
|
|
|
|
.map((row) => row.trim())
|
|
|
|
.filter(Boolean)
|
|
|
|
).toEqual(
|
|
|
|
expectSql
|
|
|
|
.split('\n')
|
|
|
|
.map((row) => row.trim())
|
|
|
|
.filter(Boolean)
|
|
|
|
);
|
|
|
|
};
|