|
|
@ -7,49 +7,34 @@ describe("shared/versions/storage", () => { |
|
|
|
return browser.storage.local.remove('version'); |
|
|
|
return browser.storage.local.remove('version'); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('return true if no previous versions', () => { |
|
|
|
it('return true if no previous versions', async() => { |
|
|
|
return Promise.resolve().then(() => { |
|
|
|
let updated = await versions.checkUpdated(); |
|
|
|
return versions.checkUpdated(); |
|
|
|
|
|
|
|
}).then((updated) => { |
|
|
|
|
|
|
|
expect(updated).to.be.true; |
|
|
|
expect(updated).to.be.true; |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it('return true if updated', () => { |
|
|
|
it('return true if updated', async() => { |
|
|
|
return Promise.resolve().then(() => { |
|
|
|
await browser.storage.local.set({ version: '0.001' }); |
|
|
|
return browser.storage.local.set({ version: '0.001' }); |
|
|
|
let updated = await versions.checkUpdated(); |
|
|
|
}).then(() => { |
|
|
|
|
|
|
|
return versions.checkUpdated(); |
|
|
|
|
|
|
|
}).then((updated) => { |
|
|
|
|
|
|
|
expect(updated).to.be.true; |
|
|
|
expect(updated).to.be.true; |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it('return false if not updated', () => { |
|
|
|
it('return false if not updated', async() => { |
|
|
|
return Promise.resolve().then(() => { |
|
|
|
await browser.storage.local.set({ version: manifest.version }); |
|
|
|
return browser.storage.local.set({ version: manifest.version }); |
|
|
|
let updated = await versions.checkUpdated(); |
|
|
|
}).then(() => { |
|
|
|
|
|
|
|
return versions.checkUpdated(); |
|
|
|
|
|
|
|
}).then((updated) => { |
|
|
|
|
|
|
|
expect(updated).to.be.false; |
|
|
|
expect(updated).to.be.false; |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
describe('#commit', () => { |
|
|
|
describe('#commit', () => { |
|
|
|
beforeEach(() => { |
|
|
|
beforeEach(() => { |
|
|
|
return browser.storage.local.remove('version'); |
|
|
|
return browser.storage.local.remove('version'); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('saves current version from manifest.json', () => { |
|
|
|
it('saves current version from manifest.json', async() => { |
|
|
|
return Promise.resolve().then(() => { |
|
|
|
await versions.commit(); |
|
|
|
return versions.commit(); |
|
|
|
let { version } = await browser.storage.local.get('version'); |
|
|
|
}).then(() => { |
|
|
|
|
|
|
|
return browser.storage.local.get('version'); |
|
|
|
|
|
|
|
}).then(({version}) => { |
|
|
|
|
|
|
|
expect(version).to.be.a('string'); |
|
|
|
expect(version).to.be.a('string'); |
|
|
|
expect(version).to.equal(manifest.version); |
|
|
|
expect(version).to.equal(manifest.version); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|