aboutsummaryrefslogtreecommitdiff
path: root/test/shared/versions/storage.test.js
blob: bcfa2594e5f7ef9d8cce905e1328bad89e8bef99 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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');
      });
    });
  });
});