aboutsummaryrefslogtreecommitdiff
path: root/test/shared/versions/storage.test.js
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2018-05-05 17:35:24 +0900
committerShin'ya Ueoka <ueokande@i-beam.org>2018-05-05 17:43:42 +0900
commit88e216d49bbbf4312dde678a890733a6e4c4cde8 (patch)
treedeef2da5ea84ceaf1b9ae2714a43aa73c0a5acbb /test/shared/versions/storage.test.js
parenta63311bd34afb5566c9f58bac69a27fa865e7b10 (diff)
Notify when updated
Diffstat (limited to 'test/shared/versions/storage.test.js')
-rw-r--r--test/shared/versions/storage.test.js39
1 files changed, 39 insertions, 0 deletions
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');
+ });
+ });
+ });
+});