Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
moroshko committed Jun 21, 2017
1 parent 2c4b211 commit b06523a
Show file tree
Hide file tree
Showing 12 changed files with 33 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default [
year: 1995
},
{
name: 'Javascript',
name: 'JavaScript',
year: 1995
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export default [
year: 1995
},
{
name: 'Javascript',
name: 'JavaScript',
year: 1995
},
{
Expand Down
2 changes: 1 addition & 1 deletion demo/src/components/App/components/Header/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default class Header extends Component {
super();

this.state = {
stargazers: '1995'
stargazers: '2020'
};
}

Expand Down
2 changes: 1 addition & 1 deletion demo/standalone/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const languages = [
year: 1995
},
{
name: 'Javascript',
name: 'JavaScript',
year: 1995
},
{
Expand Down
2 changes: 1 addition & 1 deletion demo/standalone/compiled.app.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
year: 1995
},
{
name: 'Javascript',
name: 'JavaScript',
year: 1995
},
{
Expand Down
20 changes: 17 additions & 3 deletions test/always-render-suggestions/AutosuggestApp.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import TestUtils from 'react-dom/test-utils';
import { expect } from 'chai';
import {
init,
expectInputValue,
Expand All @@ -14,7 +15,7 @@ import {
clickUp,
focusAndSetInputValue
} from '../helpers';
import AutosuggestApp from './AutosuggestApp';
import AutosuggestApp, { onSuggestionsFetchRequested } from './AutosuggestApp';

const allSuggestions = [
'C',
Expand All @@ -25,7 +26,7 @@ const allSuggestions = [
'Go',
'Haskell',
'Java',
'Javascript',
'JavaScript',
'Perl',
'PHP',
'Python',
Expand Down Expand Up @@ -151,7 +152,20 @@ describe('Autosuggest with alwaysRenderSuggestions={true}', () => {
focusAndSetInputValue('j');
clickSuggestion(1);
clickDown();
expectHighlightedSuggestion('Javascript');
expectHighlightedSuggestion('JavaScript');
});
});

describe('onSuggestionsFetchRequested', () => {
it('should be called once with the right parameters when suggestion is selected', () => {
focusAndSetInputValue('j');
onSuggestionsFetchRequested.reset();
clickSuggestion(1);
expect(onSuggestionsFetchRequested).to.have.been.calledOnce;
expect(onSuggestionsFetchRequested).to.have.been.calledWithExactly({
value: 'JavaScript',
reason: 'suggestion-selected'
});
});
});
});
2 changes: 1 addition & 1 deletion test/async-suggestions/AutosuggestApp.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('Autosuggest that gets suggestions asynchronously', () => {
});

it('should show suggestions when they arrive', () => {
expectSuggestions(['Java', 'Javascript']);
expectSuggestions(['Java', 'JavaScript']);
});

it('should not show previous suggestions when revealing suggestions', () => {
Expand Down
4 changes: 2 additions & 2 deletions test/focus-first-suggestion/AutosuggestApp.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ describe('Autosuggest with highlightFirstSuggestion={true}', () => {

it('should highlight a suggestion when mouse enters it', () => {
mouseEnterSuggestion(1);
expectHighlightedSuggestion('Javascript');
expectHighlightedSuggestion('JavaScript');
});

it('should not have highlighted suggestions when mouse leaves a suggestion', () => {
Expand All @@ -72,7 +72,7 @@ describe('Autosuggest with highlightFirstSuggestion={true}', () => {

it('should highlight the second suggestion', () => {
clickDown();
expectHighlightedSuggestion('Javascript');
expectHighlightedSuggestion('JavaScript');
});

it('should not highlight any suggestion after reaching the last suggestion', () => {
Expand Down
6 changes: 3 additions & 3 deletions test/multi-section/AutosuggestApp.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ describe('Autosuggest with multiSection={true}', () => {
'Go',
'Haskell',
'Java',
'Javascript',
'JavaScript',
'Perl',
'PHP',
'Python',
Expand Down Expand Up @@ -125,7 +125,7 @@ describe('Autosuggest with multiSection={true}', () => {
'Go',
'Haskell',
'Java',
'Javascript',
'JavaScript',
'Perl',
'PHP',
'Python',
Expand Down Expand Up @@ -193,7 +193,7 @@ describe('Autosuggest with multiSection={true}', () => {
year: 1995
},
{
name: 'Javascript',
name: 'JavaScript',
year: 1995
}
]
Expand Down
2 changes: 1 addition & 1 deletion test/multi-section/languages.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export default [
year: 1995
},
{
name: 'Javascript',
name: 'JavaScript',
year: 1995
}
]
Expand Down
6 changes: 3 additions & 3 deletions test/plain-list/AutosuggestApp.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -564,8 +564,8 @@ describe('Default Autosuggest', () => {
expect(
onSuggestionSelected
).to.have.been.calledWithExactly(syntheticEventMatcher, {
suggestion: { name: 'Javascript', year: 1995 },
suggestionValue: 'Javascript',
suggestion: { name: 'JavaScript', year: 1995 },
suggestionValue: 'JavaScript',
suggestionIndex: 1,
sectionIndex: null,
method: 'click'
Expand Down Expand Up @@ -627,7 +627,7 @@ describe('Default Autosuggest', () => {
clickDown();
expect(onSuggestionsFetchRequested).to.have.been.calledOnce;
expect(onSuggestionsFetchRequested).to.have.been.calledWithExactly({
value: 'Javascript',
value: 'JavaScript',
reason: 'suggestions-revealed'
});
});
Expand Down
2 changes: 1 addition & 1 deletion test/plain-list/languages.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default [
year: 1995
},
{
name: 'Javascript',
name: 'JavaScript',
year: 1995
},
{
Expand Down

0 comments on commit b06523a

Please sign in to comment.