aboutsummaryrefslogtreecommitdiff
path: root/test/console/reducers
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2019-02-12 21:16:38 +0900
committerShin'ya Ueoka <ueokande@i-beam.org>2019-02-15 21:16:34 +0900
commit0c2fcf74bbb49727163ea64486da2a611feebbe7 (patch)
tree8a7be653578c1c19c21fb644bb566fa4782094fe /test/console/reducers
parent21788740c1d4ee28ce05d6bd09d37901d1d88b68 (diff)
Use single index on completions of the console
Diffstat (limited to 'test/console/reducers')
-rw-r--r--test/console/reducers/console.test.js38
1 files changed, 15 insertions, 23 deletions
diff --git a/test/console/reducers/console.test.js b/test/console/reducers/console.test.js
index db40088..d5a38cf 100644
--- a/test/console/reducers/console.test.js
+++ b/test/console/reducers/console.test.js
@@ -8,8 +8,7 @@ describe("console reducer", () => {
expect(state).to.have.property('messageText', '');
expect(state).to.have.property('consoleText', '');
expect(state).to.have.deep.property('completions', []);
- expect(state).to.have.property('groupSelection', -1);
- expect(state).to.have.property('itemSelection', -1);
+ expect(state).to.have.property('select', -1);
});
it('return next state for CONSOLE_HIDE', () => {
@@ -60,8 +59,7 @@ describe("console reducer", () => {
it ('return next state for CONSOLE_SET_COMPLETIONS', () => {
let state = {
- groupSelection: 0,
- itemSelection: 0,
+ select: 0,
completions: [],
}
let action = {
@@ -76,15 +74,13 @@ describe("console reducer", () => {
}
state = reducer(state, action);
expect(state).to.have.property('completions', action.completions);
- expect(state).to.have.property('groupSelection', -1);
- expect(state).to.have.property('itemSelection', -1);
+ expect(state).to.have.property('select', -1);
});
it ('return next state for CONSOLE_COMPLETION_NEXT', () => {
let action = { type: actions.CONSOLE_COMPLETION_NEXT };
let state = {
- groupSelection: -1,
- itemSelection: -1,
+ select: -1,
completions: [{
name: 'Apple',
items: [1, 2]
@@ -95,24 +91,22 @@ describe("console reducer", () => {
};
state = reducer(state, action);
- expect(state).to.have.property('groupSelection', 0);
- expect(state).to.have.property('itemSelection', 0);
+ expect(state).to.have.property('select', 0);
state = reducer(state, action);
- expect(state).to.have.property('groupSelection', 0);
- expect(state).to.have.property('itemSelection', 1);
+ expect(state).to.have.property('select', 1);
state = reducer(state, action);
+ expect(state).to.have.property('select', 2);
+
state = reducer(state, action);
- expect(state).to.have.property('groupSelection', -1);
- expect(state).to.have.property('itemSelection', -1);
+ expect(state).to.have.property('select', -1);
});
it ('return next state for CONSOLE_COMPLETION_PREV', () => {
let action = { type: actions.CONSOLE_COMPLETION_PREV };
let state = {
- groupSelection: -1,
- itemSelection: -1,
+ select: -1,
completions: [{
name: 'Apple',
items: [1, 2]
@@ -123,17 +117,15 @@ describe("console reducer", () => {
};
state = reducer(state, action);
- expect(state).to.have.property('groupSelection', 1);
- expect(state).to.have.property('itemSelection', 0);
+ expect(state).to.have.property('select', 2);
state = reducer(state, action);
- expect(state).to.have.property('groupSelection', 0);
- expect(state).to.have.property('itemSelection', 1);
+ expect(state).to.have.property('select', 1);
state = reducer(state, action);
+ expect(state).to.have.property('select', 0);
+
state = reducer(state, action);
- expect(state).to.have.property('groupSelection', -1);
- expect(state).to.have.property('itemSelection', -1);
+ expect(state).to.have.property('select', -1);
});
-
});