Skip to content
Snippets Groups Projects
Commit 942082e5 authored by Julieta Dubra Raimunde's avatar Julieta Dubra Raimunde
Browse files

Fix en el jest

parent 00ddac18
No related branches found
No related tags found
No related merge requests found
Pipeline #15877 passed with stage
in 2 minutes and 13 seconds
{
"env": {
"test": {
"presets": ["@babel/preset-typescript"],
"plugins": ["@babel/plugin-transform-modules-commonjs"]
}
}
}
\ No newline at end of file
{
}
\ No newline at end of file
const age = require('../src/Enum/AgeBracket');
const sex = require('../src/Enum/Sex');
import age from '../src/Enum/AgeBracket';
import sex from '../src/Enum/Sex';
const sum = require('../src/Services/ERCalculator');
const ERCalculator = require('../src/Services/ERCalculator');
describe('Check', () => {
it("Probar si se devuelve 'true' cuando el tipo es IndividualMaternity", () => { expect(sum.isIndividualMaternity({ pregnantWoman: 5, lactatingWomen: 2 })).toBe(true); });
it("Probar si se devuelve 'false' cuando el tipo NO es IndividualMaternity", () => { expect(sum.isIndividualMaternity({ countryBirthRate: 3, countryWomenInAgeGroup: 2, countryPopulation: 1239 })).toBe(false); });
it("Probar si se devuelve 'true' cuando el tipo es IndividualMaternity", () => { expect(ERCalculator.isIndividualMaternity({ pregnantWoman: 5, lactatingWomen: 2 })).toBe(true); });
it("Probar si se devuelve 'false' cuando el tipo NO es IndividualMaternity", () => { expect(ERCalculator.isIndividualMaternity({ countryBirthRate: 3, countryWomenInAgeGroup: 2, countryPopulation: 1239 })).toBe(false); });
});
describe('Verificar si funciona el cálculo del GET (entre 6 y 17 años)', () => {
it('Varones de 15 años', () => {
expect(Math.round(sum.calculateTEE({
age: AgeBracket.a15, sex: Sex.Male, medianWeight: 55, population: 5,
expect(Math.round(ERCalculator.calculateTEE({
age: age.a15, sex: sex.Male, medianWeight: 55, population: 5,
}, [310.2, 63.3, -0.263, 31, -15, 15],
{ lowPALPrevalence: 20, moderatePALPrevalence: 80, intensePALPrevalence: 0 }))).toBe(2906);
});
it('Mujeres de 8 años', () => {
expect(Math.round(sum.calculateTEE({
age: AgeBracket.a8, sex: Sex.Female, medianWeight: 26.7, population: 9,
expect(Math.round(ERCalculator.calculateTEE({
age: age.a8, sex: sex.Female, medianWeight: 26.7, population: 9,
}, [263.4, 65.3, -0.454, 20, -15, 15],
{ lowPALPrevalence: 11, moderatePALPrevalence: 89, intensePALPrevalence: 0 }))).toBe(1655);
});
it('Varones de 17 años', () => {
expect(Math.round(sum.calculateTEE({
age: AgeBracket.a17, sex: Sex.Male, medianWeight: 66.1, population: 18,
expect(Math.round(ERCalculator.calculateTEE({
age: age.a17, sex: sex.Male, medianWeight: 66.1, population: 18,
}, [310.2, 63.3, -0.263, 14, -15, 15],
{ lowPALPrevalence: 25, moderatePALPrevalence: 25, intensePALPrevalence: 50 }))).toBe(3471);
});
......@@ -31,18 +31,18 @@ describe('Verificar si funciona el cálculo del GET (entre 6 y 17 años)', () =>
describe('Verificar si funciona el cálculo del TMB (mayores a 18 años)', () => {
it('Varones de 18-29 años', () => {
expect(Math.round(sum.calculateBMR({
age: AgeBracket.a18_29, sex: Sex.Male, medianWeight: 73.1, population: 13,
expect(Math.round(ERCalculator.calculateBMR({
age: age.a18_29, sex: sex.Male, medianWeight: 73.1, population: 13,
}, [15.057, 692.2, 1.95, 1.65, 1.85, 1.55]))).toBe(1793);
});
it('Mujeres de 30-59 años', () => {
expect(Math.round(sum.calculateBMR({
age: AgeBracket.a30_59, sex: Sex.Female, medianWeight: 63.8, population: 21,
expect(Math.round(ERCalculator.calculateBMR({
age: age.a30_59, sex: sex.Female, medianWeight: 63.8, population: 21,
}, [8.126, 845.6, 1.95, 1.65, 1.85, 1.55, 208, 251]))).toBe(1364);
});
it('Varones de 60+ años', () => {
expect(Math.round(sum.calculateBMR({
age: AgeBracket.a60, sex: Sex.Male, medianWeight: 66.1, population: 11,
expect(Math.round(ERCalculator.calculateBMR({
age: age.a60, sex: sex.Male, medianWeight: 66.1, population: 11,
}, [11.711, 587.7, 1.95, 1.65, 1.85, 1.55]))).toBe(1362);
});
});
This diff is collapsed.
......@@ -19,6 +19,9 @@
"yamljs": "^0.3.0"
},
"devDependencies": {
"@babel/plugin-transform-modules-commonjs": "^7.15.4",
"@babel/preset-env": "^7.15.6",
"@babel/preset-typescript": "^7.15.0",
"@types/cors": "^2.8.12",
"@types/express": "^4.17.13",
"@types/jest": "^27.0.2",
......@@ -48,7 +51,7 @@
"scripts": {
"start": "nodemon ./src/index.ts",
"test": "jest",
"pretest": "./node_modules/.bin/eslint --ignore-path .gitignore . --fix"
"pretest": "lint-staged"
},
"repository": {
"type": "git",
......
......@@ -299,4 +299,20 @@ const calculateER = (groupParameters: Map<number[], AgeGroup>, data: ExtraData):
return result;
};
module.exports = {
calculateER,
calculate60PlusYears,
calculate30To59Years,
calculate18To29Years,
calculate6To17Years,
calculate1To5Years,
calculateLessThanAYear,
calculateERWomenPopulation,
calculateERWomenIndividual,
calculatePAL,
calculateBMR,
calculateTEE,
isIndividualMaternity,
};
export default { calculateER };
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment