@accounts/client
Advanced tools
Comparing version 0.0.9-alpha.146b94d6 to 0.0.9-alpha.458b4e87
@@ -493,3 +493,3 @@ 'use strict'; | ||
if (this.options.onSignedInHook) { | ||
if (this.options.onSignedInHook && (0, _lodash.isFunction)(this.options.onSignedInHook)) { | ||
this.options.onSignedInHook(); | ||
@@ -679,3 +679,3 @@ } | ||
case 0: | ||
if (email) { | ||
if (_common.validators.validateEmail(email)) { | ||
_context13.next = 2; | ||
@@ -685,3 +685,3 @@ break; | ||
throw new _common.AccountsError('Email must be provided'); | ||
throw new _common.AccountsError('Valid email must be provided'); | ||
@@ -724,3 +724,3 @@ case 2: | ||
case 0: | ||
if (email) { | ||
if (_common.validators.validateEmail(email)) { | ||
_context14.next = 2; | ||
@@ -730,3 +730,3 @@ break; | ||
throw new _common.AccountsError('Email must be provided'); | ||
throw new _common.AccountsError('Valid email must be provided'); | ||
@@ -733,0 +733,0 @@ case 2: |
@@ -1119,3 +1119,3 @@ 'use strict'; | ||
_context32.next = 5; | ||
return _AccountsClient2.default.requestPasswordReset('email'); | ||
return _AccountsClient2.default.requestPasswordReset('email@g.co'); | ||
@@ -1151,7 +1151,7 @@ case 5: | ||
_context33.next = 4; | ||
return _AccountsClient2.default.requestPasswordReset('email'); | ||
return _AccountsClient2.default.requestPasswordReset('email@g.co'); | ||
case 4: | ||
expect(mock.mock.calls.length).toEqual(1); | ||
expect(mock.mock.calls[0][0]).toEqual('email'); | ||
expect(mock.mock.calls[0][0]).toEqual('email@g.co'); | ||
@@ -1165,7 +1165,5 @@ case 6: | ||
}))); | ||
}); | ||
describe('requestVerificationEmail', function () { | ||
it('should return an AccountsError', _asyncToGenerator(regeneratorRuntime.mark(function _callee34() { | ||
var error; | ||
it('should throw if an invalid email is provided', _asyncToGenerator(regeneratorRuntime.mark(function _callee34() { | ||
var mock; | ||
return regeneratorRuntime.wrap(function _callee34$(_context34) { | ||
@@ -1175,10 +1173,8 @@ while (1) { | ||
case 0: | ||
error = 'something bad'; | ||
mock = jest.fn(); | ||
_AccountsClient2.default.config({}, { sendVerificationEmail: function sendVerificationEmail() { | ||
return Promise.reject({ message: error }); | ||
} }); | ||
_AccountsClient2.default.config({}, { sendResetPasswordEmail: mock }); | ||
_context34.prev = 2; | ||
_context34.next = 5; | ||
return _AccountsClient2.default.requestVerificationEmail('email'); | ||
return _AccountsClient2.default.requestPasswordReset('email'); | ||
@@ -1192,5 +1188,6 @@ case 5: | ||
expect(_context34.t0.message).toEqual(error); | ||
expect(_context34.t0.message).toEqual('Valid email must be provided'); | ||
expect(mock.mock.calls.length).toEqual(0); | ||
case 11: | ||
case 12: | ||
case 'end': | ||
@@ -1202,5 +1199,7 @@ return _context34.stop(); | ||
}))); | ||
}); | ||
it('should call transport.sendVerificationEmail', _asyncToGenerator(regeneratorRuntime.mark(function _callee35() { | ||
var mock; | ||
describe('requestVerificationEmail', function () { | ||
it('should return an AccountsError', _asyncToGenerator(regeneratorRuntime.mark(function _callee35() { | ||
var error; | ||
return regeneratorRuntime.wrap(function _callee35$(_context35) { | ||
@@ -1210,2 +1209,34 @@ while (1) { | ||
case 0: | ||
error = 'something bad'; | ||
_AccountsClient2.default.config({}, { sendVerificationEmail: function sendVerificationEmail() { | ||
return Promise.reject({ message: error }); | ||
} }); | ||
_context35.prev = 2; | ||
_context35.next = 5; | ||
return _AccountsClient2.default.requestVerificationEmail('email@g.co'); | ||
case 5: | ||
throw new Error(); | ||
case 8: | ||
_context35.prev = 8; | ||
_context35.t0 = _context35['catch'](2); | ||
expect(_context35.t0.message).toEqual(error); | ||
case 11: | ||
case 'end': | ||
return _context35.stop(); | ||
} | ||
} | ||
}, _callee35, undefined, [[2, 8]]); | ||
}))); | ||
it('should call transport.sendVerificationEmail', _asyncToGenerator(regeneratorRuntime.mark(function _callee36() { | ||
var mock; | ||
return regeneratorRuntime.wrap(function _callee36$(_context36) { | ||
while (1) { | ||
switch (_context36.prev = _context36.next) { | ||
case 0: | ||
mock = jest.fn(function () { | ||
@@ -1216,17 +1247,48 @@ return Promise.resolve(); | ||
_AccountsClient2.default.config({}, { sendVerificationEmail: mock }); | ||
_context35.next = 4; | ||
return _AccountsClient2.default.requestVerificationEmail('email'); | ||
_context36.next = 4; | ||
return _AccountsClient2.default.requestVerificationEmail('email@g.co'); | ||
case 4: | ||
expect(mock.mock.calls.length).toEqual(1); | ||
expect(mock.mock.calls[0][0]).toEqual('email'); | ||
expect(mock.mock.calls[0][0]).toEqual('email@g.co'); | ||
case 6: | ||
case 'end': | ||
return _context35.stop(); | ||
return _context36.stop(); | ||
} | ||
} | ||
}, _callee35, undefined); | ||
}, _callee36, undefined); | ||
}))); | ||
it('should throw if an invalid email is provided', _asyncToGenerator(regeneratorRuntime.mark(function _callee37() { | ||
var mock; | ||
return regeneratorRuntime.wrap(function _callee37$(_context37) { | ||
while (1) { | ||
switch (_context37.prev = _context37.next) { | ||
case 0: | ||
mock = jest.fn(); | ||
_AccountsClient2.default.config({}, { sendVerificationEmail: mock }); | ||
_context37.prev = 2; | ||
_context37.next = 5; | ||
return _AccountsClient2.default.requestVerificationEmail('email'); | ||
case 5: | ||
throw new Error(); | ||
case 8: | ||
_context37.prev = 8; | ||
_context37.t0 = _context37['catch'](2); | ||
expect(_context37.t0.message).toEqual('Valid email must be provided'); | ||
expect(mock.mock.calls.length).toEqual(0); | ||
case 12: | ||
case 'end': | ||
return _context37.stop(); | ||
} | ||
} | ||
}, _callee37, undefined, [[2, 8]]); | ||
}))); | ||
}); | ||
}); |
@@ -597,3 +597,3 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
if (this.options.onSignedInHook) { | ||
if (this.options.onSignedInHook && (0, _lodash.isFunction)(this.options.onSignedInHook)) { | ||
this.options.onSignedInHook(); | ||
@@ -783,3 +783,3 @@ } | ||
case 0: | ||
if (email) { | ||
if (_common.validators.validateEmail(email)) { | ||
_context13.next = 2; | ||
@@ -789,3 +789,3 @@ break; | ||
throw new _common.AccountsError('Email must be provided'); | ||
throw new _common.AccountsError('Valid email must be provided'); | ||
@@ -828,3 +828,3 @@ case 2: | ||
case 0: | ||
if (email) { | ||
if (_common.validators.validateEmail(email)) { | ||
_context14.next = 2; | ||
@@ -834,3 +834,3 @@ break; | ||
throw new _common.AccountsError('Email must be provided'); | ||
throw new _common.AccountsError('Valid email must be provided'); | ||
@@ -837,0 +837,0 @@ case 2: |
{ | ||
"name": "@accounts/client", | ||
"version": "0.0.9-alpha.146b94d6", | ||
"version": "0.0.9-alpha.458b4e87", | ||
"description": "Fullstack authentication and accounts-management", | ||
@@ -72,3 +72,3 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"@accounts/common": "^0.0.9-alpha.146b94d6", | ||
"@accounts/common": "^0.0.9-alpha.458b4e87", | ||
"immutable": "^3.8.1", | ||
@@ -75,0 +75,0 @@ "jwt-decode": "^2.1.0", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
292353
5582