diff options
author | Dan Finlay <dan@danfinlay.com> | 2018-01-25 03:36:42 +0800 |
---|---|---|
committer | Dan Finlay <dan@danfinlay.com> | 2018-01-25 03:36:42 +0800 |
commit | f09d72fa2aa88f0def76d228cb7d8eab29e3b092 (patch) | |
tree | 88e815f51f3ea698419eb97d92aae602a40cd314 | |
parent | dd80bd48babc1bfebf91ac2350491b06971b1fc1 (diff) | |
download | tangerine-wallet-browser-f09d72fa2aa88f0def76d228cb7d8eab29e3b092.tar tangerine-wallet-browser-f09d72fa2aa88f0def76d228cb7d8eab29e3b092.tar.gz tangerine-wallet-browser-f09d72fa2aa88f0def76d228cb7d8eab29e3b092.tar.bz2 tangerine-wallet-browser-f09d72fa2aa88f0def76d228cb7d8eab29e3b092.tar.lz tangerine-wallet-browser-f09d72fa2aa88f0def76d228cb7d8eab29e3b092.tar.xz tangerine-wallet-browser-f09d72fa2aa88f0def76d228cb7d8eab29e3b092.tar.zst tangerine-wallet-browser-f09d72fa2aa88f0def76d228cb7d8eab29e3b092.zip |
Remove extension-store since we aren't using it yet
-rw-r--r-- | app/scripts/lib/extension-store.js | 39 | ||||
-rw-r--r-- | test/unit/extension-store-test.js | 67 |
2 files changed, 0 insertions, 106 deletions
diff --git a/app/scripts/lib/extension-store.js b/app/scripts/lib/extension-store.js deleted file mode 100644 index 4a970321c..000000000 --- a/app/scripts/lib/extension-store.js +++ /dev/null @@ -1,39 +0,0 @@ -const extension = require('extensionizer') - -const KEYS_TO_SYNC = ['KeyringController', 'PreferencesController'] -const FIREFOX_SYNC_DISABLED_MESSAGE = 'Please set webextensions.storage.sync.enabled to true in about:config' - -const handleDisabledSyncAndResolve = (resolve, toResolve) => { - // Firefox 52 has sync available on extension.storage, but it is disabled by default - const lastError = extension.runtime.lastError - if (lastError && lastError.message.includes(FIREFOX_SYNC_DISABLED_MESSAGE)) { - resolve({}) - } else { - resolve(toResolve) - } -} - -module.exports = class ExtensionStore { - constructor() { - this.isSupported = !!(extension.storage && extension.storage.sync) - this.isEnabled = true // TODO: get value from user settings - } - async fetch() { - return new Promise((resolve) => { - extension.storage && extension.storage.sync.get(KEYS_TO_SYNC, (data) => { - handleDisabledSyncAndResolve(resolve, data) - }) - }) - } - async sync(state) { - const dataToSync = KEYS_TO_SYNC.reduce((result, key) => { - result[key] = state.data[key] - return result - }, {}) - return new Promise((resolve) => { - extension.storage && extension.storage.sync.set(dataToSync, () => { - handleDisabledSyncAndResolve(resolve) - }) - }) - } -} diff --git a/test/unit/extension-store-test.js b/test/unit/extension-store-test.js deleted file mode 100644 index e32f37d3c..000000000 --- a/test/unit/extension-store-test.js +++ /dev/null @@ -1,67 +0,0 @@ -const assert = require('assert') -const sinon = require('sinon') - -const KEYS_TO_SYNC = ['KeyringController', 'PreferencesController'] -const mockSyncGetResult = 123 -const syncGetStub = sinon.stub().callsFake((str, cb) => cb(mockSyncGetResult)) -const syncSetStub = sinon.stub().callsFake((str, cb) => cb()) - -window.storage = { - sync: { - get: syncGetStub, - set: syncSetStub, - }, -} -window.runtime = {} -const ExtensionStore = require('../../app/scripts/lib/extension-store') - -describe('Extension Store', function () { - let extensionStore - - beforeEach(function () { - extensionStore = new ExtensionStore() - }) - - describe('#fetch', function () { - it('should return a promise', function () { - const extensionStoreFetchResult = extensionStore.fetch() - assert.ok(Promise.resolve(extensionStoreFetchResult) === extensionStoreFetchResult) - }) - it('after promise resolution, should have loaded the proper data from the extension', function (done) { - extensionStore.fetch() - .then((result) => { - assert.deepEqual(syncGetStub.getCall(0).args[0], KEYS_TO_SYNC.slice(0)) - assert.equal(result, mockSyncGetResult) - done() - }) - }) - }) - - describe('#sync', function () { - it('should return a promise', function () { - const extensionStoreSyncResult = extensionStore.sync() - assert.ok(Promise.resolve(extensionStoreSyncResult) === extensionStoreSyncResult) - }) - it('after promise resolution, should have synced the proper data from the extension', function (done) { - const mockState = { - data: { - KeyringController: 5, - PreferencesController: 6, - someOtherData: 7 - }, - someOtherProp: { - evenMoreData: 8, - }, - } - const expectedDataToSync = { - KeyringController: 5, - PreferencesController: 6, - } - extensionStore.sync(mockState) - .then(() => { - assert.deepEqual(syncSetStub.getCall(0).args[0], expectedDataToSync) - done() - }) - }) - }) -}) |