test(db): add InitiativeRepository findByStatus tests
- Test empty array for no matches - Test filtering by active/completed/archived status
This commit is contained in:
@@ -121,4 +121,32 @@ describe('DrizzleInitiativeRepository', () => {
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('findByStatus', () => {
|
||||
it('should return empty array for no matches', async () => {
|
||||
await repo.create({ name: 'Active 1', status: 'active' });
|
||||
|
||||
const completed = await repo.findByStatus('completed');
|
||||
expect(completed).toEqual([]);
|
||||
});
|
||||
|
||||
it('should filter by status', async () => {
|
||||
await repo.create({ name: 'Active 1', status: 'active' });
|
||||
await repo.create({ name: 'Active 2', status: 'active' });
|
||||
await repo.create({ name: 'Completed', status: 'completed' });
|
||||
await repo.create({ name: 'Archived', status: 'archived' });
|
||||
|
||||
const active = await repo.findByStatus('active');
|
||||
expect(active).toHaveLength(2);
|
||||
expect(active.every((i) => i.status === 'active')).toBe(true);
|
||||
|
||||
const completed = await repo.findByStatus('completed');
|
||||
expect(completed).toHaveLength(1);
|
||||
expect(completed[0].name).toBe('Completed');
|
||||
|
||||
const archived = await repo.findByStatus('archived');
|
||||
expect(archived).toHaveLength(1);
|
||||
expect(archived[0].name).toBe('Archived');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user