Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- it("should submit the rejection request and close", async (done) => {
- const onClose = jest.fn();
- const rejectPO= jest.fn(
- (purchaseOrderId: string, reason: string, rejectedBy: string) =>
- new Promise<IApiResponse<object>>((resolve) => resolve({ response: { } })),
- );
- const randomPoId = `${faker.random.number()}`;
- const {getByText, debug, container} = render(
- <PurchaseOrderRejectModalContainer
- open={true}
- purchaseOrderId={randomPoId}
- onClose={onClose}
- needPrint={true}
- rejectPO={rejectPO}
- userInfo={null}
- />
- );
- const rejectReason = getByText('reason').parentElement.children[1];
- const rejectButton = getByText('reject');
- const rejectReasonValue = faker.lorem.sentence(7);
- fireEvent.change(rejectReason, {target: {value: rejectReasonValue}});
- fireEvent.click(rejectButton);
- await wait(() => {
- expect(rejectPO).toHaveBeenCalledTimes(1);
- expect(onClose).toHaveBeenCalledTimes(1);
- expect(rejectPO).toBeCalledWith(randomPoId, rejectReasonValue, null);
- done();
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement