31 lines
1.0 KiB
TypeScript
31 lines
1.0 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { ActivityLogRepository } from '../src/database/repositories.js';
|
|
import { ActivityLog } from '../src/web/activity-log.js';
|
|
import { createTestDb } from './testUtils.js';
|
|
|
|
describe('activity origin context', () => {
|
|
it('persists and hydrates the source post title, URL, and image', () => {
|
|
const db = createTestDb();
|
|
const repository = new ActivityLogRepository(db);
|
|
const activity = new ActivityLog(repository);
|
|
|
|
activity.push(
|
|
'sent',
|
|
'Sent message to u/alice (r/example)',
|
|
'alice',
|
|
'https://i.redd.it/source.jpg',
|
|
{
|
|
postTitle: 'Source title',
|
|
postUrl: 'https://www.reddit.com/r/example/comments/source/source_title/',
|
|
},
|
|
);
|
|
|
|
expect(new ActivityLog(repository).recent(1)).toEqual([expect.objectContaining({
|
|
imageUrl: 'https://i.redd.it/source.jpg',
|
|
postTitle: 'Source title',
|
|
postUrl: 'https://www.reddit.com/r/example/comments/source/source_title/',
|
|
})]);
|
|
db.close();
|
|
});
|
|
});
|