Phase 5 cleanup
This commit is contained in:
parent
5536acd67d
commit
76a516a417
136 changed files with 6322 additions and 1985 deletions
|
|
@ -21,9 +21,13 @@ vi.mock('../../schemas/purchase.schema.js', () => {
|
|||
|
||||
class FakeModel {
|
||||
data: unknown;
|
||||
constructor(data: unknown) { this.data = data; }
|
||||
constructor(data: unknown) {
|
||||
this.data = data;
|
||||
}
|
||||
save = mockSave;
|
||||
toObject() { return this.data; }
|
||||
toObject() {
|
||||
return this.data;
|
||||
}
|
||||
static find = vi.fn(() => findChain());
|
||||
static findOne = vi.fn(() => findOneChain());
|
||||
static findOneAndUpdate = vi.fn(() => updateChain());
|
||||
|
|
@ -54,7 +58,15 @@ describe(PurchasesRepository.name, () => {
|
|||
|
||||
describe('create', () => {
|
||||
it('saves and returns plain object', async () => {
|
||||
const data = { householdId: 'hh1', storeId: 'st-1', storeName: 'CVS', status: 'in_cabinet', items: [makeItem()], purchasedAt: new Date(), createdBy: 'u-1' };
|
||||
const data = {
|
||||
householdId: 'hh1',
|
||||
storeId: 'st-1',
|
||||
storeName: 'CVS',
|
||||
status: 'in_cabinet',
|
||||
items: [makeItem()],
|
||||
purchasedAt: new Date(),
|
||||
createdBy: 'u-1',
|
||||
};
|
||||
mockSave.mockResolvedValue({ toObject: () => data });
|
||||
|
||||
const result = await repo.create(data);
|
||||
|
|
@ -104,9 +116,7 @@ describe(PurchasesRepository.name, () => {
|
|||
|
||||
await repo.findByHousehold('hh1', { limit: 20, storeId: 'st-1' });
|
||||
|
||||
expect(PurchaseModel.find).toHaveBeenCalledWith(
|
||||
expect.objectContaining({ storeId: 'st-1' }),
|
||||
);
|
||||
expect(PurchaseModel.find).toHaveBeenCalledWith(expect.objectContaining({ storeId: 'st-1' }));
|
||||
});
|
||||
|
||||
it('applies cursor filter when provided', async () => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue