Skip to content

Commit

Permalink
Merge pull request #1247 from Real-Dev-Squad/develop
Browse files Browse the repository at this point in the history
Dev to Main Sync
  • Loading branch information
iamitprakash authored Sep 7, 2024
2 parents 363fff2 + a110b65 commit 804c455
Show file tree
Hide file tree
Showing 33 changed files with 991 additions and 1,552 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import React from 'react';
import { fireEvent, render, screen } from '@testing-library/react';
import { Tab } from '@/interfaces/task.type';
import FilterModal from '@/components/tasks/TaskSearch/FilterModal';
import FilterDropdown from '@/components/tasks/TaskSearch/FilterDropdown';

const mockOnSelect = jest.fn();
const mockOnClose = jest.fn();

describe('FilterModal', () => {
describe('FilterDropdown', () => {
test('renders the modal with correct title and buttons', () => {
render(
<FilterModal
<FilterDropdown
tabs={[Tab.ASSIGNED, Tab.IN_PROGRESS]}
onSelect={mockOnSelect}
activeTab={Tab.ASSIGNED}
Expand All @@ -32,7 +32,7 @@ describe('FilterModal', () => {

test('renders the modal having overdue tab with correct title and buttons', () => {
render(
<FilterModal
<FilterDropdown
tabs={[Tab.ASSIGNED, Tab.IN_PROGRESS, Tab.OVERDUE]}
onSelect={mockOnSelect}
activeTab={Tab.OVERDUE}
Expand All @@ -56,10 +56,9 @@ describe('FilterModal', () => {
expect(overdueButton).toBeInTheDocument();
});

test('renders the modal with correct title and buttons when dev is true', () => {
test('renders the modal with correct title and buttons', () => {
render(
<FilterModal
dev={true}
<FilterDropdown
tabs={[Tab.UNASSIGNED, Tab.DONE]}
onSelect={mockOnSelect}
activeTab={Tab.UNASSIGNED}
Expand All @@ -82,7 +81,7 @@ describe('FilterModal', () => {

test('calls onSelect and onClose when a status button is clicked', () => {
render(
<FilterModal
<FilterDropdown
tabs={[Tab.ASSIGNED, Tab.IN_PROGRESS]}
onSelect={mockOnSelect}
activeTab={Tab.ASSIGNED}
Expand All @@ -98,7 +97,7 @@ describe('FilterModal', () => {

test('calls onClose when the close button is clicked', () => {
render(
<FilterModal
<FilterDropdown
tabs={[Tab.ASSIGNED, Tab.IN_PROGRESS]}
onSelect={mockOnSelect}
activeTab={Tab.ASSIGNED}
Expand All @@ -113,12 +112,11 @@ describe('FilterModal', () => {
});
test('calls onClose when clicked on outside', () => {
render(
<FilterModal
<FilterDropdown
tabs={[Tab.ASSIGNED, Tab.IN_PROGRESS]}
onSelect={mockOnSelect}
activeTab={Tab.ASSIGNED}
onClose={mockOnClose}
dev={true}
/>
);

Expand All @@ -138,12 +136,11 @@ describe('FilterModal', () => {
});
test('calls onClose when escape button is clicked', () => {
render(
<FilterModal
<FilterDropdown
tabs={[Tab.ASSIGNED, Tab.IN_PROGRESS]}
onSelect={mockOnSelect}
activeTab={Tab.ASSIGNED}
onClose={mockOnClose}
dev={true}
/>
);

Expand All @@ -154,7 +151,7 @@ describe('FilterModal', () => {

test('renders the modal with correct active tab', () => {
render(
<FilterModal
<FilterDropdown
tabs={[Tab.ASSIGNED, Tab.IN_PROGRESS]}
onSelect={mockOnSelect}
activeTab={Tab.ASSIGNED}
Expand All @@ -169,10 +166,9 @@ describe('FilterModal', () => {
expect(inProgressButton).not.toHaveClass('status-button-active');
});

test('renders the modal with correct active tab when dev is true', () => {
test('renders the modal with correct active tab', () => {
render(
<FilterModal
dev={true}
<FilterDropdown
tabs={[Tab.UNASSIGNED, Tab.DONE]}
onSelect={mockOnSelect}
activeTab={Tab.DONE}
Expand All @@ -187,10 +183,9 @@ describe('FilterModal', () => {
expect(unassignedButton).not.toHaveClass('status-button-active');
});

test('render the filter model having BACKLOG tab with correct title and buttons when dev is true', () => {
test('render the filter model having BACKLOG tab with correct title and buttons', () => {
render(
<FilterModal
dev={true}
<FilterDropdown
tabs={[Tab.UNASSIGNED, Tab.BACKLOG]}
onSelect={mockOnSelect}
activeTab={Tab.BACKLOG}
Expand All @@ -202,10 +197,9 @@ describe('FilterModal', () => {
expect(backlogButton).toBeInTheDocument();
});

test('onSelect Function Gets Called When the Backlog Status button is Clicked when dev is true', () => {
test('onSelect Function Gets Called When the Backlog Status button is Clicked', () => {
render(
<FilterModal
dev={true}
<FilterDropdown
tabs={[Tab.BACKLOG, Tab.IN_PROGRESS]}
onSelect={mockOnSelect}
activeTab={Tab.BACKLOG}
Expand All @@ -219,10 +213,9 @@ describe('FilterModal', () => {
expect(mockOnSelect).toHaveBeenCalledWith(Tab.BACKLOG);
});

test('Selection of the Backlog Button when dev is true', () => {
test('Selection of the Backlog Button', () => {
render(
<FilterModal
dev={true}
<FilterDropdown
tabs={[Tab.BACKLOG, Tab.DONE]}
onSelect={mockOnSelect}
activeTab={Tab.BACKLOG}
Expand Down
2 changes: 1 addition & 1 deletion __tests__/Unit/Components/Tasks/Option.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { render, fireEvent } from '@testing-library/react';
import Option from '@/components/tasks/TaskSearchDev/Suggestion/Option';
import Option from '@/components/tasks/TaskSearch/Suggestion/Option';

describe('Option component', () => {
const mockOnClickHandler = jest.fn();
Expand Down
2 changes: 1 addition & 1 deletion __tests__/Unit/Components/Tasks/Options.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { render, fireEvent } from '@testing-library/react';
import Options from '@/components/tasks/TaskSearchDev/Suggestion/Options';
import Options from '@/components/tasks/TaskSearch/Suggestion/Options';
import { TaskSearchOption } from '@/interfaces/searchOptions.type';

describe('Option component', () => {
Expand Down
2 changes: 1 addition & 1 deletion __tests__/Unit/Components/Tasks/Pill.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import { fireEvent, render, screen } from '@testing-library/react';
import RenderPills, {
PillProps,
} from '@/components/tasks/TaskSearchDev/Suggestion/Pill';
} from '@/components/tasks/TaskSearch/Suggestion/Pill';

describe('RenderPills', () => {
const setNewPillValue = jest.fn();
Expand Down
28 changes: 28 additions & 0 deletions __tests__/Unit/Components/Tasks/TaskDates.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { render, screen, fireEvent } from '@testing-library/react';
import { TaskDates } from '@/components/taskDetails/TaskDates';

const mockSetNewEndOnDate = jest.fn();
const mockHandleBlurOfEndsOn = jest.fn();

describe('TaskDates Component', () => {
it('should render input field for End On date when in editing mode', () => {
render(
<TaskDates
isEditing={true}
isUserAuthorized={true}
startedOn="2024-03-30T11:20:00Z"
endsOn={1700000000}
newEndOnDate="2024-03-30"
setNewEndOnDate={mockSetNewEndOnDate}
handleBlurOfEndsOn={mockHandleBlurOfEndsOn}
isExtensionRequestPending={false}
taskId="1"
/>
);

const input = screen.getByTestId('endsOnTaskDetails');
expect(input).toBeInTheDocument();
fireEvent.blur(input);
expect(mockHandleBlurOfEndsOn).toHaveBeenCalled();
});
});
96 changes: 0 additions & 96 deletions __tests__/Unit/Components/Tasks/TaskDependency.test.tsx

This file was deleted.

55 changes: 55 additions & 0 deletions __tests__/Unit/Components/Tasks/TaskDescription.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { render, screen, fireEvent } from '@testing-library/react';
import { TaskDescription } from '@/components/taskDetails/TaskDescription';

const mockHandleChange = jest.fn();

describe('TaskDescription Component', () => {
it('should renders the task description when not editing', () => {
render(
<TaskDescription
isEditing={false}
purpose="Test Purpose"
handleChange={mockHandleChange}
/>
);
expect(screen.getByText('Test Purpose')).toBeInTheDocument();
});

it('should renders "No description available" when purpose is empty', () => {
render(
<TaskDescription
isEditing={false}
purpose=""
handleChange={mockHandleChange}
/>
);
expect(
screen.getByText('No description available')
).toBeInTheDocument();
});

it('should renders textarea when in editing mode', () => {
render(
<TaskDescription
isEditing={true}
purpose="Test Purpose"
handleChange={mockHandleChange}
/>
);
expect(screen.getByTestId('purpose-textarea')).toBeInTheDocument();
});

it('should calls handleChange when textarea value changes', () => {
render(
<TaskDescription
isEditing={true}
purpose="Test Purpose"
handleChange={mockHandleChange}
/>
);
fireEvent.change(screen.getByTestId('purpose-textarea'), {
target: { value: 'New Purpose' },
});
expect(mockHandleChange).toHaveBeenCalled();
});
});
Loading

0 comments on commit 804c455

Please sign in to comment.