From fe27d5ab159900b36222e6bb4fd605e30f0598ae Mon Sep 17 00:00:00 2001 From: Akiomi Kamakura Date: Fri, 23 Oct 2015 21:45:30 +0900 Subject: [PATCH] :lipstick: --- karma.conf.js | 8 +- src/chrome-storage-promise.js | 32 +-- test/chrome-storage-mock-error.js | 64 +++--- test/chrome-storage-mock.js | 44 ++-- test/spec-helper.js | 7 +- test/spec.js | 321 +++++++++++++++--------------- 6 files changed, 239 insertions(+), 237 deletions(-) diff --git a/karma.conf.js b/karma.conf.js index dac2523..0e0a47f 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -27,7 +27,7 @@ module.exports = function(config) { // preprocess matching files before serving them to the browser // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor preprocessors: { - 'test/*.js': ['webpack'] + 'test/*.js': ['webpack'] }, @@ -65,6 +65,12 @@ module.exports = function(config) { // webpack settings webpack: { + module: { + loaders: [{ + test: /test\/.+\.js$/, + loader: 'babel-loader', + }] + } } }); }; diff --git a/src/chrome-storage-promise.js b/src/chrome-storage-promise.js index e763835..3b5c09b 100644 --- a/src/chrome-storage-promise.js +++ b/src/chrome-storage-promise.js @@ -5,7 +5,7 @@ chrome.storage.promise = { // sync sync: { get: (keys) => { - var promise = new Promise((resolve, reject) => { + let promise = new Promise((resolve, reject) => { chrome.storage.sync.get(keys, (items) => { let err = chrome.runtime.lastError; if (err) { @@ -18,7 +18,7 @@ chrome.storage.promise = { return promise; }, set: (items) => { - var promise = new Promise((resolve, reject) => { + let promise = new Promise((resolve, reject) => { chrome.storage.sync.set(items, () => { let err = chrome.runtime.lastError; if (err) { @@ -31,7 +31,7 @@ chrome.storage.promise = { return promise; }, getBytesInUse: (keys) => { - var promise = new Promise((resolve, reject) => { + let promise = new Promise((resolve, reject) => { chrome.storage.sync.getBytesInUse(keys, (items) => { let err = chrome.runtime.lastError; if (err) { @@ -44,7 +44,7 @@ chrome.storage.promise = { return promise; }, remove: (keys) => { - var promise = new Promise((resolve, reject) => { + let promise = new Promise((resolve, reject) => { chrome.storage.sync.remove(keys, () => { let err = chrome.runtime.lastError; if (err) { @@ -57,7 +57,7 @@ chrome.storage.promise = { return promise; }, clear: () => { - var promise = new Promise((resolve, reject) => { + let promise = new Promise((resolve, reject) => { chrome.storage.sync.clear(() => { let err = chrome.runtime.lastError; if (err) { @@ -74,7 +74,7 @@ chrome.storage.promise = { // local local: { get: (keys) => { - var promise = new Promise((resolve, reject) => { + let promise = new Promise((resolve, reject) => { chrome.storage.local.get(keys, (items) => { let err = chrome.runtime.lastError; if (err) { @@ -87,7 +87,7 @@ chrome.storage.promise = { return promise; }, set: (items) => { - var promise = new Promise((resolve, reject) => { + let promise = new Promise((resolve, reject) => { chrome.storage.local.set(items, () => { let err = chrome.runtime.lastError; if (err) { @@ -100,7 +100,7 @@ chrome.storage.promise = { return promise; }, getBytesInUse: (keys) => { - var promise = new Promise((resolve, reject) => { + let promise = new Promise((resolve, reject) => { chrome.storage.local.getBytesInUse(keys, (items) => { let err = chrome.runtime.lastError; if (err) { @@ -113,7 +113,7 @@ chrome.storage.promise = { return promise; }, remove: (keys) => { - var promise = new Promise((resolve, reject) => { + let promise = new Promise((resolve, reject) => { chrome.storage.local.remove(keys, () => { let err = chrome.runtime.lastError; if (err) { @@ -126,7 +126,7 @@ chrome.storage.promise = { return promise; }, clear: () => { - var promise = new Promise((resolve, reject) => { + let promise = new Promise((resolve, reject) => { chrome.storage.local.clear(() => { let err = chrome.runtime.lastError; if (err) { @@ -143,7 +143,7 @@ chrome.storage.promise = { // managed managed: { get: (keys) => { - var promise = new Promise((resolve, reject) => { + let promise = new Promise((resolve, reject) => { chrome.storage.managed.get(keys, (items) => { let err = chrome.runtime.lastError; if (err) { @@ -156,7 +156,7 @@ chrome.storage.promise = { return promise; }, set: (items) => { - var promise = new Promise((resolve, reject) => { + let promise = new Promise((resolve, reject) => { chrome.storage.managed.set(items, () => { let err = chrome.runtime.lastError; if (err) { @@ -169,7 +169,7 @@ chrome.storage.promise = { return promise; }, getBytesInUse: (keys) => { - var promise = new Promise((resolve, reject) => { + let promise = new Promise((resolve, reject) => { chrome.storage.managed.getBytesInUse(keys, (items) => { let err = chrome.runtime.lastError; if (err) { @@ -182,7 +182,7 @@ chrome.storage.promise = { return promise; }, remove: (keys) => { - var promise = new Promise((resolve, reject) => { + let promise = new Promise((resolve, reject) => { chrome.storage.managed.remove(keys, () => { let err = chrome.runtime.lastError; if (err) { @@ -195,7 +195,7 @@ chrome.storage.promise = { return promise; }, clear: () => { - var promise = new Promise((resolve, reject) => { + let promise = new Promise((resolve, reject) => { chrome.storage.managed.clear(() => { let err = chrome.runtime.lastError; if (err) { @@ -212,7 +212,7 @@ chrome.storage.promise = { // onChanged onChanged: { addListener: () => { - var promise = new Promise((resolve, reject) => { + let promise = new Promise((resolve, reject) => { chrome.storage.onChanged.addListener((changes, areaName) => { let err = chrome.runtime.lastError; if (err) { diff --git a/test/chrome-storage-mock-error.js b/test/chrome-storage-mock-error.js index cf06351..2e71850 100644 --- a/test/chrome-storage-mock-error.js +++ b/test/chrome-storage-mock-error.js @@ -2,32 +2,32 @@ chrome.storage = { sync: { - get: function(keys, callback) { - setTimeout(function() { + get: (keys, callback) => { + setTimeout(() => { chrome.runtime.lastError = '42'; callback(); }, 100); }, - set: function(items, callback) { - setTimeout(function() { + set: (items, callback) => { + setTimeout(() => { chrome.runtime.lastError = '42'; callback(); }, 100); }, - getBytesInUse: function(keys, callback) { - setTimeout(function() { + getBytesInUse: (keys, callback) => { + setTimeout(() => { chrome.runtime.lastError = '42'; callback(); }, 100); }, - remove: function(items, callback) { - setTimeout(function() { + remove: (items, callback) => { + setTimeout(() => { chrome.runtime.lastError = '42'; callback(); }, 100); }, - clear: function(callback) { - setTimeout(function() { + clear: (callback) => { + setTimeout(() => { chrome.runtime.lastError = '42'; callback(); }, 100); @@ -35,32 +35,32 @@ chrome.storage = { }, local: { - get: function(keys, callback) { - setTimeout(function() { + get: (keys, callback) => { + setTimeout(() => { chrome.runtime.lastError = '42'; callback(); }, 100); }, - set: function(items, callback) { - setTimeout(function() { + set: (items, callback) => { + setTimeout(() => { chrome.runtime.lastError = '42'; callback(); }, 100); }, - getBytesInUse: function(keys, callback) { - setTimeout(function() { + getBytesInUse: (keys, callback) => { + setTimeout(() => { chrome.runtime.lastError = '42'; callback(); }, 100); }, - remove: function(items, callback) { - setTimeout(function() { + remove: (items, callback) => { + setTimeout(() => { chrome.runtime.lastError = '42'; callback(); }, 100); }, - clear: function(callback) { - setTimeout(function() { + clear: (callback) => { + setTimeout(() => { chrome.runtime.lastError = '42'; callback(); }, 100); @@ -68,32 +68,32 @@ chrome.storage = { }, managed: { - get: function(keys, callback) { - setTimeout(function() { + get: (keys, callback) => { + setTimeout(() => { chrome.runtime.lastError = '42'; callback(); }, 100); }, - set: function(items, callback) { - setTimeout(function() { + set: (items, callback) => { + setTimeout(() => { chrome.runtime.lastError = '42'; callback(); }, 100); }, - getBytesInUse: function(keys, callback) { - setTimeout(function() { + getBytesInUse: (keys, callback) => { + setTimeout(() => { chrome.runtime.lastError = '42'; callback(); }, 100); }, - remove: function(items, callback) { - setTimeout(function() { + remove: (items, callback) => { + setTimeout(() => { chrome.runtime.lastError = '42'; callback(); }, 100); }, - clear: function(callback) { - setTimeout(function() { + clear: (callback) => { + setTimeout(() => { chrome.runtime.lastError = '42'; callback(); }, 100); @@ -101,8 +101,8 @@ chrome.storage = { }, onChanged: { - addListener: function(callback) { - setTimeout(function() { + addListener: (callback) => { + setTimeout(() => { chrome.runtime.lastError = '42'; callback(); }, 100); diff --git a/test/chrome-storage-mock.js b/test/chrome-storage-mock.js index aa09d5d..51440e4 100644 --- a/test/chrome-storage-mock.js +++ b/test/chrome-storage-mock.js @@ -2,73 +2,73 @@ chrome.storage = { sync: { - get: function(keys, callback) { - setTimeout(function() { + get: (keys, callback) => { + setTimeout(() => { callback({foo: 'bar'}); }, 100); }, - set: function(items, callback) { + set: (items, callback) => { setTimeout(callback, 100); }, - getBytesInUse: function(keys, callback) { - setTimeout(function() { + getBytesInUse: (keys, callback) => { + setTimeout(() => { callback(42); }, 100); }, - remove: function(items, callback) { + remove: (items, callback) => { setTimeout(callback, 100); }, - clear: function(callback) { + clear: (callback) => { setTimeout(callback, 100); }, }, local: { - get: function(keys, callback) { - setTimeout(function() { + get: (keys, callback) => { + setTimeout(() => { callback({foo: 'bar'}); }, 100); }, - set: function(items, callback) { + set: (items, callback) => { setTimeout(callback, 100); }, - getBytesInUse: function(keys, callback) { - setTimeout(function() { + getBytesInUse: (keys, callback) => { + setTimeout(() => { callback(42); }, 100); }, - remove: function(items, callback) { + remove: (items, callback) => { setTimeout(callback, 100); }, - clear: function(callback) { + clear: (callback) => { setTimeout(callback, 100); }, }, managed: { - get: function(keys, callback) { - setTimeout(function() { + get: (keys, callback) => { + setTimeout(() => { callback({foo: 'bar'}); }, 100); }, - set: function(items, callback) { + set: (items, callback) => { setTimeout(callback, 100); }, - getBytesInUse: function(keys, callback) { - setTimeout(function() { + getBytesInUse: (keys, callback) => { + setTimeout(() => { callback(42); }, 100); }, - remove: function(items, callback) { + remove: (items, callback) => { setTimeout(callback, 100); }, - clear: function(callback) { + clear: (callback) => { setTimeout(callback, 100); }, }, onChanged: { - addListener: function(callback) { + addListener: (callback) => { setTimeout(callback, 100); }, }, diff --git a/test/spec-helper.js b/test/spec-helper.js index 261cdf8..6719131 100644 --- a/test/spec-helper.js +++ b/test/spec-helper.js @@ -1,11 +1,8 @@ 'use strict'; -function unrequireAll(req, mod) { - Object.keys(require.cache).forEach(function(key) { +export function unrequireAll() { + Object.keys(require.cache).forEach((key) => { delete require.cache[key]; }); } -module.exports = { - unrequireAll: unrequireAll, -}; diff --git a/test/spec.js b/test/spec.js index 27b4400..4b4aaac 100644 --- a/test/spec.js +++ b/test/spec.js @@ -1,91 +1,90 @@ 'use strict'; -var helper = require('./spec-helper') -var unrequireAll = helper.unrequireAll; +import {unrequireAll} from './spec-helper' -describe('chrome-storage-promise', function() { - context('when normal', function() { - before(function() { +describe('chrome-storage-promise', () => { + context('when normal', () => { + before(() => { require('./chrome-storage-mock'); require('../dist/chrome-storage-promise'); }); - after(function() { + after(() => { unrequireAll(); }); - describe('sync', function() { - describe('.get', function() { - it('is thenable', function(done) { - chrome.storage.promise.sync.get('foo').then(function(items) { + describe('sync', () => { + describe('.get', () => { + it('is thenable', (done) => { + chrome.storage.promise.sync.get('foo').then((items) => { expect(items).to.eql({foo: 'bar'}); done(); }); }); - it('calls chrome.storage.sync.get with "foo"', function() { - var callback = sinon.spy(); + it('calls chrome.storage.sync.get with "foo"', () => { + let callback = sinon.spy(); sinon.stub(chrome.storage.sync, 'get'); chrome.storage.promise.sync.get('foo').then(callback); assert(chrome.storage.sync.get.calledWithMatch('foo')); }); }); - describe('.set', function() { - it('is thenable', function(done) { - chrome.storage.promise.sync.set({foo: 'bar'}).then(function() { + describe('.set', () => { + it('is thenable', (done) => { + chrome.storage.promise.sync.set({foo: 'bar'}).then(() => { done(); }); }); - it('calls chrome.storage.sync.set with {foo: "bar"}', function() { - var callback = sinon.spy(); + it('calls chrome.storage.sync.set with {foo: "bar"}', () => { + let callback = sinon.spy(); sinon.stub(chrome.storage.sync, 'set'); chrome.storage.promise.sync.set({foo: 'bar'}).then(callback); assert(chrome.storage.sync.set.calledWithMatch({foo: 'bar'})); }); }); - describe('.getBytesInUse', function() { - it('is thenable', function(done) { - chrome.storage.promise.sync.getBytesInUse('foo').then(function(bytesInUse) { + describe('.getBytesInUse', () => { + it('is thenable', (done) => { + chrome.storage.promise.sync.getBytesInUse('foo').then((bytesInUse) => { expect(bytesInUse).to.equal(42); done(); }); }); - it('calls chrome.storage.sync.getBytesInUse with "foo"', function() { - var callback = sinon.spy(); + it('calls chrome.storage.sync.getBytesInUse with "foo"', () => { + let callback = sinon.spy(); sinon.stub(chrome.storage.sync, 'getBytesInUse'); chrome.storage.promise.sync.getBytesInUse('foo').then(callback); assert(chrome.storage.sync.getBytesInUse.calledWithMatch('foo')); }); }); - describe('.remove', function() { - it('is thenable', function(done) { - chrome.storage.promise.sync.remove('foo').then(function() { + describe('.remove', () => { + it('is thenable', (done) => { + chrome.storage.promise.sync.remove('foo').then(() => { done(); }); }); - it('calls chrome.storage.sync.remove with "foo"', function() { - var callback = sinon.spy(); + it('calls chrome.storage.sync.remove with "foo"', () => { + let callback = sinon.spy(); sinon.stub(chrome.storage.sync, 'remove'); chrome.storage.promise.sync.remove('foo').then(callback); assert(chrome.storage.sync.remove.calledWithMatch('foo')); }); }); - describe('.clear', function() { - it('is thenable', function(done) { - chrome.storage.promise.sync.clear().then(function() { + describe('.clear', () => { + it('is thenable', (done) => { + chrome.storage.promise.sync.clear().then(() => { done(); }); }); - it('calls chrome.storage.sync.clear', function() { - var callback = sinon.spy(); + it('calls chrome.storage.sync.clear', () => { + let callback = sinon.spy(); sinon.stub(chrome.storage.sync, 'clear'); chrome.storage.promise.sync.clear().then(callback); assert(chrome.storage.sync.clear.calledWithMatch()); @@ -93,78 +92,78 @@ describe('chrome-storage-promise', function() { }); }); - describe('local', function() { - describe('.get', function() { - it('is thenable', function(done) { - chrome.storage.promise.local.get('foo').then(function(items) { + describe('local', () => { + describe('.get', () => { + it('is thenable', (done) => { + chrome.storage.promise.local.get('foo').then((items) => { expect(items).to.eql({foo: 'bar'}); done(); }); }); - it('calls chrome.storage.local.get with "foo"', function() { - var callback = sinon.spy(); + it('calls chrome.storage.local.get with "foo"', () => { + let callback = sinon.spy(); sinon.stub(chrome.storage.local, 'get'); chrome.storage.promise.local.get('foo').then(callback); assert(chrome.storage.local.get.calledWithMatch('foo')); }); }); - describe('.set', function() { - it('is thenable', function(done) { - chrome.storage.promise.local.set({foo: 'bar'}).then(function() { + describe('.set', () => { + it('is thenable', (done) => { + chrome.storage.promise.local.set({foo: 'bar'}).then(() => { done(); }); }); - it('calls chrome.storage.local.set with {foo: "bar"}', function() { - var callback = sinon.spy(); + it('calls chrome.storage.local.set with {foo: "bar"}', () => { + let callback = sinon.spy(); sinon.stub(chrome.storage.local, 'set'); chrome.storage.promise.local.set({foo: 'bar'}).then(callback); assert(chrome.storage.local.set.calledWithMatch({foo: 'bar'})); }); }); - describe('.getBytesInUse', function() { - it('is thenable', function(done) { - chrome.storage.promise.local.getBytesInUse('foo').then(function(bytesInUse) { + describe('.getBytesInUse', () => { + it('is thenable', (done) => { + chrome.storage.promise.local.getBytesInUse('foo').then((bytesInUse) => { expect(bytesInUse).to.equal(42); done(); }); }); - it('calls chrome.storage.local.getBytesInUse with "foo"', function() { - var callback = sinon.spy(); + it('calls chrome.storage.local.getBytesInUse with "foo"', () => { + let callback = sinon.spy(); sinon.stub(chrome.storage.local, 'getBytesInUse'); chrome.storage.promise.local.getBytesInUse('foo').then(callback); assert(chrome.storage.local.getBytesInUse.calledWithMatch('foo')); }); }); - describe('.remove', function() { - it('is thenable', function(done) { - chrome.storage.promise.local.remove('foo').then(function() { + describe('.remove', () => { + it('is thenable', (done) => { + chrome.storage.promise.local.remove('foo').then(() => { done(); }); }); - it('calls chrome.storage.local.remove with "foo"', function() { - var callback = sinon.spy(); + it('calls chrome.storage.local.remove with "foo"', () => { + let callback = sinon.spy(); sinon.stub(chrome.storage.local, 'remove'); chrome.storage.promise.local.remove('foo').then(callback); assert(chrome.storage.local.remove.calledWithMatch('foo')); }); }); - describe('.clear', function() { - it('is thenable', function(done) { - chrome.storage.promise.local.clear().then(function() { + describe('.clear', () => { + it('is thenable', (done) => { + chrome.storage.promise.local.clear().then(() => { done(); }); }); - it('calls chrome.storage.local.clear', function() { - var callback = sinon.spy(); + it('calls chrome.storage.local.clear', () => { + let callback = sinon.spy(); sinon.stub(chrome.storage.local, 'clear'); chrome.storage.promise.local.clear().then(callback); assert(chrome.storage.local.clear.calledWithMatch()); @@ -172,78 +171,78 @@ describe('chrome-storage-promise', function() { }); }); - describe('managed', function() { - describe('.get', function() { - it('is thenable', function(done) { - chrome.storage.promise.managed.get('foo').then(function(items) { + describe('managed', () => { + describe('.get', () => { + it('is thenable', (done) => { + chrome.storage.promise.managed.get('foo').then((items) => { expect(items).to.eql({foo: 'bar'}); done(); }); }); - it('calls chrome.storage.managed.get with "foo"', function() { - var callback = sinon.spy(); + it('calls chrome.storage.managed.get with "foo"', () => { + let callback = sinon.spy(); sinon.stub(chrome.storage.managed, 'get'); chrome.storage.promise.managed.get('foo').then(callback); assert(chrome.storage.managed.get.calledWithMatch('foo')); }); }); - describe('.set', function() { - it('is thenable', function(done) { - chrome.storage.promise.managed.set({foo: 'bar'}).then(function() { + describe('.set', () => { + it('is thenable', (done) => { + chrome.storage.promise.managed.set({foo: 'bar'}).then(() => { done(); }); }); - it('calls chrome.storage.managed.set with {foo: "bar"}', function() { - var callback = sinon.spy(); + it('calls chrome.storage.managed.set with {foo: "bar"}', () => { + let callback = sinon.spy(); sinon.stub(chrome.storage.managed, 'set'); chrome.storage.promise.managed.set({foo: 'bar'}).then(callback); assert(chrome.storage.managed.set.calledWithMatch({foo: 'bar'})); }); }); - describe('.getBytesInUse', function() { - it('is thenable', function(done) { - chrome.storage.promise.managed.getBytesInUse('foo').then(function(bytesInUse) { + describe('.getBytesInUse', () => { + it('is thenable', (done) => { + chrome.storage.promise.managed.getBytesInUse('foo').then((bytesInUse) => { expect(bytesInUse).to.equal(42); done(); }); }); - it('calls chrome.storage.managed.getBytesInUse with "foo"', function() { - var callback = sinon.spy(); + it('calls chrome.storage.managed.getBytesInUse with "foo"', () => { + let callback = sinon.spy(); sinon.stub(chrome.storage.managed, 'getBytesInUse'); chrome.storage.promise.managed.getBytesInUse('foo').then(callback); assert(chrome.storage.managed.getBytesInUse.calledWithMatch('foo')); }); }); - describe('.remove', function() { - it('is thenable', function(done) { - chrome.storage.promise.managed.remove('foo').then(function() { + describe('.remove', () => { + it('is thenable', (done) => { + chrome.storage.promise.managed.remove('foo').then(() => { done(); }); }); - it('calls chrome.storage.managed.remove with "foo"', function() { - var callback = sinon.spy(); + it('calls chrome.storage.managed.remove with "foo"', () => { + let callback = sinon.spy(); sinon.stub(chrome.storage.managed, 'remove'); chrome.storage.promise.managed.remove('foo').then(callback); assert(chrome.storage.managed.remove.calledWithMatch('foo')); }); }); - describe('.clear', function() { - it('is thenable', function(done) { - chrome.storage.promise.managed.clear().then(function() { + describe('.clear', () => { + it('is thenable', (done) => { + chrome.storage.promise.managed.clear().then(() => { done(); }); }); - it('calls chrome.storage.managed.clear', function() { - var callback = sinon.spy(); + it('calls chrome.storage.managed.clear', () => { + let callback = sinon.spy(); sinon.stub(chrome.storage.managed, 'clear'); chrome.storage.promise.managed.clear().then(callback); assert(chrome.storage.managed.clear.calledWithMatch()); @@ -251,16 +250,16 @@ describe('chrome-storage-promise', function() { }); }); - describe('onChanged', function() { - describe('.addListener', function() { - it('is thenable', function(done) { - chrome.storage.promise.onChanged.addListener().then(function() { + describe('onChanged', () => { + describe('.addListener', () => { + it('is thenable', (done) => { + chrome.storage.promise.onChanged.addListener().then(() => { done(); }); }); - it('calls chrome.storage.onChanged.addListener', function() { - var callback = sinon.spy(); + it('calls chrome.storage.onChanged.addListener', () => { + let callback = sinon.spy(); sinon.stub(chrome.storage.onChanged, 'addListener'); chrome.storage.promise.onChanged.addListener().then(callback); assert(chrome.storage.onChanged.addListener.calledWithMatch()); @@ -269,66 +268,66 @@ describe('chrome-storage-promise', function() { }); }); - context('when error', function() { - before(function() { + context('when error', () => { + before(() => { require('./chrome-storage-mock-error'); require('../dist/chrome-storage-promise'); }); - after(function() { + after(() => { unrequireAll(); }); - describe('sync', function() { - describe('.get', function() { - it('returns error message', function(done) { - chrome.storage.promise.sync.get('foo').then(function() { + describe('sync', () => { + describe('.get', () => { + it('returns error message', (done) => { + chrome.storage.promise.sync.get('foo').then(() => { done('test failed'); - }, function(error) { + }, (error) => { expect(error).to.equal('42'); done(); }); }); }); - describe('.set', function() { - it('returns error message', function(done) { - chrome.storage.promise.sync.set({foo: 'bar'}).then(function() { + describe('.set', () => { + it('returns error message', (done) => { + chrome.storage.promise.sync.set({foo: 'bar'}).then(() => { done('test failed'); - }, function(error) { + }, (error) => { expect(error).to.equal('42'); done(); }); }); }); - describe('.getBytesInUse', function() { - it('returns error message', function(done) { - chrome.storage.promise.sync.getBytesInUse('foo').then(function() { + describe('.getBytesInUse', () => { + it('returns error message', (done) => { + chrome.storage.promise.sync.getBytesInUse('foo').then(() => { done('test failed'); - }, function(error) { + }, (error) => { expect(error).to.equal('42'); done(); }); }); }); - describe('.remove', function() { - it('returns error message', function(done) { - chrome.storage.promise.sync.remove('foo').then(function() { + describe('.remove', () => { + it('returns error message', (done) => { + chrome.storage.promise.sync.remove('foo').then(() => { done('test failed'); - }, function(error) { + }, (error) => { expect(error).to.equal('42'); done(); }); }); }); - describe('.clear', function() { - it('returns error message', function(done) { - chrome.storage.promise.sync.clear().then(function() { + describe('.clear', () => { + it('returns error message', (done) => { + chrome.storage.promise.sync.clear().then(() => { done('test failed'); - }, function(error) { + }, (error) => { expect(error).to.equal('42'); done(); }); @@ -336,56 +335,56 @@ describe('chrome-storage-promise', function() { }); }); - describe('local', function() { - describe('.get', function() { - it('returns error message', function(done) { - chrome.storage.promise.local.get('foo').then(function() { + describe('local', () => { + describe('.get', () => { + it('returns error message', (done) => { + chrome.storage.promise.local.get('foo').then(() => { done('test failed'); - }, function(error) { + }, (error) => { expect(error).to.equal('42'); done(); }); }); }); - describe('.set', function() { - it('returns error message', function(done) { - chrome.storage.promise.local.set({foo: 'bar'}).then(function() { + describe('.set', () => { + it('returns error message', (done) => { + chrome.storage.promise.local.set({foo: 'bar'}).then(() => { done('test failed'); - }, function(error) { + }, (error) => { expect(error).to.equal('42'); done(); }); }); }); - describe('.getBytesInUse', function() { - it('returns error message', function(done) { - chrome.storage.promise.local.getBytesInUse('foo').then(function() { + describe('.getBytesInUse', () => { + it('returns error message', (done) => { + chrome.storage.promise.local.getBytesInUse('foo').then(() => { done('test failed'); - }, function(error) { + }, (error) => { expect(error).to.equal('42'); done(); }); }); }); - describe('.remove', function() { - it('returns error message', function(done) { - chrome.storage.promise.local.remove('foo').then(function() { + describe('.remove', () => { + it('returns error message', (done) => { + chrome.storage.promise.local.remove('foo').then(() => { done('test failed'); - }, function(error) { + }, (error) => { expect(error).to.equal('42'); done(); }); }); }); - describe('.clear', function() { - it('returns error message', function(done) { - chrome.storage.promise.local.clear().then(function() { + describe('.clear', () => { + it('returns error message', (done) => { + chrome.storage.promise.local.clear().then(() => { done('test failed'); - }, function(error) { + }, (error) => { expect(error).to.equal('42'); done(); }); @@ -393,56 +392,56 @@ describe('chrome-storage-promise', function() { }); }); - describe('managed', function() { - describe('.get', function() { - it('returns error message', function(done) { - chrome.storage.promise.managed.get('foo').then(function() { + describe('managed', () => { + describe('.get', () => { + it('returns error message', (done) => { + chrome.storage.promise.managed.get('foo').then(() => { done('test failed'); - }, function(error) { + }, (error) => { expect(error).to.equal('42'); done(); }); }); }); - describe('.set', function() { - it('returns error message', function(done) { - chrome.storage.promise.managed.set({foo: 'bar'}).then(function() { + describe('.set', () => { + it('returns error message', (done) => { + chrome.storage.promise.managed.set({foo: 'bar'}).then(() => { done('test failed'); - }, function(error) { + }, (error) => { expect(error).to.equal('42'); done(); }); }); }); - describe('.getBytesInUse', function() { - it('returns error message', function(done) { - chrome.storage.promise.managed.getBytesInUse('foo').then(function() { + describe('.getBytesInUse', () => { + it('returns error message', (done) => { + chrome.storage.promise.managed.getBytesInUse('foo').then(() => { done('test failed'); - }, function(error) { + }, (error) => { expect(error).to.equal('42'); done(); }); }); }); - describe('.remove', function() { - it('returns error message', function(done) { - chrome.storage.promise.managed.remove('foo').then(function() { + describe('.remove', () => { + it('returns error message', (done) => { + chrome.storage.promise.managed.remove('foo').then(() => { done('test failed'); - }, function(error) { + }, (error) => { expect(error).to.equal('42'); done(); }); }); }); - describe('.clear', function() { - it('returns error message', function(done) { - chrome.storage.promise.managed.clear().then(function() { + describe('.clear', () => { + it('returns error message', (done) => { + chrome.storage.promise.managed.clear().then(() => { done('test failed'); - }, function(error) { + }, (error) => { expect(error).to.equal('42'); done(); }); @@ -450,12 +449,12 @@ describe('chrome-storage-promise', function() { }); }); - describe('onChanged', function() { - describe('.addListener', function() { - it('returns error message', function(done) { - chrome.storage.promise.onChanged.addListener().then(function() { + describe('onChanged', () => { + describe('.addListener', () => { + it('returns error message', (done) => { + chrome.storage.promise.onChanged.addListener().then(() => { done('test failed'); - }, function(error) { + }, (error) => { expect(error).to.equal('42'); done(); });