Files
TREK/server/tests/helpers/notifications-repos.ts
Maurice 724c88c201 style: format server and shared with prettier
A mechanical prettier --write over server/src, server/tests, server/scripts
and shared/src with the workspaces' .prettierrc; nothing but layout and
import order changes, and every file keeps the same set of imports. shared
is formatted throughout and its format baseline is empty. The server
baseline keeps the 35 files that Prettier would grow past their lint:size
limit (they need a split first, which is not a formatting change), and the
generated entity files stay as their generator writes them.
2026-10-10 21:23:37 +02:00

37 lines
2.0 KiB
TypeScript

import { NotificationChannelPreferences } from '../../src/db/entities/NotificationChannelPreferences.entity';
import { Notifications } from '../../src/db/entities/Notifications.entity';
import { PushSubscriptions } from '../../src/db/entities/PushSubscriptions.entity';
import type { NotificationChannelPreferencesRepository } from '../../src/db/repositories/NotificationChannelPreferences.repository';
import type { NotificationsRepository } from '../../src/db/repositories/Notifications.repository';
import type { PushSubscriptionsRepository } from '../../src/db/repositories/PushSubscriptions.repository';
import { sharedTestOrm } from './test-uow';
import type Database from 'better-sqlite3';
/**
* Plan 3f Task 3 (`NotificationsService`/`NotificationPreferencesService`)
* test-only repository factories, bound to a suite's own better-sqlite3
* handle via the SAME memoised `sharedTestOrm` `test-uow.ts` exports — the
* `todo-repos.ts`/`packing-repos.ts` precedent (a repository from a SECOND,
* independent ORM instance would resolve a different transaction fork than
* the `UnitOfWork`/`AppSettingsRepository` a hand-built service also needs).
*
* A NEW file rather than an addition to `test-uow.ts`, same reasoning those
* two files give for themselves: avoids colliding with a concurrently
* in-flight task's edits to that shared file.
*/
export function createTestNotificationsRepo(db: Database.Database): Promise<NotificationsRepository> {
return sharedTestOrm(db).then((t) => t.repo(Notifications));
}
export function createTestNotificationChannelPreferencesRepo(
db: Database.Database,
): Promise<NotificationChannelPreferencesRepository> {
return sharedTestOrm(db).then((t) => t.repo(NotificationChannelPreferences));
}
/** Web Push (#894): the `push_subscriptions` table behind `PushSubscriptionsService`. */
export function createTestPushSubscriptionsRepo(db: Database.Database): Promise<PushSubscriptionsRepository> {
return sharedTestOrm(db).then((t) => t.repo(PushSubscriptions));
}