aboutsummaryrefslogtreecommitdiff
path: root/test/background
diff options
context:
space:
mode:
Diffstat (limited to 'test/background')
-rw-r--r--test/background/actions/find.test.js12
-rw-r--r--test/background/actions/tab.test.js13
-rw-r--r--test/background/reducers/find.test.js18
-rw-r--r--test/background/reducers/setting.test.js35
-rw-r--r--test/background/reducers/tab.test.js22
-rw-r--r--test/background/shared/commands/parsers.test.js84
-rw-r--r--test/background/usecases/parsers.test.js5
7 files changed, 2 insertions, 187 deletions
diff --git a/test/background/actions/find.test.js b/test/background/actions/find.test.js
deleted file mode 100644
index 6b0b846..0000000
--- a/test/background/actions/find.test.js
+++ /dev/null
@@ -1,12 +0,0 @@
-import actions from 'background/actions';
-import * as findActions from 'background/actions/find';
-
-describe("find actions", () => {
- describe("setKeyword", () => {
- it('create FIND_SET_KEYWORD action', () => {
- let action = findActions.setKeyword('banana');
- expect(action.type).to.equal(actions.FIND_SET_KEYWORD);
- expect(action.keyword).to.equal('banana');
- });
- });
-});
diff --git a/test/background/actions/tab.test.js b/test/background/actions/tab.test.js
deleted file mode 100644
index ab57374..0000000
--- a/test/background/actions/tab.test.js
+++ /dev/null
@@ -1,13 +0,0 @@
-import actions from 'background/actions';
-import * as tabActions from 'background/actions/tab';
-
-describe("tab actions", () => {
- describe("selected", () => {
- it('create TAB_SELECTED action', () => {
- let action = tabActions.selected(123);
- expect(action.type).to.equal(actions.TAB_SELECTED);
- expect(action.tabId).to.equal(123);
- });
- });
-});
-
diff --git a/test/background/reducers/find.test.js b/test/background/reducers/find.test.js
deleted file mode 100644
index c366223..0000000
--- a/test/background/reducers/find.test.js
+++ /dev/null
@@ -1,18 +0,0 @@
-import actions from 'background/actions';
-import findReducer from 'background/reducers/find';
-
-describe("find reducer", () => {
- it('return the initial state', () => {
- let state = findReducer(undefined, {});
- expect(state).to.have.deep.property('keyword', null);
- });
-
- it('return next state for FIND_SET_KEYWORD', () => {
- let action = {
- type: actions.FIND_SET_KEYWORD,
- keyword: 'cherry',
- };
- let state = findReducer(undefined, action);
- expect(state).to.have.deep.property('keyword', 'cherry')
- });
-});
diff --git a/test/background/reducers/setting.test.js b/test/background/reducers/setting.test.js
deleted file mode 100644
index 24d02ea..0000000
--- a/test/background/reducers/setting.test.js
+++ /dev/null
@@ -1,35 +0,0 @@
-import actions from 'background/actions';
-import settingReducer from 'background/reducers/setting';
-
-describe("setting reducer", () => {
- it('return the initial state', () => {
- let state = settingReducer(undefined, {});
- expect(state).to.have.deep.property('value', {});
- });
-
- it('return next state for SETTING_SET_SETTINGS', () => {
- let action = {
- type: actions.SETTING_SET_SETTINGS,
- value: { key: 123 },
- };
- let state = settingReducer(undefined, action);
- expect(state).to.have.deep.property('value', { key: 123 });
- });
-
- it('return next state for SETTING_SET_PROPERTY', () => {
- let state = {
- value: {
- properties: { smoothscroll: true }
- }
- }
- let action = {
- type: actions.SETTING_SET_PROPERTY,
- name: 'encoding',
- value: 'utf-8',
- };
- state = settingReducer(state, action);
-
- expect(state.value.properties).to.have.property('smoothscroll', true);
- expect(state.value.properties).to.have.property('encoding', 'utf-8');
- });
-});
diff --git a/test/background/reducers/tab.test.js b/test/background/reducers/tab.test.js
deleted file mode 100644
index 09fa8a7..0000000
--- a/test/background/reducers/tab.test.js
+++ /dev/null
@@ -1,22 +0,0 @@
-import actions from 'background/actions';
-import tabReducer from 'background/reducers/tab';
-
-describe("tab reducer", () => {
- it('return the initial state', () => {
- let state = tabReducer(undefined, {});
- expect(state.previousSelected).to.equal(-1);
- expect(state.currentSelected).to.equal(-1);
- });
-
- it('return next state for TAB_SELECTED', () => {
- let state = undefined;
-
- state = tabReducer(state, { type: actions.TAB_SELECTED, tabId: 123 });
- expect(state.previousSelected).to.equal(-1);
- expect(state.currentSelected).to.equal(123);
-
- state = tabReducer(state, { type: actions.TAB_SELECTED, tabId: 456 });
- expect(state.previousSelected).to.equal(123);
- expect(state.currentSelected).to.equal(456);
- });
-});
diff --git a/test/background/shared/commands/parsers.test.js b/test/background/shared/commands/parsers.test.js
deleted file mode 100644
index 4a0c9f0..0000000
--- a/test/background/shared/commands/parsers.test.js
+++ /dev/null
@@ -1,84 +0,0 @@
-import * as parsers from 'background/shared/commands/parsers';
-
-describe("shared/commands/parsers", () => {
- describe("#parsers.parseSetOption", () => {
- it('parse set string', () => {
- let [key, value] = parsers.parseSetOption('encoding=utf-8', { encoding: 'string' });
- expect(key).to.equal('encoding');
- expect(value).to.equal('utf-8');
- });
-
- it('parse set empty string', () => {
- let [key, value] = parsers.parseSetOption('encoding=', { encoding: 'string' });
- expect(key).to.equal('encoding');
- expect(value).to.equal('');
- });
-
- it('parse set string', () => {
- let [key, value] = parsers.parseSetOption('history=50', { history: 'number' });
- expect(key).to.equal('history');
- expect(value).to.equal(50);
- });
-
- it('parse set boolean', () => {
- let [key, value] = parsers.parseSetOption('paste', { paste: 'boolean' });
- expect(key).to.equal('paste');
- expect(value).to.be.true;
-
- [key, value] = parsers.parseSetOption('nopaste', { paste: 'boolean' });
- expect(key).to.equal('paste');
- expect(value).to.be.false;
- });
-
- it('throws error on unknown property', () => {
- expect(() => parsers.parseSetOption('charset=utf-8', {})).to.throw(Error, 'Unknown');
- expect(() => parsers.parseSetOption('smoothscroll', {})).to.throw(Error, 'Unknown');
- expect(() => parsers.parseSetOption('nosmoothscroll', {})).to.throw(Error, 'Unknown');
- })
-
- it('throws error on invalid property', () => {
- expect(() => parsers.parseSetOption('charset=utf-8', { charset: 'number' })).to.throw(Error, 'Not number');
- expect(() => parsers.parseSetOption('charset=utf-8', { charset: 'boolean' })).to.throw(Error, 'Invalid');
- expect(() => parsers.parseSetOption('charset=', { charset: 'boolean' })).to.throw(Error, 'Invalid');
- expect(() => parsers.parseSetOption('smoothscroll', { smoothscroll: 'string' })).to.throw(Error, 'Invalid');
- expect(() => parsers.parseSetOption('smoothscroll', { smoothscroll: 'number' })).to.throw(Error, 'Invalid');
- })
- });
-
- describe('#normalizeUrl', () => {
- const config = {
- default: 'google',
- engines: {
- google: 'https://google.com/search?q={}',
- yahoo: 'https://yahoo.com/search?q={}',
- }
- };
-
- it('convertes search url', () => {
- expect(parsers.normalizeUrl(['google', 'apple'], config))
- .to.equal('https://google.com/search?q=apple');
- expect(parsers.normalizeUrl(['yahoo', 'apple'], config))
- .to.equal('https://yahoo.com/search?q=apple');
- expect(parsers.normalizeUrl(['google', 'apple', 'banana'], config))
- .to.equal('https://google.com/search?q=apple%20banana');
- expect(parsers.normalizeUrl(['yahoo', 'C++CLI'], config))
- .to.equal('https://yahoo.com/search?q=C%2B%2BCLI');
- });
-
- it('user default search engine', () => {
- expect(parsers.normalizeUrl(['apple', 'banana'], config))
- .to.equal('https://google.com/search?q=apple%20banana');
- });
- });
-
- describe('#parseCommandLine', () => {
- it('parse command line as name and args', () => {
- expect(parsers.parseCommandLine('open google apple')).to.deep.equal(['open', ['google', 'apple']]);
- expect(parsers.parseCommandLine(' open google apple ')).to.deep.equal(['open', ['google', 'apple']]);
- expect(parsers.parseCommandLine('')).to.deep.equal(['', []]);
- expect(parsers.parseCommandLine(' ')).to.deep.equal(['', []]);
- expect(parsers.parseCommandLine('exit')).to.deep.equal(['exit', []]);
- expect(parsers.parseCommandLine(' exit ')).to.deep.equal(['exit', []]);
- });
- });
-});
diff --git a/test/background/usecases/parsers.test.js b/test/background/usecases/parsers.test.js
index fa0e757..a58c4a3 100644
--- a/test/background/usecases/parsers.test.js
+++ b/test/background/usecases/parsers.test.js
@@ -1,6 +1,6 @@
import * as parsers from 'background/usecases/parsers';
-describe("background/usecases/parsers", () => {
+describe("shared/commands/parsers", () => {
describe("#parsers.parseSetOption", () => {
it('parse set string', () => {
let [key, value] = parsers.parseSetOption('encoding=utf-8', { encoding: 'string' });
@@ -65,10 +65,9 @@ describe("background/usecases/parsers", () => {
.to.equal('https://yahoo.com/search?q=C%2B%2BCLI');
});
- it('user default search engine', () => {
+ it('user default search engine', () => {
expect(parsers.normalizeUrl('apple banana', config))
.to.equal('https://google.com/search?q=apple%20banana');
});
});
});
-