Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Move helper functions for tests
Add a pressEscape() function
  • Loading branch information
bruderstein committed Jul 27, 2015
commit b4f602529b1d5863a8d70bebc72cb7b06602fddc
34 changes: 20 additions & 14 deletions test/Select-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,26 @@ class PropsWrapper extends React.Component {
describe('Select', function() {
var options, instance, onChange;
var searchInputNode;

function pressEnterToAccept() {
TestUtils.Simulate.keyDown(searchInputNode, { keyCode: 13, key: 'Enter' });
}

function pressTabToAccept() {
TestUtils.Simulate.keyDown(searchInputNode, { keyCode: 9, key: 'Tab' });
}

function pressEscape() {
TestUtils.Simulate.keyDown(searchInputNode, { keyCode: 27, key: 'Escape' });
}

function typeSearchText(text) {
TestUtils.Simulate.change(searchInputNode, { target: { value: text } });
}

function getSelectControl(instance) {
return React.findDOMNode(instance).querySelector('.Select-control');
}

describe('with simple options', function () {

Expand Down Expand Up @@ -76,20 +96,6 @@ describe('Select', function() {

});

function pressEnterToAccept() {
TestUtils.Simulate.keyDown(searchInputNode, { keyCode: 13, key: 'Enter' });
}
function pressTabToAccept() {
TestUtils.Simulate.keyDown(searchInputNode, { keyCode: 9, key: 'Tab' });
}

function typeSearchText(text) {
TestUtils.Simulate.change(searchInputNode, { target: { value: text } });
}

function getSelectControl(instance) {
return React.findDOMNode(instance).querySelector('.Select-control');
}

it('should assign the given name', function () {
var selectInputElement = TestUtils.scryRenderedDOMComponentsWithTag(instance, 'input')[0];
Expand Down