Skip to content

Commit

Permalink
Added unit tests for Autocomplete#renderMenu
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Lane committed Feb 23, 2016
1 parent cfffd89 commit 16de503
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion lib/__tests__/Autocomplete-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ describe('Autocomplete acceptance tests', () => {
});
});

// Event handler tests
// Event handler unit tests

describe('Autocomplete kewDown->ArrowDown event handlers', () => {

Expand Down Expand Up @@ -211,3 +211,28 @@ describe('Autocomplete kewDown->Escape event handlers', () => {
});

});

// Component method unit tests
describe('Autocomplete#renderMenu', () => {

var autocompleteWrapper = mount(AutocompleteComponentJSX({}));
var autocompleteInputWrapper = autocompleteWrapper.find('input');

it('should return a <div ref="menu"> ReactComponent when renderMenu() is called', () => {
//autocompleteInputWrapper.simulate('change', { target: { value: 'Ar' } });
var autocompleteMenu = autocompleteWrapper.instance().renderMenu();
expect(autocompleteMenu.type).to.be.equal('div');
expect(autocompleteMenu.ref).to.be.equal('menu');
expect(autocompleteMenu.props.children.length).to.be.equal(50);
});

it('should return a menu ReactComponent with a subset of children when partial match text has been entered', () => {
// Input 'Ar' should result in 6 items in the menu, populated from autocomplete.
autocompleteInputWrapper.simulate('change', { target: { value: 'Ar' } });

var autocompleteMenu = autocompleteWrapper.instance().renderMenu();
expect(autocompleteMenu.props.children.length).to.be.equal(6);

});

});

0 comments on commit 16de503

Please sign in to comment.