Clean old codes
This commit is contained in:
parent
66c23423f9
commit
ccdb0a2428
32 changed files with 4 additions and 1279 deletions
|
@ -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');
|
||||
});
|
||||
});
|
||||
});
|
|
@ -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);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
@ -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')
|
||||
});
|
||||
});
|
|
@ -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');
|
||||
});
|
||||
});
|
|
@ -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);
|
||||
});
|
||||
});
|
|
@ -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', []]);
|
||||
});
|
||||
});
|
||||
});
|
|
@ -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');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
|
Reference in a new issue