Skip to content
Snippets Groups Projects
Commit 00ddac18 authored by Agustin Ruiz Diaz Cambon's avatar Agustin Ruiz Diaz Cambon
Browse files

first unit tests feature/Calculo

parent 6b24e0c7
No related branches found
No related tags found
No related merge requests found
Pipeline #15865 passed
const age = require('../src/Enum/AgeBracket');
const sex = require('../src/Enum/Sex');
const sum = 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); });
});
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,
}, [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,
}, [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,
}, [310.2, 63.3, -0.263, 14, -15, 15],
{ lowPALPrevalence: 25, moderatePALPrevalence: 25, intensePALPrevalence: 50 }))).toBe(3471);
});
});
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,
}, [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,
}, [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,
}, [11.711, 587.7, 1.95, 1.65, 1.85, 1.55]))).toBe(1362);
});
});
This diff is collapsed.
......@@ -21,6 +21,7 @@
"devDependencies": {
"@types/cors": "^2.8.12",
"@types/express": "^4.17.13",
"@types/jest": "^27.0.2",
"@types/node": "^16.7.10",
"@types/swagger-jsdoc": "^6.0.1",
"@types/swagger-ui-express": "^4.1.3",
......@@ -37,11 +38,12 @@
"eslint-plugin-react": "^7.21.5",
"eslint-plugin-react-hooks": "^4.0.8",
"husky": "^4.3.8",
"jest": "^27.0.6",
"jest": "^27.2.3",
"lint-staged": "^11.1.2",
"nodemon": "^2.0.12",
"ts-jest": "^27.0.5",
"ts-node": "^10.2.1",
"typescript": "^4.4.2"
"typescript": "^4.4.3"
},
"scripts": {
"start": "nodemon ./src/index.ts",
......
export const SheetNames = {
HOMBRES: 'Hombres',
MUJERES: 'Mujeres',
HOMBRES_MENORES: 'Hombres<1',
MUJERES_MENORES: 'Mujeres<1',
};
export const SheetNames = {
HOMBRES: 'Hombres',
MUJERES: 'Mujeres',
HOMBRES_MENORES: 'Hombres<1',
MUJERES_MENORES: 'Mujeres<1',
};
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