forked from facebook/react
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add selection start tests in regards to issue facebook#11806
- Loading branch information
Showing
1 changed file
with
45 additions
and
0 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
packages/react-dom/src/client/__tests__/getSelectionStart-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
}) | ||
}) | ||
}); |