Enhance stock quantity recalculation tests with updated mock implementations
All checks were successful
farmcontrol/farmcontrol-ws/pipeline/head This commit looks good

- Added a mock for `updateDraftStockAuditCurrents` in the stock quantity recalculation test suite to ensure proper integration with stock audit processes.
- Reset the mock state for `updateDraftStockAuditCurrents` in the `beforeEach` hook to maintain test isolation and reliability.
- Updated the test setup to resolve the mock function, improving the accuracy of test outcomes related to stock quantity recalculations.
This commit is contained in:
Tom Butcher 2026-09-01 16:07:49 +01:00
parent 6bf0568f23
commit 5f84c7077d

View File

@ -23,7 +23,12 @@ jest.unstable_mockModule('../../utils.js', () => ({
generateId: jest.fn(() => () => 'test-id'),
}));
jest.unstable_mockModule('../inventory/stockaudit.schema.js', () => ({
updateDraftStockAuditCurrents: jest.fn(),
}));
const { aggregateRollups, editObject, newObject, deleteObject } = await import('../../database.js');
const { updateDraftStockAuditCurrents } = await import('../inventory/stockaudit.schema.js');
const { listingModel } = await import('../sales/listing.schema.js');
const { listingVarientModel } = await import('../sales/listingvarient.schema.js');
const { productSkuModel } = await import('../management/productsku.schema.js');
@ -365,7 +370,9 @@ describe('productStock.recalculate', () => {
beforeEach(() => {
aggregateRollups.mockReset();
editObject.mockReset();
updateDraftStockAuditCurrents.mockReset();
jest.restoreAllMocks();
updateDraftStockAuditCurrents.mockResolvedValue(undefined);
});
it('writes the sku/location total onto matching listing varients', async () => {