import type { CRUDEngine } from '../engine' ; import { RecordNotFoundError } from '../engine/error/RecordNotFoundError' ; const TABLE_NAME = 'the-simpsons' ; interface DomainEntity { some : string ; } export const readSpec = { 'returns a database record.' : async ( engine ) => { const PRIMARY_KEY = 'primary-key' ; const entity = { some : 'value' , } ; const primaryKey = await engine . create ( TABLE_NAME , PRIMARY_KEY , entity ) ; const record = await engine . read < DomainEntity > ( TABLE_NAME , primaryKey ) ; expect ( record . some ) . toBe ( entity . some ) ; } , 'throws an error if a record cannot be found.' : async ( engine ) => { const PRIMARY_KEY = 'primary-key' ; try { await engine . read ( TABLE_NAME , PRIMARY_KEY ) ; fail ( new Error ( 'Method is supposed to throw an error.' ) ) ; } catch ( error ) { expect ( error ) . toEqual ( jasmine . any ( RecordNotFoundError ) ) ; } } , } ;