Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

converts NONE to empty string when "No project" is selected

Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,9 @@ export const AddTaskdialog = ({
if (value === '__CREATE_NEW__') {
setIsCreatingNewProject(true);
setNewTask({ ...newTask, project: '' });
} else if (value === '__NONE__') {
setIsCreatingNewProject(false);
setNewTask({ ...newTask, project: '' });
} else {
setIsCreatingNewProject(false);
setNewTask({ ...newTask, project: value });
Expand Down
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added unit test

Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,21 @@ describe('AddTaskDialog Component', () => {
});

describe('Project Field', () => {
test('sets project to empty string when "No project" is selected', () => {
mockProps.isOpen = true;
mockProps.uniqueProjects = ['Work', 'Personal'];
render(<AddTaskdialog {...mockProps} />);

const projectSelect = screen.getByTestId('project-select');
fireEvent.change(projectSelect, { target: { value: '__NONE__' } });

expect(mockProps.setIsCreatingNewProject).toHaveBeenCalledWith(false);
expect(mockProps.setNewTask).toHaveBeenCalledWith({
...mockProps.newTask,
project: '',
});
});

test('updates project when user types in project field', async () => {
mockProps.isOpen = true;
mockProps.isCreatingNewProject = true;
Expand Down
Loading