Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

didnt know tests failed #2565

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

vanvalera
Copy link

DEMO LINK
Everything is works...but i cant pass the tests

Copy link

@volodymyr-soltys97 volodymyr-soltys97 left a comment

Choose a reason for hiding this comment

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

Good job 👍
Let's make your code better

Comment on lines 32 to 60
<tr data-cy="todo" className="" key={todo.id}>
<td className="is-vcentered">{todo.id}</td>
{todo.completed ? (
<td className="is-vcentered">
<span className="icon" data-cy="iconCompleted">
<i className="fas fa-check" />
</span>
</td>
) : (
<td className="is-vcentered" />
)}
<td className="is-vcentered is-expanded">
<p
className={
todo.completed ? 'has-text-success' : 'has-text-danger'
}
>
{todo.title}
</p>
</td>
<td className="has-text-right is-vcentered">
<button
data-cy="selectButton"
className="button"
type="button"
onClick={() => openModal(todo)}
>
<span className="icon">
<i

Choose a reason for hiding this comment

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

Move this logic to the TodoItem component

Copy link
Author

Choose a reason for hiding this comment

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

why? there are no tests for this component. As i understand i must using this "You are given the markup for the App, TodosList, TodoFilter, TodoModal and Loader components. Load data from the API and show it using the given components."

Choose a reason for hiding this comment

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

After this fix, this component will be more readable, it will be a good practice

<td className="is-vcentered is-expanded">
<p
className={
todo.completed ? 'has-text-success' : 'has-text-danger'

Choose a reason for hiding this comment

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

Use the classnames library for add classes with condition, fix it everywhere

todo.completed ? 'has-text-success' : 'has-text-danger'
}
>
{todo.title}

Choose a reason for hiding this comment

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

Use destructuring for todo


export const App: React.FC = () => {
const [todos, setTodos] = useState<Todo[]>([]);
const [filteredTodos, setFilteredTodos] = useState<Todo[]>([]);

Choose a reason for hiding this comment

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

Redundant state

Suggested change
const [filteredTodos, setFilteredTodos] = useState<Todo[]>([]);

Choose a reason for hiding this comment

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

Not fixed
image

src/App.tsx Outdated
Comment on lines 20 to 24
getTodos().then(todos1 => {
setTodos(todos1);
setFilteredTodos(todos1);
setLoading(false);
});

Choose a reason for hiding this comment

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

Suggested change
getTodos().then(todos1 => {
setTodos(todos1);
setFilteredTodos(todos1);
setLoading(false);
});
getTodos()
.then(setTodos)
.finally(() => setLoading(false));

src/App.tsx Outdated

export const App: React.FC = () => {
const [todos, setTodos] = useState<Todo[]>([]);
const [filteredTodos, setFilteredTodos] = useState<Todo[]>([]);
const [loading, setLoading] = useState<boolean>(true);

Choose a reason for hiding this comment

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

Suggested change
const [loading, setLoading] = useState<boolean>(true);
const [isLoading, setIsLoading] = useState<boolean>(true);

Copy link

@volodymyr-soltys97 volodymyr-soltys97 left a comment

Choose a reason for hiding this comment

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

Almost done!
You need to fix all comment for failed tests


export const App: React.FC = () => {
const [todos, setTodos] = useState<Todo[]>([]);
const [filteredTodos, setFilteredTodos] = useState<Todo[]>([]);

Choose a reason for hiding this comment

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

Not fixed
image

src/App.tsx Outdated
Comment on lines 18 to 25
const fetchTodos = async () => {
const todosData = await getTodos();

setTodos(todosData);
setFilteredTodos(todosData);
};

fetchTodos();

Choose a reason for hiding this comment

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

Suggested change
const fetchTodos = async () => {
const todosData = await getTodos();
setTodos(todosData);
setFilteredTodos(todosData);
};
fetchTodos();
setIsLoading(true)
getTodos()
.then(setTodos)
.finally(() => setIsLoading(false))

src/App.tsx Outdated
Comment on lines 15 to 16
const [selectedTodo, setSelectedTodo] = useState<Todo | null>(null);

Choose a reason for hiding this comment

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

Create a state for isLoading

Comment on lines 32 to 60
<tr data-cy="todo" className="" key={todo.id}>
<td className="is-vcentered">{todo.id}</td>
{todo.completed ? (
<td className="is-vcentered">
<span className="icon" data-cy="iconCompleted">
<i className="fas fa-check" />
</span>
</td>
) : (
<td className="is-vcentered" />
)}
<td className="is-vcentered is-expanded">
<p
className={
todo.completed ? 'has-text-success' : 'has-text-danger'
}
>
{todo.title}
</p>
</td>
<td className="has-text-right is-vcentered">
<button
data-cy="selectButton"
className="button"
type="button"
onClick={() => openModal(todo)}
>
<span className="icon">
<i

Choose a reason for hiding this comment

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

After this fix, this component will be more readable, it will be a good practice

Copy link

@anastasiiavorobiova anastasiiavorobiova left a comment

Choose a reason for hiding this comment

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

Great work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants