From e9ceb07e01da0d0a0136fd28b413a8e4fac5ea2b Mon Sep 17 00:00:00 2001 From: Gregor Date: Mon, 19 Feb 2018 10:36:49 -0800 Subject: [PATCH] style: standard --- lib/init.js | 86 ++++++++++++++++++++++----------------------- tests/specs/init.js | 20 +++++------ 2 files changed, 53 insertions(+), 53 deletions(-) diff --git a/lib/init.js b/lib/init.js index fc62817..f02ac35 100644 --- a/lib/init.js +++ b/lib/init.js @@ -27,30 +27,30 @@ function init (hoodie) { return hoodie.store.reset() - .then(function () { - function migrate (doc) { - doc.createdBy = account.id - delete doc._rev - return doc - } - return hoodie.store.add(options.beforeSignin.docs.map(migrate)) - }) - - .then(function () { - return hoodie.store.connect() - }) + .then(function () { + function migrate (doc) { + doc.createdBy = account.id + delete doc._rev + return doc + } + return hoodie.store.add(options.beforeSignin.docs.map(migrate)) + }) + + .then(function () { + return hoodie.store.connect() + }) }) hoodie.account.hook.before('signout', function () { return hoodie.store.push() - .catch(function (error) { - if (error.status !== 401) { - throw error - } + .catch(function (error) { + if (error.status !== 401) { + throw error + } - error.message = 'Local changes could not be synced, sign in first' - throw error - }) + error.message = 'Local changes could not be synced, sign in first' + throw error + }) }) hoodie.account.hook.after('signout', function (options) { return hoodie.store.reset() @@ -63,40 +63,40 @@ function init (hoodie) { hoodie.connectionStatus.on('disconnect', function () { hoodie.account.get('session') - .then(function (session) { - if (session) { - hoodie.store.disconnect() - } - }) + .then(function (session) { + if (session) { + hoodie.store.disconnect() + } + }) }) hoodie.connectionStatus.on('reconnect', function () { hoodie.account.get('session') - .then(function (session) { - if (session) { - hoodie.store.connect() - } - }) + .then(function (session) { + if (session) { + hoodie.store.connect() + } + }) }) hoodie.account.get('session') - .then(function (session) { + .then(function (session) { // signed out - if (!session) { - return - } + if (!session) { + return + } - // signed in, but session was invalid - if (session.invalid) { - return - } + // signed in, but session was invalid + if (session.invalid) { + return + } - // hoodie.connectionStatus.ok is false if there is a connection issue - if (hoodie.connectionStatus.ok === false) { - return - } + // hoodie.connectionStatus.ok is false if there is a connection issue + if (hoodie.connectionStatus.ok === false) { + return + } - hoodie.store.connect() - }) + hoodie.store.connect() + }) } diff --git a/tests/specs/init.js b/tests/specs/init.js index 3fe5427..66a7b44 100644 --- a/tests/specs/init.js +++ b/tests/specs/init.js @@ -56,13 +56,13 @@ test('"reset" triggered on "signin"', function (t) { var options = {} beforeSignInCall.args[1](options) - .then(function () { - options.beforeSignin.accountId = 'accountid2' - return afterSignInCall.args[1]({}, options) - }) - .then(function () { - t.deepEqual(signInTestOrder, ['reset', 'connect'], 'store.connect was called after store.reset') - }) + .then(function () { + options.beforeSignin.accountId = 'accountid2' + return afterSignInCall.args[1]({}, options) + }) + .then(function () { + t.deepEqual(signInTestOrder, ['reset', 'connect'], 'store.connect was called after store.reset') + }) }) test('"reset" triggered after signout', function (t) { @@ -515,9 +515,9 @@ test('hoodie.store.connect() is called', function (t) { var options = {} beforeSignInCall.args[1](options) - .then(function () { - return afterSignInCall.args[1](hoodie.account, options) - }) + .then(function () { + return afterSignInCall.args[1](hoodie.account, options) + }) }) test('hoodie.account.hook.before returns an error', function (t) { t.plan(2)