Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffrifwald committed Jan 15, 2016
1 parent cc54ad8 commit 97ac21a
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 34 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
language: node_js
node_js:
- "0.10"
- "4.2.4"
sudo: false
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@
"test": "npm run lint && npm run cover && npm run check_coverage"
},
"devDependencies": {
"babel": "^6.3.13",
"babel-cli": "^6.3.13",
"babel-core": "^6.3.13",
"babel": "6.3.13",
"babel-cli": "6.3.13",
"babel-core": "6.3.13",
"babel-eslint": "^4.1.6",
"babel-loader": "^6.2.1",
"babel-polyfill": "^6.3.13",
"babel-preset-es2015": "^6.3.13",
"babel-preset-react": "^6.3.13",
"babel-preset-stage-1": "^6.3.13",
"babel-polyfill": "6.3.13",
"babel-preset-es2015": "6.3.13",
"babel-preset-react": "6.3.13",
"babel-preset-stage-1": "6.3.13",
"babel-runtime": "^6.3.13",
"css-loader": "^0.23.1",
"eslint": "^0.23.0",
Expand Down
4 changes: 2 additions & 2 deletions src/SearchBox/components/SearchBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ class SearchBox extends React.Component {
this.setState({value});
}

selectIndex(index) {
let selectedIndex = index;
selectIndex(i) {
let selectedIndex = i;

if (selectedIndex >= this.state.results.length) {
selectedIndex = this.state.results.length - 1;
Expand Down
34 changes: 17 additions & 17 deletions src/SelectBox/components/SelectBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class SelectBox extends React.Component {
super(...args);

this.state = {
highlightIndex: -1,
highlightedIndex: -1,
showDropDown: false,
value: this.props.defaultValue
};
Expand Down Expand Up @@ -182,7 +182,7 @@ class SelectBox extends React.Component {
''
),
(
i === this.state.highlightIndex ?
i === this.state.highlightedIndex ?
'react-ui-select-box-option-highlighted' :
''
)
Expand Down Expand Up @@ -211,7 +211,7 @@ class SelectBox extends React.Component {
this.props.onChange(evt, option);

this.setState({
highlightIndex: -1,
highlightedIndex: -1,
showDropDown: false,
query: '',
value: option
Expand Down Expand Up @@ -267,15 +267,15 @@ class SelectBox extends React.Component {
}

onSearchKeyDown(options, evt) {
if (evt.keyCode === KEY_CODES.ENTER && this.state.highlightIndex > -1) {
if (evt.keyCode === KEY_CODES.ENTER && this.state.highlightedIndex > -1) {
this.onChange(
options[this.state.highlightIndex],
options[this.state.highlightedIndex],
evt
);
} else if (evt.keyCode === KEY_CODES.ARROW_DOWN) {
this.highlightIndex(this.state.highlightIndex + 1, options);
this.highlightIndex(this.state.highlightedIndex + 1, options);
} else if (evt.keyCode === KEY_CODES.ARROW_UP) {
this.highlightIndex(this.state.highlightIndex - 1, options);
this.highlightIndex(this.state.highlightedIndex - 1, options);
}
}

Expand All @@ -292,13 +292,13 @@ class SelectBox extends React.Component {
}

filterOptions(options) {
const filterOptions = options || this.getOptions();
const filteredOptions = options || this.getOptions();

return this.state.query ? filterOptions.filter(
return this.state.query ? filteredOptions.filter(
option => option[this.props.displayProp].toLowerCase().indexOf(
this.state.query
) >= 0
) : filterOptions;
) : filteredOptions;
}

isOptionSelected(option) {
Expand All @@ -313,22 +313,22 @@ class SelectBox extends React.Component {
}

highlightIndex(index, options) {
let highlightIndex = index;
let highlightedIndex = index;

if (highlightIndex >= options.length) {
highlightIndex = options.length - 1;
if (highlightedIndex >= options.length) {
highlightedIndex = options.length - 1;
}

if (highlightIndex < 0) {
highlightIndex = 0;
if (highlightedIndex < 0) {
highlightedIndex = 0;
}

this.setState({highlightIndex: highlightIndex});
this.setState({highlightedIndex: highlightedIndex});
}

clear() {
this.setState({
highlightIndex: -1,
highlightedIndex: -1,
value: undefined
});
}
Expand Down
14 changes: 7 additions & 7 deletions src/SelectBox/components/__tests__/SelectBox-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ Mingus.createTestCase('SelectBoxTest', {
);

component.state.value = {display: 'B', value: 'B'};
component.state.highlightIndex = 0;
component.state.highlightedIndex = 0;

const renderedOptions = component.renderOptions(options);

Expand Down Expand Up @@ -227,7 +227,7 @@ Mingus.createTestCase('SelectBoxTest', {
this.assertEqual(component.setState.callCount, 1);
this.assertTrue(onChange.calledWith(mockEvt, 'mock value'));
this.assertTrue(component.setState.calledWith({
highlightIndex: -1,
highlightedIndex: -1,
showDropDown: false,
query: '',
value: 'mock value'
Expand Down Expand Up @@ -395,7 +395,7 @@ Mingus.createTestCase('SelectBoxTest', {
this.assertTrue(component.highlightIndex.calledWith(-2));

mockEvt.keyCode = KEY_CODES.ENTER;
component.state.highlightIndex = 1;
component.state.highlightedIndex = 1;
component.onSearchKeyDown(['a', 'b', 'c'], mockEvt);
this.assertEqual(component.onChange.callCount, 1);
this.assertEqual(component.highlightIndex.callCount, 2);
Expand Down Expand Up @@ -460,19 +460,19 @@ Mingus.createTestCase('SelectBoxTest', {
component.highlightIndex(1, options);
this.assertEqual(component.setState.callCount, 1);
this.assertTrue(component.setState.calledWith({
highlightIndex: 1
highlightedIndex: 1
}));

component.highlightIndex(-2, options);
this.assertEqual(component.setState.callCount, 2);
this.assertTrue(component.setState.calledWith({
highlightIndex: 0
highlightedIndex: 0
}));

component.highlightIndex(10, options);
this.assertEqual(component.setState.callCount, 3);
this.assertTrue(component.setState.calledWith({
highlightIndex: 2
highlightedIndex: 2
}));
},

Expand All @@ -484,7 +484,7 @@ Mingus.createTestCase('SelectBoxTest', {
component.clear();
this.assertEqual(component.setState.callCount, 1);
this.assertTrue(component.setState.calledWith({
highlightIndex: -1,
highlightedIndex: -1,
value: undefined
}));
},
Expand Down

0 comments on commit 97ac21a

Please sign in to comment.