Skip to content

TDD - Roberta Amaro#23

Open
robs-am wants to merge 9 commits into
reprograma:mainfrom
robs-am:main
Open

TDD - Roberta Amaro#23
robs-am wants to merge 9 commits into
reprograma:mainfrom
robs-am:main

Conversation

@robs-am

@robs-am robs-am commented Jun 29, 2023

Copy link
Copy Markdown

Resolução de testes unitários para verificação de uma conta bancária

Como?

  • Adicionei um arquivo para resolver a atividade 1 utilizando funções para requisição do enunciado: consulta de saldo, depósito, saque quando existe limite disponível, saque quando não há saldo disponível e limite disponível e por último, desativação do limite.
  • Para a desativação do limite importei o objeto dentro do teste e utilizei o método .toBeNull()

Comment on lines +20 to +33
function withdraw(withdraw) {
if (withdraw <= balance) {
balance = balance - withdraw;
return "Saque efetuado";
} else {
if (withdraw <= limit) {
balance = balance - limit;
//return balance;
return "Saldo negativo e limite disponível";
} else {
return "Operação Negada";
}
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Você poderia incluir nas mensagens de retorno o valor do novo saldo após o saque realizado.

Comment on lines +17 to +24
it("should enable withdraw when sufficient balance", () => {
const output = "Saque efetuado";
expect(withdraw(100)).toEqual(output);
});
it("should enable withdraw when insufficient balance and the limit is sufficient", () => {
const output = "Saldo negativo e limite disponível";
expect(withdraw(1005)).toEqual(output);
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Você poderia fazer outro teste referente à função withdraw para verificar quando o cliente não possui nem saldo nem limite suficientes, que no caso iria retornar "Operação Negada".

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Obrigada pela sugestão :)

@Marianaliima Marianaliima left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

olá, parabéns pela entrega, seria bom refatorar os testes para usar variavas globais

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