diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/actions/completion.test.js | 27 | ||||
-rw-r--r-- | test/actions/console.test.js | 34 | ||||
-rw-r--r-- | test/actions/follow.test.js | 4 | ||||
-rw-r--r-- | test/actions/input.test.js | 4 | ||||
-rw-r--r-- | test/components/follow.test.js | 2 | ||||
-rw-r--r-- | test/content/hint-key-producer.test.js | 2 | ||||
-rw-r--r-- | test/content/hint.test.js | 2 | ||||
-rw-r--r-- | test/content/navigates.test.js | 2 | ||||
-rw-r--r-- | test/reducers/completion.test.js | 90 | ||||
-rw-r--r-- | test/reducers/console.test.js | 91 | ||||
-rw-r--r-- | test/reducers/follow.test.js | 4 | ||||
-rw-r--r-- | test/reducers/input.test.js | 4 | ||||
-rw-r--r-- | test/reducers/setting.test.js | 4 | ||||
-rw-r--r-- | test/shared/validators/setting.test.js | 2 | ||||
-rw-r--r-- | test/store/index.test.js | 2 |
15 files changed, 123 insertions, 151 deletions
diff --git a/test/actions/completion.test.js b/test/actions/completion.test.js deleted file mode 100644 index da88f53..0000000 --- a/test/actions/completion.test.js +++ /dev/null @@ -1,27 +0,0 @@ -import { expect } from "chai"; -import actions from '../../src/actions'; -import * as completionActions from '../../src/actions/completion'; - -describe("completion actions", () => { - describe('setItems', () => { - it('create COMPLETION_SET_ITEMS action', () => { - let action = completionActions.setItems([1, 2, 3]); - expect(action.type).to.equal(actions.COMPLETION_SET_ITEMS); - expect(action.groups).to.deep.equal([1, 2, 3]); - }); - }); - - describe('selectNext', () => { - it('create COMPLETION_SELECT_NEXT action', () => { - let action = completionActions.selectNext(); - expect(action.type).to.equal(actions.COMPLETION_SELECT_NEXT); - }); - }); - - describe('selectPrev', () => { - it('create COMPLETION_SELECT_PREV action', () => { - let action = completionActions.selectPrev(); - expect(action.type).to.equal(actions.COMPLETION_SELECT_PREV); - }); - }); -}); diff --git a/test/actions/console.test.js b/test/actions/console.test.js index 512ee40..ff905bc 100644 --- a/test/actions/console.test.js +++ b/test/actions/console.test.js @@ -1,6 +1,6 @@ import { expect } from "chai"; -import actions from '../../src/actions'; -import * as consoleActions from '../../src/actions/console'; +import actions from 'actions'; +import * as consoleActions from 'actions/console'; describe("console actions", () => { describe("showCommand", () => { @@ -11,14 +11,6 @@ describe("console actions", () => { }); }); - describe("setCompletions", () => { - it('create CONSOLE_SET_COMPLETIONS action', () => { - let action = consoleActions.setCompletions([1,2,3]); - expect(action.type).to.equal(actions.CONSOLE_SET_COMPLETIONS); - expect(action.completions).to.deep.equal([1, 2, 3]); - }); - }); - describe("showError", () => { it('create CONSOLE_SHOW_ERROR action', () => { let action = consoleActions.showError('an error'); @@ -33,5 +25,27 @@ describe("console actions", () => { expect(action.type).to.equal(actions.CONSOLE_HIDE); }); }); + + describe("setCompletions", () => { + it('create CONSOLE_SET_COMPLETIONS action', () => { + let action = consoleActions.setCompletions([1,2,3]); + expect(action.type).to.equal(actions.CONSOLE_SET_COMPLETIONS); + expect(action.completions).to.deep.equal([1, 2, 3]); + }); + }); + + describe("completionPrev", () => { + it('create CONSOLE_COMPLETION_PREV action', () => { + let action = consoleActions.completionPrev(); + expect(action.type).to.equal(actions.CONSOLE_COMPLETION_PREV); + }); + }); + + describe("completionNext", () => { + it('create CONSOLE_COMPLETION_NEXT action', () => { + let action = consoleActions.completionNext(); + expect(action.type).to.equal(actions.CONSOLE_COMPLETION_NEXT); + }); + }); }); diff --git a/test/actions/follow.test.js b/test/actions/follow.test.js index 9439de7..32ab9e2 100644 --- a/test/actions/follow.test.js +++ b/test/actions/follow.test.js @@ -1,6 +1,6 @@ import { expect } from "chai"; -import actions from '../../src/actions'; -import * as followActions from '../../src/actions/follow'; +import actions from 'actions'; +import * as followActions from 'actions/follow'; describe('follow actions', () => { describe('enable', () => { diff --git a/test/actions/input.test.js b/test/actions/input.test.js index 904d3e7..0a2ab18 100644 --- a/test/actions/input.test.js +++ b/test/actions/input.test.js @@ -1,6 +1,6 @@ import { expect } from "chai"; -import actions from '../../src/actions'; -import * as inputActions from '../../src/actions/input'; +import actions from 'actions'; +import * as inputActions from 'actions/input'; describe("input actions", () => { describe("keyPress", () => { diff --git a/test/components/follow.test.js b/test/components/follow.test.js index f2f870e..c83e211 100644 --- a/test/components/follow.test.js +++ b/test/components/follow.test.js @@ -1,5 +1,5 @@ import { expect } from "chai"; -import FollowComponent from '../../src/components/follow'; +import FollowComponent from 'components/follow'; describe('FollowComponent', () => { describe('#codeChars', () => { diff --git a/test/content/hint-key-producer.test.js b/test/content/hint-key-producer.test.js index 74fb462..b2171ba 100644 --- a/test/content/hint-key-producer.test.js +++ b/test/content/hint-key-producer.test.js @@ -1,5 +1,5 @@ import { expect } from "chai"; -import HintKeyProducer from '../../src/content/hint-key-producer'; +import HintKeyProducer from 'content/hint-key-producer'; describe('HintKeyProducer class', () => { describe('#constructor', () => { diff --git a/test/content/hint.test.js b/test/content/hint.test.js index 9b2ab6e..1547971 100644 --- a/test/content/hint.test.js +++ b/test/content/hint.test.js @@ -1,5 +1,5 @@ import { expect } from "chai"; -import Hint from '../../src/content/hint'; +import Hint from 'content/hint'; describe('Hint class', () => { beforeEach(() => { diff --git a/test/content/navigates.test.js b/test/content/navigates.test.js index cf20435..b5144e9 100644 --- a/test/content/navigates.test.js +++ b/test/content/navigates.test.js @@ -1,5 +1,5 @@ import { expect } from "chai"; -import * as navigates from '../../src/content/navigates'; +import * as navigates from 'content/navigates'; describe('navigates module', () => { describe('#linkPrev', () => { diff --git a/test/reducers/completion.test.js b/test/reducers/completion.test.js deleted file mode 100644 index 79163bf..0000000 --- a/test/reducers/completion.test.js +++ /dev/null @@ -1,90 +0,0 @@ -import { expect } from "chai"; -import actions from '../../src/actions'; -import completionReducer from '../../src/reducers/completion'; - -describe("completion reducer", () => { - it ('return the initial state', () => { - let state = completionReducer(undefined, {}); - expect(state).to.have.property('groupSelection', -1); - expect(state).to.have.property('itemSelection', -1); - expect(state).to.have.deep.property('groups', []); - }); - - it ('return next state for COMPLETION_SET_ITEMS', () => { - let state = { - groupSelection: 0, - itemSelection: 0, - groups: [], - } - let action = { - type: actions.COMPLETION_SET_ITEMS, - groups: [{ - name: 'Apple', - items: [1, 2, 3] - }, { - name: 'Banana', - items: [4, 5, 6] - }] - } - state = completionReducer(state, action); - expect(state).to.have.property('groups', action.groups); - expect(state).to.have.property('groupSelection', -1); - expect(state).to.have.property('itemSelection', -1); - }); - - it ('return next state for COMPLETION_SELECT_NEXT', () => { - let action = { type: actions.COMPLETION_SELECT_NEXT }; - let state = { - groupSelection: -1, - itemSelection: -1, - groups: [{ - name: 'Apple', - items: [1, 2] - }, { - name: 'Banana', - items: [3] - }] - }; - - state = completionReducer(state, action); - expect(state).to.have.property('groupSelection', 0); - expect(state).to.have.property('itemSelection', 0); - - state = completionReducer(state, action); - expect(state).to.have.property('groupSelection', 0); - expect(state).to.have.property('itemSelection', 1); - - state = completionReducer(state, action); - state = completionReducer(state, action); - expect(state).to.have.property('groupSelection', -1); - expect(state).to.have.property('itemSelection', -1); - }); - - it ('return next state for COMPLETION_SELECT_PREV', () => { - let action = { type: actions.COMPLETION_SELECT_PREV }; - let state = { - groupSelection: -1, - itemSelection: -1, - groups: [{ - name: 'Apple', - items: [1, 2] - }, { - name: 'Banana', - items: [3] - }] - }; - - state = completionReducer(state, action); - expect(state).to.have.property('groupSelection', 1); - expect(state).to.have.property('itemSelection', 0); - - state = completionReducer(state, action); - expect(state).to.have.property('groupSelection', 0); - expect(state).to.have.property('itemSelection', 1); - - state = completionReducer(state, action); - state = completionReducer(state, action); - expect(state).to.have.property('groupSelection', -1); - expect(state).to.have.property('itemSelection', -1); - }); -}); diff --git a/test/reducers/console.test.js b/test/reducers/console.test.js index 9820a08..5ebf4bc 100644 --- a/test/reducers/console.test.js +++ b/test/reducers/console.test.js @@ -1,6 +1,6 @@ import { expect } from "chai"; -import actions from '../../src/actions'; -import consoleReducer from '../../src/reducers/console'; +import actions from 'actions'; +import consoleReducer from 'reducers/console'; describe("console reducer", () => { it('return the initial state', () => { @@ -10,6 +10,8 @@ describe("console reducer", () => { expect(state).to.have.property('commandShown', false); expect(state).to.have.property('commandText', ''); expect(state).to.have.deep.property('completions', []); + expect(state).to.have.property('groupSelection', -1); + expect(state).to.have.property('itemSelection', -1); }); it('return next state for CONSOLE_SHOW_COMMAND', () => { @@ -20,12 +22,6 @@ describe("console reducer", () => { expect(state).to.have.property('errorShown', false); }); - it('return next state for CONSOLE_SET_COMPLETIONS', () => { - let action = { type: actions.CONSOLE_SET_COMPLETIONS, completions: [1, 2, 3] }; - let state = consoleReducer({}, action); - expect(state).to.have.deep.property('completions', [1, 2, 3]); - }); - it('return next state for CONSOLE_SHOW_ERROR', () => { let action = { type: actions.CONSOLE_SHOW_ERROR, text: 'an error' }; let state = consoleReducer({}, action); @@ -40,4 +36,83 @@ describe("console reducer", () => { expect(state).to.have.property('errorShown', false); expect(state).to.have.property('commandShown', false); }); + + it ('return next state for CONSOLE_SET_COMPLETIONS', () => { + let state = { + groupSelection: 0, + itemSelection: 0, + completions: [], + } + let action = { + type: actions.CONSOLE_SET_COMPLETIONS, + completions: [{ + name: 'Apple', + items: [1, 2, 3] + }, { + name: 'Banana', + items: [4, 5, 6] + }] + } + state = consoleReducer(state, action); + expect(state).to.have.property('completions', action.completions); + expect(state).to.have.property('groupSelection', -1); + expect(state).to.have.property('itemSelection', -1); + }); + + it ('return next state for CONSOLE_COMPLETION_NEXT', () => { + let action = { type: actions.CONSOLE_COMPLETION_NEXT }; + let state = { + groupSelection: -1, + itemSelection: -1, + completions: [{ + name: 'Apple', + items: [1, 2] + }, { + name: 'Banana', + items: [3] + }] + }; + + state = consoleReducer(state, action); + expect(state).to.have.property('groupSelection', 0); + expect(state).to.have.property('itemSelection', 0); + + state = consoleReducer(state, action); + expect(state).to.have.property('groupSelection', 0); + expect(state).to.have.property('itemSelection', 1); + + state = consoleReducer(state, action); + state = consoleReducer(state, action); + expect(state).to.have.property('groupSelection', -1); + expect(state).to.have.property('itemSelection', -1); + }); + + it ('return next state for CONSOLE_COMPLETION_PREV', () => { + let action = { type: actions.CONSOLE_COMPLETION_PREV }; + let state = { + groupSelection: -1, + itemSelection: -1, + completions: [{ + name: 'Apple', + items: [1, 2] + }, { + name: 'Banana', + items: [3] + }] + }; + + state = consoleReducer(state, action); + expect(state).to.have.property('groupSelection', 1); + expect(state).to.have.property('itemSelection', 0); + + state = consoleReducer(state, action); + expect(state).to.have.property('groupSelection', 0); + expect(state).to.have.property('itemSelection', 1); + + state = consoleReducer(state, action); + state = consoleReducer(state, action); + expect(state).to.have.property('groupSelection', -1); + expect(state).to.have.property('itemSelection', -1); + }); + }); diff --git a/test/reducers/follow.test.js b/test/reducers/follow.test.js index 19a1300..79e75d4 100644 --- a/test/reducers/follow.test.js +++ b/test/reducers/follow.test.js @@ -1,6 +1,6 @@ import { expect } from "chai"; -import actions from '../../src/actions'; -import followReducer from '../../src/reducers/follow'; +import actions from 'actions'; +import followReducer from 'reducers/follow'; describe('follow reducer', () => { it ('returns the initial state', () => { diff --git a/test/reducers/input.test.js b/test/reducers/input.test.js index 3c3bf39..7b5a89c 100644 --- a/test/reducers/input.test.js +++ b/test/reducers/input.test.js @@ -1,6 +1,6 @@ import { expect } from "chai"; -import actions from '../../src/actions'; -import inputReducer from '../../src/reducers/input'; +import actions from 'actions'; +import inputReducer from 'reducers/input'; describe("input reducer", () => { it('return the initial state', () => { diff --git a/test/reducers/setting.test.js b/test/reducers/setting.test.js index 7261be6..1af031a 100644 --- a/test/reducers/setting.test.js +++ b/test/reducers/setting.test.js @@ -1,6 +1,6 @@ import { expect } from "chai"; -import actions from '../../src/actions'; -import settingReducer from '../../src/reducers/setting'; +import actions from 'actions'; +import settingReducer from 'reducers/setting'; describe("setting reducer", () => { it('return the initial state', () => { diff --git a/test/shared/validators/setting.test.js b/test/shared/validators/setting.test.js index 9baf858..15d6a10 100644 --- a/test/shared/validators/setting.test.js +++ b/test/shared/validators/setting.test.js @@ -1,5 +1,5 @@ import { expect } from "chai"; -import { validate } from '../../../src/shared/validators/setting'; +import { validate } from 'shared/validators/setting'; describe("setting validator", () => { describe("unknown top keys", () => { diff --git a/test/store/index.test.js b/test/store/index.test.js index e19d50e..5dce715 100644 --- a/test/store/index.test.js +++ b/test/store/index.test.js @@ -1,5 +1,5 @@ import { expect } from "chai"; -import { createStore } from '../../src/store'; +import { createStore } from 'store'; describe("Store class", () => { const reducer = (state, action) => { |