mirror of
https://github.com/moparisthebest/mail
synced 2024-12-01 13:22:16 -05:00
cover corner case when emailAdress is undefined
This commit is contained in:
parent
33205ff4d9
commit
9ff7f4e10a
@ -362,7 +362,11 @@ define(function(require) {
|
|||||||
self.buildModules();
|
self.buildModules();
|
||||||
|
|
||||||
// init user's local database
|
// init user's local database
|
||||||
self._userStorage.init(options.emailAddress, function() {
|
self._userStorage.init(options.emailAddress, function(err) {
|
||||||
|
if (err) {
|
||||||
|
callback(err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Migrate the databases if necessary
|
// Migrate the databases if necessary
|
||||||
self._updateHandler.update(onUpdate);
|
self._updateHandler.update(onUpdate);
|
||||||
|
@ -243,11 +243,25 @@ define(function(require) {
|
|||||||
onConnectStub.restore();
|
onConnectStub.restore();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should fail due to error in storage initialization', function(done) {
|
||||||
|
devicestorageStub.init.withArgs(undefined).yields({});
|
||||||
|
|
||||||
|
controller.init({}, function(err, keypair) {
|
||||||
|
expect(err).to.exist;
|
||||||
|
expect(keypair).to.not.exist;
|
||||||
|
expect(devicestorageStub.init.calledOnce).to.be.true;
|
||||||
|
expect(updateHandlerStub.update.calledOnce).to.be.false;
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it('should fail due to error in update handler', function(done) {
|
it('should fail due to error in update handler', function(done) {
|
||||||
devicestorageStub.init.yields();
|
devicestorageStub.init.yields();
|
||||||
updateHandlerStub.update.yields({});
|
updateHandlerStub.update.yields({});
|
||||||
|
|
||||||
controller.init({}, function(err, keypair) {
|
controller.init({
|
||||||
|
emailAddress: emailAddress
|
||||||
|
}, function(err, keypair) {
|
||||||
expect(err).to.exist;
|
expect(err).to.exist;
|
||||||
expect(keypair).to.not.exist;
|
expect(keypair).to.not.exist;
|
||||||
expect(updateHandlerStub.update.calledOnce).to.be.true;
|
expect(updateHandlerStub.update.calledOnce).to.be.true;
|
||||||
@ -261,7 +275,9 @@ define(function(require) {
|
|||||||
updateHandlerStub.update.yields();
|
updateHandlerStub.update.yields();
|
||||||
emailDaoStub.init.yields({});
|
emailDaoStub.init.yields({});
|
||||||
|
|
||||||
controller.init({}, function(err, keypair) {
|
controller.init({
|
||||||
|
emailAddress: emailAddress
|
||||||
|
}, function(err, keypair) {
|
||||||
expect(err).to.exist;
|
expect(err).to.exist;
|
||||||
expect(keypair).to.not.exist;
|
expect(keypair).to.not.exist;
|
||||||
expect(updateHandlerStub.update.calledOnce).to.be.true;
|
expect(updateHandlerStub.update.calledOnce).to.be.true;
|
||||||
@ -278,7 +294,9 @@ define(function(require) {
|
|||||||
|
|
||||||
onConnectStub.yields({});
|
onConnectStub.yields({});
|
||||||
|
|
||||||
controller.init({}, function(err) {
|
controller.init({
|
||||||
|
emailAddress: emailAddress
|
||||||
|
}, function(err) {
|
||||||
expect(err).to.exist;
|
expect(err).to.exist;
|
||||||
expect(updateHandlerStub.update.calledOnce).to.be.true;
|
expect(updateHandlerStub.update.calledOnce).to.be.true;
|
||||||
expect(emailDaoStub.init.calledOnce).to.be.true;
|
expect(emailDaoStub.init.calledOnce).to.be.true;
|
||||||
|
Loading…
Reference in New Issue
Block a user