test('주문 상세 조회 테스트(getOrderById)', async () => {
mockRequest.params = { orderId: 1 };
mockRequest.headers = { cookie: "test" };
const orderById = 1;
mockOrderService.findOrderById = jest.fn(() => {
return orderById;
});
const cookie = 'test';
mockOrderService.findOrderById = jest.fn(() => {
return cookie;
});
await orderController.getOrderById(mockRequest, mockResponse);
expect(mockOrderService.findOrderById).toHaveBeenCalledTimes(1);
expect(mockResponse.status).toHaveBeenCalledTimes(1);
expect(mockResponse.status).toHaveBeenCalledWith(200);
});
fn 함수를 활용하는법은 재밌당