diff options
Diffstat (limited to 'test/background')
-rw-r--r-- | test/background/repositories/version.js (renamed from test/background/shared/versions/storage.test.js) | 18 | ||||
-rw-r--r-- | test/background/shared/versions/index.test.js | 40 |
2 files changed, 12 insertions, 46 deletions
diff --git a/test/background/shared/versions/storage.test.js b/test/background/repositories/version.js index f452516..8510ae6 100644 --- a/test/background/shared/versions/storage.test.js +++ b/test/background/repositories/version.js @@ -1,14 +1,20 @@ -import * as storage from 'background/shared/versions/storage'; +import VersionRepository from 'background/repositories/version'; -describe("shared/versions/storage", () => { - describe('#load', () => { +describe("background/repositories/version", () => { + let versionRepository; + + beforeEach(() => { + versionRepository = new VersionRepository; + }); + + describe('#get', () => { beforeEach(() => { return browser.storage.local.remove('version'); }); it('loads saved version', async() => { await browser.storage.local.set({ version: '1.2.3' }); - let version = await storage.load(); + let version = await this.versionRepository.get(); expect(version).to.equal('1.2.3'); }); @@ -18,9 +24,9 @@ describe("shared/versions/storage", () => { }); }); - describe('#save', () => { + describe('#update', () => { it('saves version string', async() => { - await storage.save('2.3.4'); + await versionRepository.update('2.3.4'); let { version } = await browser.storage.local.get('version'); expect(version).to.equal('2.3.4'); }); diff --git a/test/background/shared/versions/index.test.js b/test/background/shared/versions/index.test.js deleted file mode 100644 index d65dd9a..0000000 --- a/test/background/shared/versions/index.test.js +++ /dev/null @@ -1,40 +0,0 @@ -import * as versions from 'background/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', async() => { - let updated = await versions.checkUpdated(); - 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', async() => { - await browser.storage.local.set({ version: manifest.version }); - let updated = await versions.checkUpdated(); - expect(updated).to.be.false; - }); - }); - - describe('#commit', () => { - beforeEach(() => { - return browser.storage.local.remove('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); - }); - }); -}); |