aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/background/actions/find.test.js1
-rw-r--r--test/background/reducers/find.test.js1
-rw-r--r--test/background/reducers/setting.test.js1
-rw-r--r--test/console/actions/console.test.js1
-rw-r--r--test/console/reducers/console.test.js1
-rw-r--r--test/content/actions/addon.test.js1
-rw-r--r--test/content/actions/follow-controller.test.js1
-rw-r--r--test/content/actions/input.test.js1
-rw-r--r--test/content/actions/setting.test.js1
-rw-r--r--test/content/components/common/follow.test.js1
-rw-r--r--test/content/components/common/hint.test.js1
-rw-r--r--test/content/components/common/input.test.js1
-rw-r--r--test/content/hint-key-producer.test.js1
-rw-r--r--test/content/navigates.test.js1
-rw-r--r--test/content/reducers/addon.test.js1
-rw-r--r--test/content/reducers/find.test.js1
-rw-r--r--test/content/reducers/follow-controller.test.js1
-rw-r--r--test/content/reducers/input.test.js1
-rw-r--r--test/content/reducers/setting.test.js1
-rw-r--r--test/main.js6
-rw-r--r--test/settings/components/form/blacklist-form.test.jsx1
-rw-r--r--test/settings/components/form/keymaps-form.test.jsx1
-rw-r--r--test/settings/components/form/properties-form.test.jsx1
-rw-r--r--test/settings/components/form/search-engine-form.test.jsx1
-rw-r--r--test/settings/components/ui/input.test.jsx1
-rw-r--r--test/settings/reducers/setting.test.js1
-rw-r--r--test/shared/commands/parsers.test.js1
-rw-r--r--test/shared/settings/validator.test.js1
-rw-r--r--test/shared/settings/values.test.js1
-rw-r--r--test/shared/store/index.test.js1
-rw-r--r--test/shared/utils/keys.test.js1
-rw-r--r--test/shared/utils/re.test.js1
-rw-r--r--test/shared/versions/index.test.js55
-rw-r--r--test/shared/versions/storage.test.js39
34 files changed, 100 insertions, 31 deletions
diff --git a/test/background/actions/find.test.js b/test/background/actions/find.test.js
index 467604f..6b0b846 100644
--- a/test/background/actions/find.test.js
+++ b/test/background/actions/find.test.js
@@ -1,4 +1,3 @@
-import { expect } from "chai";
import actions from 'background/actions';
import * as findActions from 'background/actions/find';
diff --git a/test/background/reducers/find.test.js b/test/background/reducers/find.test.js
index 707d73a..c366223 100644
--- a/test/background/reducers/find.test.js
+++ b/test/background/reducers/find.test.js
@@ -1,4 +1,3 @@
-import { expect } from "chai";
import actions from 'background/actions';
import findReducer from 'background/reducers/find';
diff --git a/test/background/reducers/setting.test.js b/test/background/reducers/setting.test.js
index 8df5abe..24d02ea 100644
--- a/test/background/reducers/setting.test.js
+++ b/test/background/reducers/setting.test.js
@@ -1,4 +1,3 @@
-import { expect } from "chai";
import actions from 'background/actions';
import settingReducer from 'background/reducers/setting';
diff --git a/test/console/actions/console.test.js b/test/console/actions/console.test.js
index 1774431..77855cd 100644
--- a/test/console/actions/console.test.js
+++ b/test/console/actions/console.test.js
@@ -1,4 +1,3 @@
-import { expect } from "chai";
import actions from 'console/actions';
import * as consoleActions from 'console/actions/console';
diff --git a/test/console/reducers/console.test.js b/test/console/reducers/console.test.js
index d196011..db40088 100644
--- a/test/console/reducers/console.test.js
+++ b/test/console/reducers/console.test.js
@@ -1,4 +1,3 @@
-import { expect } from "chai";
import actions from 'console/actions';
import reducer from 'console/reducers';
diff --git a/test/content/actions/addon.test.js b/test/content/actions/addon.test.js
index 7f244dc..5f96372 100644
--- a/test/content/actions/addon.test.js
+++ b/test/content/actions/addon.test.js
@@ -1,4 +1,3 @@
-import { expect } from "chai";
import actions from 'content/actions';
import * as addonActions from 'content/actions/addon';
diff --git a/test/content/actions/follow-controller.test.js b/test/content/actions/follow-controller.test.js
index 298abf2..718a90a 100644
--- a/test/content/actions/follow-controller.test.js
+++ b/test/content/actions/follow-controller.test.js
@@ -1,4 +1,3 @@
-import { expect } from "chai";
import actions from 'content/actions';
import * as followControllerActions from 'content/actions/follow-controller';
diff --git a/test/content/actions/input.test.js b/test/content/actions/input.test.js
index 30705d2..fe9db5f 100644
--- a/test/content/actions/input.test.js
+++ b/test/content/actions/input.test.js
@@ -1,4 +1,3 @@
-import { expect } from "chai";
import actions from 'content/actions';
import * as inputActions from 'content/actions/input';
diff --git a/test/content/actions/setting.test.js b/test/content/actions/setting.test.js
index 3112b2d..10f6807 100644
--- a/test/content/actions/setting.test.js
+++ b/test/content/actions/setting.test.js
@@ -1,4 +1,3 @@
-import { expect } from "chai";
import actions from 'content/actions';
import * as settingActions from 'content/actions/setting';
diff --git a/test/content/components/common/follow.test.js b/test/content/components/common/follow.test.js
index 1fc935e..4fc11d0 100644
--- a/test/content/components/common/follow.test.js
+++ b/test/content/components/common/follow.test.js
@@ -1,4 +1,3 @@
-import { expect } from "chai";
import FollowComponent from 'content/components/common/follow';
describe('FollowComponent', () => {
diff --git a/test/content/components/common/hint.test.js b/test/content/components/common/hint.test.js
index ced2fde..42d571f 100644
--- a/test/content/components/common/hint.test.js
+++ b/test/content/components/common/hint.test.js
@@ -1,4 +1,3 @@
-import { expect } from "chai";
import Hint from 'content/components/common/hint';
describe('Hint class', () => {
diff --git a/test/content/components/common/input.test.js b/test/content/components/common/input.test.js
index a346cf6..2ba5507 100644
--- a/test/content/components/common/input.test.js
+++ b/test/content/components/common/input.test.js
@@ -1,5 +1,4 @@
import InputComponent from 'content/components/common/input';
-import { expect } from "chai";
describe('InputComponent', () => {
it('register callbacks', () => {
diff --git a/test/content/hint-key-producer.test.js b/test/content/hint-key-producer.test.js
index b2171ba..dcf477d 100644
--- a/test/content/hint-key-producer.test.js
+++ b/test/content/hint-key-producer.test.js
@@ -1,4 +1,3 @@
-import { expect } from "chai";
import HintKeyProducer from 'content/hint-key-producer';
describe('HintKeyProducer class', () => {
diff --git a/test/content/navigates.test.js b/test/content/navigates.test.js
index f1f0741..1d73344 100644
--- a/test/content/navigates.test.js
+++ b/test/content/navigates.test.js
@@ -1,4 +1,3 @@
-import { expect } from 'chai';
import * as navigates from 'content/navigates';
const testRel = (done, rel, html) => {
diff --git a/test/content/reducers/addon.test.js b/test/content/reducers/addon.test.js
index 93f97e8..8c546d2 100644
--- a/test/content/reducers/addon.test.js
+++ b/test/content/reducers/addon.test.js
@@ -1,4 +1,3 @@
-import { expect } from "chai";
import actions from 'content/actions';
import addonReducer from 'content/reducers/addon';
diff --git a/test/content/reducers/find.test.js b/test/content/reducers/find.test.js
index 908b01b..a8c30d7 100644
--- a/test/content/reducers/find.test.js
+++ b/test/content/reducers/find.test.js
@@ -1,4 +1,3 @@
-import { expect } from "chai";
import actions from 'content/actions';
import findReducer from 'content/reducers/find';
diff --git a/test/content/reducers/follow-controller.test.js b/test/content/reducers/follow-controller.test.js
index f4b91d2..8a4c2d4 100644
--- a/test/content/reducers/follow-controller.test.js
+++ b/test/content/reducers/follow-controller.test.js
@@ -1,4 +1,3 @@
-import { expect } from "chai";
import actions from 'content/actions';
import followControllerReducer from 'content/reducers/follow-controller';
diff --git a/test/content/reducers/input.test.js b/test/content/reducers/input.test.js
index d0b5655..0011943 100644
--- a/test/content/reducers/input.test.js
+++ b/test/content/reducers/input.test.js
@@ -1,4 +1,3 @@
-import { expect } from "chai";
import actions from 'content/actions';
import inputReducer from 'content/reducers/input';
diff --git a/test/content/reducers/setting.test.js b/test/content/reducers/setting.test.js
index 634b299..4e4c095 100644
--- a/test/content/reducers/setting.test.js
+++ b/test/content/reducers/setting.test.js
@@ -1,4 +1,3 @@
-import { expect } from "chai";
import actions from 'content/actions';
import settingReducer from 'content/reducers/setting';
diff --git a/test/main.js b/test/main.js
new file mode 100644
index 0000000..3aeae69
--- /dev/null
+++ b/test/main.js
@@ -0,0 +1,6 @@
+import chai from 'chai';
+const browserFake = require('webextensions-api-fake');
+const browser = browserFake();
+
+global.expect = chai.expect;
+global.browser = browser;
diff --git a/test/settings/components/form/blacklist-form.test.jsx b/test/settings/components/form/blacklist-form.test.jsx
index 95f5cde..1c46943 100644
--- a/test/settings/components/form/blacklist-form.test.jsx
+++ b/test/settings/components/form/blacklist-form.test.jsx
@@ -1,4 +1,3 @@
-import { expect } from 'chai';
import { h, render } from 'preact';
import BlacklistForm from 'settings/components/form/blacklist-form'
diff --git a/test/settings/components/form/keymaps-form.test.jsx b/test/settings/components/form/keymaps-form.test.jsx
index e9f9359..55edf8c 100644
--- a/test/settings/components/form/keymaps-form.test.jsx
+++ b/test/settings/components/form/keymaps-form.test.jsx
@@ -1,4 +1,3 @@
-import { expect } from 'chai';
import { h, render } from 'preact';
import KeymapsForm from 'settings/components/form/keymaps-form'
diff --git a/test/settings/components/form/properties-form.test.jsx b/test/settings/components/form/properties-form.test.jsx
index 4807361..0efe382 100644
--- a/test/settings/components/form/properties-form.test.jsx
+++ b/test/settings/components/form/properties-form.test.jsx
@@ -1,4 +1,3 @@
-import { expect } from 'chai';
import { h, render } from 'preact';
import PropertiesForm from 'settings/components/form/properties-form'
diff --git a/test/settings/components/form/search-engine-form.test.jsx b/test/settings/components/form/search-engine-form.test.jsx
index 9600cae..c52419d 100644
--- a/test/settings/components/form/search-engine-form.test.jsx
+++ b/test/settings/components/form/search-engine-form.test.jsx
@@ -1,4 +1,3 @@
-import { expect } from 'chai';
import { h, render } from 'preact';
import SearchForm from 'settings/components/form/search-form'
diff --git a/test/settings/components/ui/input.test.jsx b/test/settings/components/ui/input.test.jsx
index 98f2cef..0711bba 100644
--- a/test/settings/components/ui/input.test.jsx
+++ b/test/settings/components/ui/input.test.jsx
@@ -1,4 +1,3 @@
-import { expect } from 'chai';
import { h, render } from 'preact';
import Input from 'settings/components/ui/input'
diff --git a/test/settings/reducers/setting.test.js b/test/settings/reducers/setting.test.js
index 3468d4b..b9579cf 100644
--- a/test/settings/reducers/setting.test.js
+++ b/test/settings/reducers/setting.test.js
@@ -1,4 +1,3 @@
-import { expect } from "chai";
import actions from 'settings/actions';
import settingReducer from 'settings/reducers/setting';
diff --git a/test/shared/commands/parsers.test.js b/test/shared/commands/parsers.test.js
index 0a1960c..1910f07 100644
--- a/test/shared/commands/parsers.test.js
+++ b/test/shared/commands/parsers.test.js
@@ -1,4 +1,3 @@
-import { expect } from "chai";
import * as parsers from 'shared/commands/parsers';
describe("shared/commands/parsers", () => {
diff --git a/test/shared/settings/validator.test.js b/test/shared/settings/validator.test.js
index 61d976a..9bbfa3e 100644
--- a/test/shared/settings/validator.test.js
+++ b/test/shared/settings/validator.test.js
@@ -1,4 +1,3 @@
-import { expect } from "chai";
import { validate } from 'shared/settings/validator';
describe("setting validator", () => {
diff --git a/test/shared/settings/values.test.js b/test/shared/settings/values.test.js
index 62cfb5f..c72824d 100644
--- a/test/shared/settings/values.test.js
+++ b/test/shared/settings/values.test.js
@@ -1,4 +1,3 @@
-import { expect } from 'chai';
import * as values from 'shared/settings/values';
describe("settings values", () => {
diff --git a/test/shared/store/index.test.js b/test/shared/store/index.test.js
index 133033b..5b69b40 100644
--- a/test/shared/store/index.test.js
+++ b/test/shared/store/index.test.js
@@ -1,4 +1,3 @@
-import { expect } from "chai";
import { createStore } from 'shared/store';
describe("Store class", () => {
diff --git a/test/shared/utils/keys.test.js b/test/shared/utils/keys.test.js
index 5ca8b54..770b530 100644
--- a/test/shared/utils/keys.test.js
+++ b/test/shared/utils/keys.test.js
@@ -1,4 +1,3 @@
-import { expect } from 'chai';
import * as keys from 'shared/utils/keys';
describe("keys util", () => {
diff --git a/test/shared/utils/re.test.js b/test/shared/utils/re.test.js
index 9ed6521..d12ceb7 100644
--- a/test/shared/utils/re.test.js
+++ b/test/shared/utils/re.test.js
@@ -1,4 +1,3 @@
-import { expect } from 'chai';
import * as re from 'shared/utils/re';
describe("re util", () => {
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);
+ });
+ });
+ });
+});
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');
+ });
+ });
+ });
+});