From 5f84c7077dbc1fbd44292b924c7c17d9b87fa663 Mon Sep 17 00:00:00 2001 From: Tom Butcher Date: Tue, 1 Sep 2026 16:07:49 +0100 Subject: [PATCH] Enhance stock quantity recalculation tests with updated mock implementations - 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. --- .../schemas/__tests__/stockQuantity.recalculate.test.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/database/schemas/__tests__/stockQuantity.recalculate.test.js b/src/database/schemas/__tests__/stockQuantity.recalculate.test.js index 20b3be3..94bad77 100644 --- a/src/database/schemas/__tests__/stockQuantity.recalculate.test.js +++ b/src/database/schemas/__tests__/stockQuantity.recalculate.test.js @@ -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 () => {