Add unit tests to coefficients calc#4
Add unit tests to coefficients calc#4KleversonNascimento wants to merge 53 commits intoremove-fleak-testsfrom
Conversation
Atualização do README do projeto do server
4591030 to
56fb24f
Compare
949ad7c to
bfbc822
Compare
Fix and skip broken tests
Atualizando README.md do ufabc-next-server
…fo-test Create user info route test
Add pull request template
Add CI to run unit tests
Add unit tests to POST /v1/comments route
|
|
||
| return null | ||
| } No newline at end of file | ||
| module.exports = {calculateAlunoCoefficientsData, isAprovado, convertGradeToNumber, parseCategory} No newline at end of file |
There was a problem hiding this comment.
Deixar o module.exports exportando dessa forma pode quebrar outros lugares que importam esse arquivo e esperam uma função diretamente (como no app/agenda/processors/enrollments/updateUserEnrollments.js#L24). Nesse caso para conseguir testar essas funções menores, como o convertGradeToNumber, voce pode dar um export exclusivo nela e ainda sim manter module.exports exportando a função principal. Então ficando:
module.exports.parseCategory = function parseCategory(category) {
if (category === "Livre Escolha") return "free";
else if (category === "Obrigatória") return "mandatory";
else if (category === "Opção Limitada") return "limited";
return null;
};E dentro do teste, voce consegue acessar da mesma maneira, com excessão da função principal que voce pode chamar direto func() sem precisar acessar alguma chave especifica func.isAprovado()
There was a problem hiding this comment.
Valeu! Corrigi e abri o PR com essa e as outras alterações em: ufabc-next#103
| @@ -0,0 +1,117 @@ | |||
| const assert = require('assert') | |||
|
|
|||
| const func = require('./coefficients') | |||
There was a problem hiding this comment.
Nesse caso, não estamos tratando de uma func, então poderia ser chamado de coefficients mesmo
Teste unitário referente ao findIdeais
Change Request
Description
Add unit tests to methods that calculate coefficients
How do I test this?
yarn testChecklist
bug,ready to reviewetc.