UNPKG

@adonisjs/lucid

Version:

SQL ORM built on top of Active Record pattern

42 lines (41 loc) 1.61 kB
import { type ApplicationService } from '@adonisjs/core/types'; import { type LucidRow } from '../types/model.js'; /** * Provides database assertion methods for use inside test bodies. * Exposed on Japa's TestContext as `db`. */ export declare class DatabaseTestAssertions { #private; protected app: ApplicationService; protected connectionName?: string | undefined; constructor(app: ApplicationService, connectionName?: string | undefined); /** * Returns a new instance of assertions configured for the given connection */ connection(connectionName: string): DatabaseTestAssertions; /** * Assert that the given table has rows matching the provided data. * When `count` is provided, asserts that exactly that many matching rows exist. */ assertHas(table: string, data: Record<string, any>, count?: number): Promise<void>; /** * Assert that the given table has no rows matching the provided data. */ assertMissing(table: string, data: Record<string, any>): Promise<void>; /** * Assert that the given table has exactly the expected number of rows. */ assertCount(table: string, expectedCount: number): Promise<void>; /** * Assert that the given table is empty (has no rows). */ assertEmpty(table: string): Promise<void>; /** * Assert that a model instance exists in the database. */ assertModelExists(model: LucidRow): Promise<void>; /** * Assert that a model instance does not exist in the database. */ assertModelMissing(model: LucidRow): Promise<void>; }