UNPKG

random-names-hebrew

Version:
65 lines (64 loc) 3.05 kB
"use strict"; exports.__esModule = true; // Use mocah to excute this test var chai_1 = require("chai"); // https://www.chaijs.com/api/bdd/ var name_1 = require("./name"); var generalExpect = function (name, phone) { (0, chai_1.expect)(name.firstName).to.be.a.string; (0, chai_1.expect)(name.lastName).to.be.a.string; (0, chai_1.expect)(name.fullName).to.be.a.string; if (!phone) (0, chai_1.expect)(name.phone).to.be["null"]; (0, chai_1.expect)("".concat(name.firstName, " ").concat(name.lastName)).to.be.equal(name.fullName); }; describe('Create a random name method:', function () { it('without params', function () { var name = (0, name_1["default"])(); generalExpect(name, false); }); it('Param gender [boys]', function () { var name = (0, name_1["default"])({ gender: 'boys' }); generalExpect(name, false); }); it('Param gender [girls]', function () { var name = (0, name_1["default"])({ gender: 'girls' }); generalExpect(name, false); }); it('Param gender [unisex]', function () { var name = (0, name_1["default"])({ gender: 'unisex' }); generalExpect(name, false); }); it('Param phone [true]', function () { var name = (0, name_1["default"])({ phone: true }); generalExpect(name, true); (0, chai_1.expect)(name.phone).to.be.a('string'); (0, chai_1.expect)(name.phone).to.have.lengthOf(10); (0, chai_1.expect)(name.phone).to.match(/^\d{10}$/); }); it('Params {phone: true, phoneFormat: "e164"}', function () { var name = (0, name_1["default"])({ phone: true, phoneFormat: "e164" }); generalExpect(name, true); (0, chai_1.expect)(name.phone).to.be.a('string'); (0, chai_1.expect)(name.phone).to.have.lengthOf(13); (0, chai_1.expect)(name.phone[0]).to.equal('+'); (0, chai_1.expect)(name.phone).to.match(/^\+\d{12}$/); }); it('Params {phone: true, phoneFormat: "formatted"}', function () { var name = (0, name_1["default"])({ phone: true, phoneFormat: "formatted" }); generalExpect(name, true); (0, chai_1.expect)(name.phone).to.be.a('string'); (0, chai_1.expect)(name.phone).to.have.lengthOf(12); (0, chai_1.expect)(name.phone).to.match(/^\d{3}-\d{3}-\d{4}$/); (0, chai_1.expect)("".concat(name.firstName, " ").concat(name.lastName)).to.be.equal(name.fullName); }); it('Params {phone: true, phoneFormat: "object"}', function () { var name = (0, name_1["default"])({ phone: true, phoneFormat: "object" }); generalExpect(name, true); (0, chai_1.expect)(name.phone).to.be.a('object'); (0, chai_1.expect)(name.phone.formatted).to.have.lengthOf(12); (0, chai_1.expect)(name.phone.number).to.have.lengthOf(10); (0, chai_1.expect)(name.phone.number).to.match(/^\d{10}$/); (0, chai_1.expect)(name.phone.e164).to.have.lengthOf(13); (0, chai_1.expect)(name.phone.e164).to.match(/^\+\d{12}$/); }); });