UNPKG

node-elizabeth

Version:
45 lines (34 loc) 1.49 kB
"use strict"; var _providers = require("../providers.js"); var _code = require("../locales/int/code.js"); var code = new _providers.Code(); describe('Test code provider', function () { it('should return item from 4 digits', function () { expect(code.pin()).toMatch(/^[0-9]{4}$/); }); it('should return isbn code', function () { var isbn13Regexp = new RegExp(/\d{3}-?(\d{1,3}|#)-\d{5}-\d{3}-\d{1}/); var isbn10Regexp = new RegExp(/(\d{1,3}|#)-\d{5}-\d{3}-\d{1}/); expect(code.isbn()).toMatch(isbn10Regexp); expect(code.isbn({ format: 'isbn-13' })).toMatch(isbn13Regexp); var localeWithNoIsbnGroup = new _providers.Code({ locale: 'en-au' }); expect(localeWithNoIsbnGroup.isbn()).toMatch(isbn10Regexp); expect(localeWithNoIsbnGroup.isbn({ format: 'isbn-13' })).toMatch(isbn13Regexp); }); it('should return mask from 4 chars', function () { expect(code.customCode()).toHaveLength(4); }); it('should return random item from array', function () { expect(_code.LOCALE_CODES).toContain(code.localeCode()); }); it('should return item from 8 and 13 digits', function () { expect(code.ean({ format: 'ean-8' })).toMatch(/^[0-9]{8}$/); expect(code.ean()).toMatch(/^[0-9]{13}$/); }); it('should return mask fromat 4 digits - 4 digits', function () { expect(code.issn()).toMatch(/^[0-9]{4}-[0-9]{4}$/); }); it('should return string <= 15 digits', function () { expect(code.imei()).toMatch(/^\d{14,15}$/); }); });