Enhance test coverage by adding additional mock implementations for database and schema modules
All checks were successful
farmcontrol/farmcontrol-api/pipeline/head This commit looks good
All checks were successful
farmcontrol/farmcontrol-api/pipeline/head This commit looks good
This commit expands the test setup in `stockQuantity.recalculate.test.js` and `shipments.test.js` by introducing new mock functions for various database operations, including `searchObjects`, `getPropertyValues`, and `listObjects`. These enhancements improve the isolation of tests and ensure that the tests can run independently of the actual database implementation. The updates also include mocks for sales order and marketplace schemas, further enriching the test environment and facilitating comprehensive testing of inventory-related functionalities.
This commit is contained in:
parent
5ff93be27c
commit
e0f2870af3
@ -2,10 +2,21 @@ import { beforeEach, describe, expect, it, jest } from '@jest/globals';
|
||||
import mongoose from 'mongoose';
|
||||
|
||||
jest.unstable_mockModule('../../database.js', () => ({
|
||||
searchObjects: jest.fn(),
|
||||
getPropertyValues: jest.fn(),
|
||||
listObjects: jest.fn(),
|
||||
getObject: jest.fn(),
|
||||
editObject: jest.fn(),
|
||||
editObjects: jest.fn(),
|
||||
newObject: jest.fn(),
|
||||
deleteObject: jest.fn(),
|
||||
listObjectsByProperties: jest.fn(),
|
||||
getModelStats: jest.fn(),
|
||||
getModelHistory: jest.fn(),
|
||||
aggregateRollups: jest.fn(),
|
||||
aggregateRollupsHistory: jest.fn(),
|
||||
editObject: jest.fn(),
|
||||
getObject: jest.fn(),
|
||||
checkStates: jest.fn(),
|
||||
getObjectNeighbors: jest.fn(),
|
||||
}));
|
||||
|
||||
jest.unstable_mockModule('../../utils.js', () => ({
|
||||
|
||||
@ -12,6 +12,8 @@ jest.unstable_mockModule('../../../database/database.js', () => ({
|
||||
listObjectsByProperties: jest.fn(),
|
||||
getModelStats: jest.fn(),
|
||||
getModelHistory: jest.fn(),
|
||||
aggregateRollups: jest.fn(),
|
||||
aggregateRollupsHistory: jest.fn(),
|
||||
checkStates: jest.fn(),
|
||||
getObjectNeighbors: jest.fn(),
|
||||
}));
|
||||
@ -24,6 +26,18 @@ jest.unstable_mockModule('../../../database/schemas/inventory/orderitem.schema.j
|
||||
orderItemModel: { modelName: 'OrderItem' },
|
||||
}));
|
||||
|
||||
jest.unstable_mockModule('../../../database/schemas/sales/salesorder.schema.js', () => ({
|
||||
salesOrderModel: { modelName: 'SalesOrder' },
|
||||
}));
|
||||
|
||||
jest.unstable_mockModule('../../../database/schemas/sales/marketplace.schema.js', () => ({
|
||||
marketplaceModel: { modelName: 'Marketplace', findById: jest.fn() },
|
||||
}));
|
||||
|
||||
jest.unstable_mockModule('../../../integrations/marketplaceworker.js', () => ({
|
||||
pushMarketplaceShipmentFulfillment: jest.fn(),
|
||||
}));
|
||||
|
||||
jest.unstable_mockModule('log4js', () => ({
|
||||
default: {
|
||||
getLogger: () => ({
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user