Skip to content

Commit

Permalink
Add selection start tests in regards to issue facebook#11806
Browse files Browse the repository at this point in the history
  • Loading branch information
bs91 committed Dec 9, 2017
1 parent d9869a4 commit 5364e56
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions packages/react-dom/src/client/__tests__/getSelectionStart-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/**
* Copyright (c) 2016-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @emails react-core
*/

'use strict';

const React = require('react');
const ReactDOM = require('react-dom');

describe('getSelectionText', () => {

describe('when the node is a text area', () => {
it('has a value for selectionStart', () => {
const container = document.createElement('div');
ReactDOM.render(<textarea />, container);

expect(container.firstChild.selectionStart).not.toBeUndefined();
});
});

describe('when the node is an input', () => {
it('has a value for selectionStart', () => {
const container = document.createElement('div');
ReactDOM.render(<input />, container);

expect(container.firstChild.selectionStart).not.toBeUndefined();
});
});

describe('when the node is a content editable div', () => {
it('has an undefined value for selectionStart', () => {
const container = document.createElement('div');
ReactDOM.render(<div />, container);
container.firstChild.contentEditable = true;

expect(container.firstChild).toBeTruthy();
expect(container.firstChild.selectionStart).toBeUndefined();
})
})
});

0 comments on commit 5364e56

Please sign in to comment.