aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2018-06-17 17:50:42 +0900
committerShin'ya Ueoka <ueokande@i-beam.org>2018-06-17 17:50:42 +0900
commit88238005ab64f957d9def8c18473d8210b280de9 (patch)
tree049966769fff054a817626763faf016c661b7330 /test
parent70ed31f35e1323706b26406ac6471679007051d9 (diff)
Rewrite tests with async/await
Diffstat (limited to 'test')
-rw-r--r--test/shared/versions/index.test.js47
-rw-r--r--test/shared/versions/storage.test.js33
2 files changed, 27 insertions, 53 deletions
diff --git a/test/shared/versions/index.test.js b/test/shared/versions/index.test.js
index 3bb307a..d90f04c 100644
--- a/test/shared/versions/index.test.js
+++ b/test/shared/versions/index.test.js
@@ -7,32 +7,21 @@ describe("shared/versions/storage", () => {
return browser.storage.local.remove('version');
});
- it('return true if no previous versions', () => {
- return Promise.resolve().then(() => {
- return versions.checkUpdated();
- }).then((updated) => {
- expect(updated).to.be.true;
- });
+ it('return true if no previous versions', async() => {
+ let updated = await versions.checkUpdated();
+ expect(updated).to.be.true;
});
- it('return true if updated', () => {
- return Promise.resolve().then(() => {
- return browser.storage.local.set({ version: '0.001' });
- }).then(() => {
- return versions.checkUpdated();
- }).then((updated) => {
- expect(updated).to.be.true;
- });
+ it('return true if updated', async() => {
+ await browser.storage.local.set({ version: '0.001' });
+ let updated = await versions.checkUpdated();
+ expect(updated).to.be.true;
});
- it('return false if not updated', () => {
- return Promise.resolve().then(() => {
- return browser.storage.local.set({ version: manifest.version });
- }).then(() => {
- return versions.checkUpdated();
- }).then((updated) => {
- expect(updated).to.be.false;
- });
+ it('return false if not updated', async() => {
+ await browser.storage.local.set({ version: manifest.version });
+ let updated = await versions.checkUpdated();
+ expect(updated).to.be.false;
});
});
@@ -41,15 +30,11 @@ describe("shared/versions/storage", () => {
return browser.storage.local.remove('version');
});
- it('saves current version from manifest.json', () => {
- return Promise.resolve().then(() => {
- return versions.commit();
- }).then(() => {
- return browser.storage.local.get('version');
- }).then(({version}) => {
- expect(version).to.be.a('string');
- expect(version).to.equal(manifest.version);
- });
+ it('saves current version from manifest.json', async() => {
+ await versions.commit();
+ let { version } = await browser.storage.local.get('version');
+ expect(version).to.be.a('string');
+ expect(version).to.equal(manifest.version);
});
});
});
diff --git a/test/shared/versions/storage.test.js b/test/shared/versions/storage.test.js
index bcfa259..f541abf 100644
--- a/test/shared/versions/storage.test.js
+++ b/test/shared/versions/storage.test.js
@@ -6,34 +6,23 @@ describe("shared/versions/storage", () => {
return browser.storage.local.remove('version');
});
- it('loads saved version', () => {
- return Promise.resolve().then(() => {
- return browser.storage.local.set({ version: '1.2.3' });
- }).then(() => {
- return storage.load();
- }).then((version) => {
- expect(version).to.equal('1.2.3');
- });
+ it('loads saved version', async() => {
+ await browser.storage.local.set({ version: '1.2.3' });
+ let version = await storage.load();
+ expect(version).to.equal('1.2.3');
});
- it('returns undefined if no versions in storage', () => {
- return Promise.resolve().then(() => {
- return storage.load();
- }).then((version) => {
- expect(version).to.be.a('undefined');
- });
+ it('returns undefined if no versions in storage', async() => {
+ let version = await storage.load();
+ expect(version).to.be.a('undefined');
});
});
describe('#save', () => {
- it('saves version string', () => {
- return Promise.resolve().then(() => {
- return storage.save('2.3.4');
- }).then(() => {
- return browser.storage.local.get('version');
- }).then(({version}) => {
- expect(version).to.equal('2.3.4');
- });
+ it('saves version string', async() => {
+ await storage.save('2.3.4');
+ let { version } = await browser.storage.local.get('version');
+ expect(version).to.equal('2.3.4');
});
});
});