@@ -36,37 +36,50 @@ describe('ReactInputSelection', () => {
3636 expect ( ReactInputSelection . hasSelectionCapabilities ( textarea ) ) . toBe ( true ) ;
3737 } ) ;
3838
39- it ( 'returns true for text inputs' , ( ) => {
40- var inputText = document . createElement ( 'input' ) ;
39+ it ( 'returns true for inputs that can support text selection ranges' , ( ) => {
40+ [
41+ 'date' ,
42+ 'datetime-local' ,
43+ 'email' ,
44+ 'month' ,
45+ 'number' ,
46+ 'password' ,
47+ 'search' ,
48+ 'tel' ,
49+ 'text' ,
50+ 'time' ,
51+ 'url' ,
52+ 'week' ,
53+ ] . forEach ( type => {
54+ const input = document . createElement ( 'input' ) ;
55+ input . type = type ;
56+ expect ( ReactInputSelection . hasSelectionCapabilities ( input ) ) . toBe ( true ) ;
57+ } ) ;
58+
4159 var inputReadOnly = document . createElement ( 'input' ) ;
4260 inputReadOnly . readOnly = 'true' ;
43- var inputNumber = document . createElement ( 'input' ) ;
44- inputNumber . type = 'number' ;
45- var inputEmail = document . createElement ( 'input' ) ;
46- inputEmail . type = 'email' ;
47- var inputPassword = document . createElement ( 'input' ) ;
48- inputPassword . type = 'password' ;
49- var inputHidden = document . createElement ( 'input' ) ;
50- inputHidden . type = 'hidden' ;
51-
52- expect ( ReactInputSelection . hasSelectionCapabilities ( inputText ) ) . toBe (
53- true ,
54- ) ;
5561 expect ( ReactInputSelection . hasSelectionCapabilities ( inputReadOnly ) ) . toBe (
5662 true ,
5763 ) ;
58- expect ( ReactInputSelection . hasSelectionCapabilities ( inputNumber ) ) . toBe (
59- false ,
60- ) ;
61- expect ( ReactInputSelection . hasSelectionCapabilities ( inputEmail ) ) . toBe (
62- false ,
63- ) ;
64- expect ( ReactInputSelection . hasSelectionCapabilities ( inputPassword ) ) . toBe (
65- false ,
66- ) ;
67- expect ( ReactInputSelection . hasSelectionCapabilities ( inputHidden ) ) . toBe (
68- false ,
69- ) ;
64+ } ) ;
65+
66+ it ( 'returns false for non-text-selectable inputs' , ( ) => {
67+ [
68+ 'button' ,
69+ 'checkbox' ,
70+ 'color' ,
71+ 'file' ,
72+ 'hidden' ,
73+ 'image' ,
74+ 'radio' ,
75+ 'range' ,
76+ 'reset' ,
77+ 'submit' ,
78+ ] . forEach ( type => {
79+ const input = document . createElement ( 'input' ) ;
80+ input . type = type ;
81+ expect ( ReactInputSelection . hasSelectionCapabilities ( input ) ) . toBe ( false ) ;
82+ } ) ;
7083 } ) ;
7184
7285 it ( 'returns true for contentEditable elements' , ( ) => {
0 commit comments