UNPKG

purespectrum-lib

Version:

shared code between front and backend projects

48 lines 2.52 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var qualification_codes_1 = require("../../shared/qualification-codes"); var child_age_gender_mapper_constants_1 = require("../child-age-gender-mapper.constants"); qualification_codes_1.CHILD_AGE_GENDER; var child_1 = require("./child"); describe('Child, gender and age Mapper', function () { it('should create children from code properly', function () { for (var index = 0; index < child_age_gender_mapper_constants_1.MONTHS; index++) { var boy = new child_1.Child(qualification_codes_1.CHILD_AGE_GENDER.BOYS_CONDITIONS_CODES[index]); var girl = new child_1.Child(qualification_codes_1.CHILD_AGE_GENDER.GIRLS_CONDITIONS_CODES[index]); var month = index + 1; var age = month % 12 === 0 ? month / 12 : month; // create children expect(boy.noChildren).toBeFalsy(); expect(girl.noChildren).toBeFalsy(); expect(boy.isBoy).toBeTruthy(); expect(girl.isBoy).toBeFalsy(); expect(boy.age).toBe(age); expect(girl.age).toBe(age); // create noChildren if (month === child_age_gender_mapper_constants_1.NO_CHILDREN_CODE) { var notChild = new child_1.Child(month); expect(notChild.noChildren).toBeTruthy(); } } }); it('should create children from criterias properly', function () { for (var month = 1; month <= child_age_gender_mapper_constants_1.MONTHS; month++) { var age = month % 12 === 0 ? month / 12 : month; var boy = child_1.Child.create(true, true, age); var girl = child_1.Child.create(true, false, age); var boyCode = qualification_codes_1.CHILD_AGE_GENDER.BOYS_CONDITIONS_CODES[age - 1]; var girlCode = qualification_codes_1.CHILD_AGE_GENDER.GIRLS_CONDITIONS_CODES[age - 1]; expect(boy.code).toBe(boyCode); expect(girl.code).toBe(girlCode); } // create noChildren var notChild = child_1.Child.createNoChildren(); expect(notChild.noChildren).toBeTruthy(); expect(notChild.code).toBe(child_age_gender_mapper_constants_1.NO_CHILDREN_CODE); var boyBaby = child_1.Child.create(true, true, 1); var girlBaby = child_1.Child.create(true, false, 1); expect(boyBaby.code).toBe(111); expect(girlBaby.code).toBe(112); }); }); //# sourceMappingURL=child.spec.js.map