Files
kochwas/tests/integration/profile-repository.test.ts
Hendrik 5693371673 feat(profiles): add profile repository
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-17 15:11:23 +02:00

35 lines
1009 B
TypeScript

import { describe, it, expect } from 'vitest';
import { openInMemoryForTest } from '../../src/lib/server/db';
import {
createProfile,
listProfiles,
renameProfile,
deleteProfile
} from '../../src/lib/server/profiles/repository';
describe('profile repository', () => {
it('creates, lists, renames, deletes', () => {
const db = openInMemoryForTest();
const p = createProfile(db, 'Hendrik', '👨‍🍳');
expect(p.id).toBeGreaterThan(0);
expect(listProfiles(db).length).toBe(1);
renameProfile(db, p.id, 'Hendrik S.');
expect(listProfiles(db)[0].name).toBe('Hendrik S.');
deleteProfile(db, p.id);
expect(listProfiles(db).length).toBe(0);
});
it('rejects duplicate names', () => {
const db = openInMemoryForTest();
createProfile(db, 'Hendrik');
expect(() => createProfile(db, 'Hendrik')).toThrow();
});
it('rejects empty name', () => {
const db = openInMemoryForTest();
expect(() => createProfile(db, ' ')).toThrow(/empty/i);
});
});