feat(profiles): add profile repository
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
34
tests/integration/profile-repository.test.ts
Normal file
34
tests/integration/profile-repository.test.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
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);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user