Refactored newFilamentStockRouteHandler test to accommodate updated filament stock structure, including net and gross weight properties. Adjusted mock implementations to ensure accurate testing of stock creation and event handling.
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 is contained in:
parent
5ee8f332e2
commit
6f59f75b41
@ -74,13 +74,18 @@ describe('Filament Stock Service Route Handlers', () => {
|
|||||||
|
|
||||||
describe('newFilamentStockRouteHandler', () => {
|
describe('newFilamentStockRouteHandler', () => {
|
||||||
it('should create a new filament stock', async () => {
|
it('should create a new filament stock', async () => {
|
||||||
req.body = { filament: 'filament123', currentWeight: 1000 };
|
req.body = {
|
||||||
|
filament: 'filament123',
|
||||||
|
startingWeight: { net: 1000, gross: 1100 },
|
||||||
|
currentWeight: { net: 1000, gross: 1100 },
|
||||||
|
};
|
||||||
const mockStock = { _id: '456', ...req.body };
|
const mockStock = { _id: '456', ...req.body };
|
||||||
newObject.mockResolvedValue(mockStock);
|
const mockStockEvent = { _id: '789' };
|
||||||
|
newObject.mockResolvedValueOnce(mockStock).mockResolvedValueOnce(mockStockEvent);
|
||||||
|
|
||||||
await newFilamentStockRouteHandler(req, res);
|
await newFilamentStockRouteHandler(req, res);
|
||||||
|
|
||||||
expect(newObject).toHaveBeenCalled();
|
expect(newObject).toHaveBeenCalledTimes(2);
|
||||||
expect(res.send).toHaveBeenCalledWith(mockStock);
|
expect(res.send).toHaveBeenCalledWith(mockStock);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user