diff options
Diffstat (limited to 'test/shared')
-rw-r--r-- | test/shared/commands/parsers.test.js | 1 | ||||
-rw-r--r-- | test/shared/settings/validator.test.js | 1 | ||||
-rw-r--r-- | test/shared/settings/values.test.js | 1 | ||||
-rw-r--r-- | test/shared/store/index.test.js | 1 | ||||
-rw-r--r-- | test/shared/utils/keys.test.js | 1 | ||||
-rw-r--r-- | test/shared/utils/re.test.js | 1 | ||||
-rw-r--r-- | test/shared/versions/index.test.js | 55 | ||||
-rw-r--r-- | test/shared/versions/storage.test.js | 39 |
8 files changed, 94 insertions, 6 deletions
diff --git a/test/shared/commands/parsers.test.js b/test/shared/commands/parsers.test.js index 0a1960c..1910f07 100644 --- a/test/shared/commands/parsers.test.js +++ b/test/shared/commands/parsers.test.js @@ -1,4 +1,3 @@ -import { expect } from "chai"; import * as parsers from 'shared/commands/parsers'; describe("shared/commands/parsers", () => { diff --git a/test/shared/settings/validator.test.js b/test/shared/settings/validator.test.js index 61d976a..9bbfa3e 100644 --- a/test/shared/settings/validator.test.js +++ b/test/shared/settings/validator.test.js @@ -1,4 +1,3 @@ -import { expect } from "chai"; import { validate } from 'shared/settings/validator'; describe("setting validator", () => { diff --git a/test/shared/settings/values.test.js b/test/shared/settings/values.test.js index 62cfb5f..c72824d 100644 --- a/test/shared/settings/values.test.js +++ b/test/shared/settings/values.test.js @@ -1,4 +1,3 @@ -import { expect } from 'chai'; import * as values from 'shared/settings/values'; describe("settings values", () => { diff --git a/test/shared/store/index.test.js b/test/shared/store/index.test.js index 133033b..5b69b40 100644 --- a/test/shared/store/index.test.js +++ b/test/shared/store/index.test.js @@ -1,4 +1,3 @@ -import { expect } from "chai"; import { createStore } from 'shared/store'; describe("Store class", () => { diff --git a/test/shared/utils/keys.test.js b/test/shared/utils/keys.test.js index 5ca8b54..770b530 100644 --- a/test/shared/utils/keys.test.js +++ b/test/shared/utils/keys.test.js @@ -1,4 +1,3 @@ -import { expect } from 'chai'; import * as keys from 'shared/utils/keys'; describe("keys util", () => { diff --git a/test/shared/utils/re.test.js b/test/shared/utils/re.test.js index 9ed6521..d12ceb7 100644 --- a/test/shared/utils/re.test.js +++ b/test/shared/utils/re.test.js @@ -1,4 +1,3 @@ -import { expect } from 'chai'; import * as re from 'shared/utils/re'; describe("re util", () => { diff --git a/test/shared/versions/index.test.js b/test/shared/versions/index.test.js new file mode 100644 index 0000000..3bb307a --- /dev/null +++ b/test/shared/versions/index.test.js @@ -0,0 +1,55 @@ +import * as versions from 'shared/versions'; +import manifest from '../../../manifest.json'; + +describe("shared/versions/storage", () => { + describe('#checkUpdated', () => { + beforeEach(() => { + 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 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 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; + }); + }); + }); + + describe('#commit', () => { + beforeEach(() => { + 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); + }); + }); + }); +}); diff --git a/test/shared/versions/storage.test.js b/test/shared/versions/storage.test.js new file mode 100644 index 0000000..bcfa259 --- /dev/null +++ b/test/shared/versions/storage.test.js @@ -0,0 +1,39 @@ +import * as storage from 'shared/versions/storage'; + +describe("shared/versions/storage", () => { + describe('#load', () => { + beforeEach(() => { + 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('returns undefined if no versions in storage', () => { + return Promise.resolve().then(() => { + return storage.load(); + }).then((version) => { + 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'); + }); + }); + }); +}); |