feat(repos): tags, polymorphic entity_links, attachments
This commit is contained in:
26
tests/repos/attachments.test.js
Normal file
26
tests/repos/attachments.test.js
Normal file
@@ -0,0 +1,26 @@
|
||||
import { describe, it, expect, beforeEach } from 'vitest';
|
||||
import { resetDb } from '../helpers/db.js';
|
||||
import { migrateUp } from '../../lib/db/migrate.js';
|
||||
import * as attachments from '../../lib/db/repos/attachments.js';
|
||||
|
||||
beforeEach(async () => { await resetDb(); await migrateUp(); });
|
||||
|
||||
describe('attachments repo', () => {
|
||||
it('records an attachment', async () => {
|
||||
const a = await attachments.create({
|
||||
entity_type: 'page',
|
||||
entity_id: '11111111-1111-1111-1111-111111111111',
|
||||
filename: 'spec.pdf', mime_type: 'application/pdf',
|
||||
size_bytes: 1024, blob_path: 'aa/abc', checksum: 'abc'
|
||||
});
|
||||
expect(a.filename).toBe('spec.pdf');
|
||||
});
|
||||
|
||||
it('listForEntity returns descending by uploaded_at', async () => {
|
||||
const eid = '11111111-1111-1111-1111-111111111111';
|
||||
await attachments.create({ entity_type: 'page', entity_id: eid, filename: 'a', blob_path: 'a' });
|
||||
await attachments.create({ entity_type: 'page', entity_id: eid, filename: 'b', blob_path: 'b' });
|
||||
const list = await attachments.listForEntity('page', eid);
|
||||
expect(list).toHaveLength(2);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user