Skip to content

Instantly share code, notes, and snippets.

View martialanouman's full-sized avatar
🧘‍♂️

Martial Anouman martialanouman

🧘‍♂️
  • Arolitec
  • Abidjan
View GitHub Profile
@martialanouman
martialanouman / repository.mock.ts
Created March 14, 2022 18:55
Base TypeOrm repository mock
class MockUserRepo<T extends { id: number; [key: string]: any }> {
private db: T[] = []
async create(data: Partial<T>) {
return { ...data, id: this.db.length + 1 } as T
}
async save(entity: T) {
this.db = [...this.db, entity]
return Promise.resolve(entity)