1 import { render } from '@testing-library/react';
3 import type { Condition } from '../filters/interfaces';
4 import { ConditionComparator } from '../filters/interfaces';
5 import AttachmentsCondition from './AttachmentsCondition';
7 describe('AttachmentsCondition', () => {
8 const condition1 = { comparator: ConditionComparator.DOES_NOT_CONTAIN } as Condition;
9 const condition2 = { comparator: ConditionComparator.CONTAINS } as Condition;
10 const onUpdate = jest.fn();
12 describe('when we click on the "With attachment" radio', () => {
13 it('should call the onUpdate function with the right condition', () => {
14 const { getByText } = render(<AttachmentsCondition index={0} condition={condition1} onUpdate={onUpdate} />);
15 getByText('With attachment').click();
16 expect(onUpdate).toHaveBeenCalledWith({ comparator: ConditionComparator.CONTAINS });
20 describe('when we click on the "Without attachment" radio', () => {
21 it('should call the onUpdate function with the right condition', () => {
22 const { getByText } = render(<AttachmentsCondition index={0} condition={condition2} onUpdate={onUpdate} />);
23 getByText('Without attachment').click();
24 expect(onUpdate).toHaveBeenCalledWith({ comparator: ConditionComparator.DOES_NOT_CONTAIN });