Skip to content

Commit

Permalink
test: 뒤로가기 버튼을 클릭하는 로직에 대한 테스트코드 작성
Browse files Browse the repository at this point in the history
  • Loading branch information
jhLim97 committed Feb 5, 2022
1 parent a86f300 commit 36c0a9c
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion frontend/src/components/TransactionUpdateForm/test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { render, screen } from '../../test-utils';
import { render, screen, fireEvent } from '../../test-utils';

import TransactionUpdateForm from '.';

Expand Down Expand Up @@ -42,4 +42,20 @@ describe('TransactionUpateForm 테스트', () => {
expect(deleteButton).toBeInTheDocument();
expect(updateButton).toBeInTheDocument();
});

it('뒤로가기 버튼을 누르면 onCancle 함수가 호출된다.', () => {
const onCancle = jest.fn();
render(
<TransactionUpdateForm
transaction={TEST_DATA}
onUpdate={null}
onDelete={null}
onCancle={onCancle}
/>,
);

const backButton = screen.getByRole('button', { name: 'back' });
fireEvent.click(backButton);
expect(onCancle).toHaveBeenCalled();
});
});

0 comments on commit 36c0a9c

Please sign in to comment.