Skip to content

Semana12 aula4 week planner#30

Open
Brian-Mello wants to merge 3 commits intomasterfrom
semana12-aula4-WeekPlanner
Open

Semana12 aula4 week planner#30
Brian-Mello wants to merge 3 commits intomasterfrom
semana12-aula4-WeekPlanner

Conversation

@Brian-Mello
Copy link
Copy Markdown
Collaborator

PR - Week Planner

O que funciona

  • As funções funcionam

O que não funciona

  • Os testes ainda não foram feitos

Link:

Imagens (prints das telas)

image
image
image
image

@Brian-Mello Brian-Mello requested a review from pdarvas January 31, 2020 20:08
Copy link
Copy Markdown

@pdarvas pdarvas left a comment

Choose a reason for hiding this comment

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

Brian, muito bom seu projeto. Conseguiu uma cobertura legal, apesar de um pouco abaixo dos 70%. Deixei alguns comentários, mas são detalhes. Atente-se principalmente à repetição de código. Quando for código parecido, extraia para uma função.

Parabéns!

export const getTasks = () => async (dispatch) => {

const response = await axios.get(`${baseUrl}`)
dispatch(setTaskDayAction(response.data))
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

identação

day: 'Segunda'
}]

describe('Teste das actions', () => {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Não precisa explicitar que é um teste. E é uma boa deixar claro qual action ta sendo testada, como vc fez nos outros describes.

});

describe('teste do getTasks', () => {
it('teste para saber se o getTasks retorna um valor', async () => {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Também não precisa explicitar que é um teste. Procure colocar essa descricao do it no seguinte formato: "deve retornar um valor". E o describe seria só "getTasks". Então, o describe define o que está sendo testado, e o it define o que exatamente cada teste testa.

let orderedMonday;

if(mondayFilter) {
orderedMonday = mondayFilter.sort((a,b) => {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Todos os dias da semana têm a mesma lógica de ordenação, então você poderia ter extraído isso pra uma função:

sortDay(day) => {
  return day.sort((a,b) => {
        if(a.text > b.text) {
          return 1;
        } else if (a.text < b.text) {
          return -1;
        } else {
          return 0
        }
      })
}


const {tasks} = this.props;

const mondayFilter = tasks.filter((task) => {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Todos os dias da semana têm a mesma lógica de filtro, então você poderia ter extraído isso pra uma função:

filterTasksByDay = (tasks, day) => {
  return tasks.filter((task) => {
      return task.day === day
   })

<DaysContainer>
<TasksContainerComponent
day="Monday"
text = {orderedMonday.map((task) => <Fragment><p>{task.text}</p></Fragment>)}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Esse fragment não é necessário.

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.

2 participants