diff options
author | Shin'ya Ueoka <ueokande@i-beam.org> | 2018-05-05 18:01:46 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-05 18:01:46 +0900 |
commit | e68c0b0f8002207c32c2e8d387b17f5f4f2ccae9 (patch) | |
tree | 5b9aadd2404240012b7c595657fef57d1c3c30d6 /test/shared/versions/index.test.js | |
parent | c9c18966e6f59e8bc16dfd65394041491cba539e (diff) | |
parent | 8b72102ba5b9b094d774b5bb0bf6c685e00682b5 (diff) |
Merge pull request #385 from ueokande/update_notification
Update notification
Diffstat (limited to 'test/shared/versions/index.test.js')
-rw-r--r-- | test/shared/versions/index.test.js | 55 |
1 files changed, 55 insertions, 0 deletions
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); + }); + }); + }); +}); |