Advertisement
Guest User

Untitled

a guest
May 25th, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. it("should submit the rejection request and close", async (done) => {
  2. const onClose = jest.fn();
  3. const rejectPO= jest.fn(
  4. (purchaseOrderId: string, reason: string, rejectedBy: string) =>
  5. new Promise<IApiResponse<object>>((resolve) => resolve({ response: { } })),
  6. );
  7. const randomPoId = `${faker.random.number()}`;
  8. const {getByText, debug, container} = render(
  9. <PurchaseOrderRejectModalContainer
  10. open={true}
  11. purchaseOrderId={randomPoId}
  12. onClose={onClose}
  13. needPrint={true}
  14. rejectPO={rejectPO}
  15. userInfo={null}
  16. />
  17. );
  18. const rejectReason = getByText('reason').parentElement.children[1];
  19. const rejectButton = getByText('reject');
  20. const rejectReasonValue = faker.lorem.sentence(7);
  21.  
  22. fireEvent.change(rejectReason, {target: {value: rejectReasonValue}});
  23. fireEvent.click(rejectButton);
  24.  
  25. await wait(() => {
  26. expect(rejectPO).toHaveBeenCalledTimes(1);
  27. expect(onClose).toHaveBeenCalledTimes(1);
  28. expect(rejectPO).toBeCalledWith(randomPoId, rejectReasonValue, null);
  29. done();
  30. });
  31. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement