purespectrum-lib
Version:
shared code between front and backend projects
163 lines • 6.58 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var index_1 = require("index");
var children_1 = require("./children");
var quota_mapper_constants_1 = require("../quota-mapper/quota-mapper.constants");
describe('Children', function () {
it('Boy age 0 to 5 years', function () {
var conditionCodes = [
'111',
'113',
'115',
'117',
'119',
'121',
'123',
'125',
'127',
'129',
'131',
'133',
'135',
'137',
'139',
'141',
];
var childrenQuotas = conditionCodes.map(function (code) { return new index_1.Child(Number(code)); });
var result = new children_1.Children(childrenQuotas);
expect(result.ageUnit).toBe(311);
expect(result.age.from).toBe(0);
expect(result.age.to).toBe(5);
var isBaby = false;
var gender = '111';
var fromAge = 0;
var toAge = 5;
var resultFromCreate = children_1.Children.create(isBaby, gender, fromAge, toAge);
expect(resultFromCreate.ageUnit).toBe(311);
expect(resultFromCreate.age.from).toBe(fromAge);
expect(resultFromCreate.age.to).toBe(toAge);
var resultFromCreateNotBaby = children_1.Children.create(false, gender, 1, toAge);
expect(resultFromCreateNotBaby.ageUnit).toBe(311);
expect(resultFromCreateNotBaby.age.from).toBe(1);
expect(resultFromCreateNotBaby.age.to).toBe(5);
});
it('Girl age 0 to 5 years', function () {
var conditionCodes = [
'112',
'114',
'116',
'118',
'120',
'122',
'124',
'126',
'128',
'130',
'132',
'134',
'136',
'138',
'140',
'142',
];
var childrenQuotas = conditionCodes.map(function (code) { return new index_1.Child(Number(code)); });
var result = new children_1.Children(childrenQuotas);
expect(result.ageUnit).toBe(311);
expect(result.age.from).toBe(0);
expect(result.age.to).toBe(5);
var isBaby = false;
var gender = '112';
var fromAge = 0;
var toAge = 5;
var resultFromCreate = children_1.Children.create(isBaby, gender, fromAge, toAge);
expect(resultFromCreate.ageUnit).toBe(311);
expect(resultFromCreate.age.from).toBe(0);
expect(resultFromCreate.age.to).toBe(5);
var resultFromCreateNotBaby = children_1.Children.create(false, gender, 1, toAge);
expect(resultFromCreateNotBaby.ageUnit).toBe(311);
expect(resultFromCreateNotBaby.age.from).toBe(1);
expect(resultFromCreateNotBaby.age.to).toBe(5);
});
it('Boy age 1 to 5 years', function () {
var conditionCodes = ['133', '135', '137', '139', '141'];
var childrenQuotas = conditionCodes.map(function (code) { return new index_1.Child(Number(code)); });
var result = new children_1.Children(childrenQuotas);
expect(result.ageUnit).toBe(311);
expect(result.age.from).toBe(1);
expect(result.age.to).toBe(5);
});
it('Girl age 1 to 5 years', function () {
var conditionCodes = ['134', '136', '138', '140', '142'];
var childrenQuotas = conditionCodes.map(function (code) { return new index_1.Child(Number(code)); });
var result = new children_1.Children(childrenQuotas);
expect(result.ageUnit).toBe(311);
expect(result.age.from).toBe(1);
expect(result.age.to).toBe(5);
});
it('Boy age 1 to 2 years', function () {
var isBaby = false;
var gender = '111';
var fromAge = 1;
var toAge = 2;
var result = children_1.Children.create(isBaby, gender, fromAge, toAge);
expect(result.gender).toBe(gender);
expect(result.ageUnit).toBe(quota_mapper_constants_1.YEARS_CHILD_AGE_UNIT_CODE);
expect(result.age.from).toBe(fromAge);
expect(result.age.to).toBe(toAge);
expect(result.noChildren).toBe(false);
expect(result.description).toBe('Children');
});
it('Both gender age 0 to 3 years', function () {
var isBaby = false;
var gender = 'both';
var fromAge = 0;
var toAge = 3;
var result = children_1.Children.create(isBaby, gender, fromAge, toAge);
expect(result.gender).toBe(gender);
expect(result.ageUnit).toBe(quota_mapper_constants_1.YEARS_CHILD_AGE_UNIT_CODE);
expect(result.age.from).toBe(fromAge);
expect(result.age.to).toBe(toAge);
expect(result.noChildren).toBe(false);
expect(result.description).toBe('Children');
});
it('Both gender age 0 to 15 months', function () {
var isBaby = true;
var gender = 'both';
var fromAge = 0;
var toAge = 15;
var result = children_1.Children.create(isBaby, gender, fromAge, toAge);
expect(result.gender).toBe(gender);
expect(result.ageUnit).toBe(quota_mapper_constants_1.MONTHS_CHILD_AGE_UNIT_CODE);
expect(result.age.from).toBe(1);
expect(result.age.to).toBe(toAge);
expect(result.noChildren).toBe(false);
expect(result.description).toBe('Children');
});
it('Girl age 1 to 38 months', function () {
var isBaby = true;
var gender = '112';
var fromAge = 1;
var toAge = 38;
var result = children_1.Children.create(isBaby, gender, fromAge, toAge);
expect(result.gender).toBe(gender);
expect(result.ageUnit).toBe(quota_mapper_constants_1.MONTHS_CHILD_AGE_UNIT_CODE);
expect(result.age.from).toBe(fromAge);
expect(result.age.to).toBe(toAge);
expect(result.noChildren).toBe(false);
expect(result.description).toBe('Children');
});
it('Boy age 0 to 47 months', function () {
var isBaby = true;
var gender = '111';
var fromAge = 1;
var toAge = 47;
var result = children_1.Children.create(isBaby, gender, fromAge, toAge);
expect(result.gender).toBe(gender);
expect(result.ageUnit).toBe(quota_mapper_constants_1.MONTHS_CHILD_AGE_UNIT_CODE);
expect(result.age.from).toBe(fromAge);
expect(result.age.to).toBe(toAge);
expect(result.noChildren).toBe(false);
expect(result.description).toBe('Children');
});
});
//# sourceMappingURL=children.spec.js.map