UNPKG

node-elizabeth

Version:
86 lines (66 loc) 3.15 kB
'use strict'; var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; var _providers = require('../providers.js'); var _util = require('./../util'); var _address = require('../locales/int/address.js'); var data = (0, _util.pull)('address.json', 'en'); var address = new _providers.Address(); describe('Test address provider', function () { it('should be return random number', function () { expect(address.streetNumber()).toBeGreaterThanOrEqual(1); expect(address.streetNumber()).toBeLessThanOrEqual(1400); }); it('should be in array', function () { expect(data.street.name).toContain(address.streetName()); }); it('should be in array', function () { expect(data.street.suffix).toContain(address.streetSuffix()); }); it('should be string', function () { expect(_typeof(address.address())).toBe('string'); }); it('should be in array', function () { expect(data.state.abbr).toContain(address.state({ abbr: true })); expect(data.state.name).toContain(address.state()); }); it('should be in array', function () { expect(data.country.name).toContain(address.country()); }); it('should be in array', function () { expect(data.city).toContain(address.city()); }); it('should be number and have diapason (-180 to 180)', function () { expect(_typeof(address.longitude())).toBe('number'); expect(address.longitude()).toBeGreaterThanOrEqual(-180); expect(address.longitude()).toBeLessThanOrEqual(180); }); it('should be number and have diapason (-90 to 90)', function () { expect(_typeof(address.latitude())).toBe('number'); expect(address.latitude()).toBeGreaterThanOrEqual(-90); expect(address.latitude()).toBeLessThanOrEqual(90); }); it('should be object and have latitude and longitude', function () { var result = address.coordinates(); expect(result).toBeInstanceOf(Object); var longitude = result['longitude']; expect(typeof longitude === 'undefined' ? 'undefined' : _typeof(longitude)).toBe('number'); expect(longitude).toBeGreaterThanOrEqual(-180); expect(longitude).toBeLessThanOrEqual(180); var latitude = result['latitude']; expect(typeof latitude === 'undefined' ? 'undefined' : _typeof(latitude)).toBe('number'); expect(latitude).toBeGreaterThanOrEqual(-180); expect(latitude).toBeLessThanOrEqual(180); }); it('should be in array', function () { expect(_address.CONTINENT_CODES).toContain(address.continent({ code: true })); expect(data.continent).toContain(address.continent()); }); it('should be in array', function () { expect(_address.COUNTRIES_ISO['iso2']).toContain(address.countryISO()); }); it('should raise error if format is unsupported', function () { expect(function () { return address.countryISO({ format: 'unsupported' }); }).toThrow(new Error('Unsupported format. Use: ' + Object.keys(_address.COUNTRIES_ISO))); }); });