Skip to content

Ellie Konuma 28/06 home assignment #21

Open
EllieKonuma wants to merge 9 commits into
reprograma:mainfrom
EllieKonuma:main
Open

Ellie Konuma 28/06 home assignment #21
EllieKonuma wants to merge 9 commits into
reprograma:mainfrom
EllieKonuma:main

Conversation

@EllieKonuma

Copy link
Copy Markdown

🤣👌

Comment thread atividades/para-casa/ellie-konuma/contaBancaria.test.js Outdated
Comment thread atividades/para-casa/ellie-konuma/contaBancaria.test.js Outdated
Comment thread atividades/para-casa/ellie-konuma/test.js Outdated
{
"name": "Isa",
"balance": 1000,
"limit": 1000

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

gostei que você fez um arquivo diferente em Json para as contas! Eu tinha feito uma constante no próprio arquivo das funções só

return acc ? { ok: acc } : { error: "account not found" };
};

const hasError = (res) => (Object.keys(res)[0] === "error" ? true : false);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

gostei dessa função de erro! não tinha pensado nisso

@@ -0,0 +1,99 @@
const findAccount = (name, accounts) => {
const acc = accounts.find((acc) => acc.name == name);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

aqui minha única sugestão é usar o === para a busca ser mais restrita, caso tenha alguma questão de tipo de variável e usar um filter pq duas pessoas podem ter o mesmo nome (não no caso do seu json, mas pensando de forma abrangente)


let { balance } = res.ok;

return { ok: balance };

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

eu nem sei se isso é uma boa prática de código, mas vejo aqui a possibilidade de fazer uma única função tipo checkInformation para verificar o balance e o limit na mesma função

let { limit } = res.ok;

if (limit == null) return { error: "limit not active" };
if (limit === 0) return { error: "limit not available" };

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

achei bem legal como vc fez tratamento de erro sempre


describe("check if result has error", () => {
it("should be true", () => {
expect(hasError({ error: "bubla" })).toEqual(true);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

bubla hahahah

{
name: "Isa",
balance: 1000,
limit: 1000,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

muito legal que vc usou o beforeEach(), vendo o seu vejo que podia ter usado do mesmo jeito

@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á tudo bem? seu código ficou muito bem construído, parabéns. Uma dica vi que comentou o beforeEach não seria melhor utilizar para criar um código menos verboso? também vi alguns comentários no código fique atenta a essa questão, mas de novo parabéns pela entrega

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