UNPKG

random-names-hebrew

Version:
104 lines (103 loc) 5.63 kB
"use strict"; exports.__esModule = true; var chai_1 = require("chai"); var batch_1 = require("./batch"); describe('Create a random batch method:', function () { it('with param to return 1 row', function () { var batch = (0, batch_1["default"])(); batch.then(function (names) { var amount = 1; (0, chai_1.expect)(names).to.have.lengthOf(amount); for (var i = 0; i < amount; i++) { (0, chai_1.expect)(names[i].firstName).to.be.a.string; (0, chai_1.expect)(names[i].lastName).to.be.a.string; (0, chai_1.expect)(names[i].fullName).to.be.a.string; (0, chai_1.expect)(names[i].phone).to.be["null"]; (0, chai_1.expect)("".concat(names[i].firstName, " ").concat(names[i].lastName)).to.be.equal(names[i].fullName); } })["catch"](function (e) { console.log(e); process.exit(); }); }); it('with param to return 2 row params is a number 2', function () { var amount = 2; var batch = (0, batch_1["default"])(amount); batch.then(function (names) { (0, chai_1.expect)(names).to.have.lengthOf(amount); for (var i = 0; i < amount; i++) { (0, chai_1.expect)(names[i].firstName).to.be.a.string; (0, chai_1.expect)(names[i].lastName).to.be.a.string; (0, chai_1.expect)(names[i].fullName).to.be.a.string; (0, chai_1.expect)(names[i].phone).to.be["null"]; (0, chai_1.expect)("".concat(names[i].firstName, " ").concat(names[i].lastName)).to.be.equal(names[i].fullName); } }); }); it('with param to return 1 row params amount 0', function () { var amount = 0; var batch = (0, batch_1["default"])({ amount: amount }); batch.then(function (names) { (0, chai_1.expect)(names).to.have.lengthOf(amount + 1); for (var i = 0; i < amount + 1; i++) { (0, chai_1.expect)(names[i].firstName).to.be.a.string; (0, chai_1.expect)(names[i].lastName).to.be.a.string; (0, chai_1.expect)(names[i].fullName).to.be.a.string; (0, chai_1.expect)(names[i].phone).to.be["null"]; (0, chai_1.expect)("".concat(names[i].firstName, " ").concat(names[i].lastName)).to.be.equal(names[i].fullName); } }); }); it('with param to return 3 row params amount 3', function () { var amount = 3; var batch = (0, batch_1["default"])({ amount: amount }); batch.then(function (names) { (0, chai_1.expect)(names).to.have.lengthOf(amount); for (var i = 0; i < amount; i++) { (0, chai_1.expect)(names[i].firstName).to.be.a.string; (0, chai_1.expect)(names[i].lastName).to.be.a.string; (0, chai_1.expect)(names[i].fullName).to.be.a.string; (0, chai_1.expect)(names[i].phone).to.be["null"]; (0, chai_1.expect)("".concat(names[i].firstName, " ").concat(names[i].lastName)).to.be.equal(names[i].fullName); } }); }); it('Params {phone: true, phoneFormat: "object", amount: 10}', function () { var batch = (0, batch_1["default"])({ amount: 10, phone: true, phoneFormat: "object" }); batch.then(function (names) { (0, chai_1.expect)(names).to.have.lengthOf(10); for (var i = 0; i < names.length; i++) { (0, chai_1.expect)(names[i].firstName).to.be.a.string; (0, chai_1.expect)(names[i].lastName).to.be.a.string; (0, chai_1.expect)(names[i].fullName).to.be.a.string; (0, chai_1.expect)(names[i].phone).to.be.a('object'); (0, chai_1.expect)(names[i].phone.formatted).to.have.lengthOf(12); (0, chai_1.expect)(names[i].phone.number).to.have.lengthOf(10); (0, chai_1.expect)(names[i].phone.number).to.match(/^\d{10}$/); (0, chai_1.expect)(names[i].phone.e164).to.have.lengthOf(13); (0, chai_1.expect)(names[i].phone.e164).to.match(/^\+\d{12}$/); (0, chai_1.expect)("".concat(names[i].firstName, " ").concat(names[i].lastName)).to.be.equal(names[i].fullName); } }); }); // a heavy test it('** Heavy load ** Params {phone: true, phoneFormat: "object", amount: 100,000}', function () { var amount = 100000; var batch = (0, batch_1["default"])({ amount: amount, phone: true, phoneFormat: "object" }); batch.then(function (names) { (0, chai_1.expect)(names).to.have.lengthOf(amount); for (var i = 0; i < names.length; i++) { (0, chai_1.expect)(names[i].firstName).to.be.a.string; (0, chai_1.expect)(names[i].lastName).to.be.a.string; (0, chai_1.expect)(names[i].fullName).to.be.a.string; (0, chai_1.expect)(names[i].phone).to.be.a('object'); (0, chai_1.expect)(names[i].phone.formatted).to.have.lengthOf(12); (0, chai_1.expect)(names[i].phone.number).to.have.lengthOf(10); (0, chai_1.expect)(names[i].phone.number).to.match(/^\d{10}$/); (0, chai_1.expect)(names[i].phone.e164).to.have.lengthOf(13); (0, chai_1.expect)(names[i].phone.e164).to.match(/^\+\d{12}$/); (0, chai_1.expect)("".concat(names[i].firstName, " ").concat(names[i].lastName)).to.be.equal(names[i].fullName); } }); }); });