@@ -37,34 +37,28 @@ describe('MouseHelper.getCoords', () => {
3737 describe ( 'when charMeasure is not initialized' , ( ) => {
3838 it ( 'should return null' , ( ) => {
3939 charMeasure = new MockCharMeasure ( ) ;
40- assert . equal ( mouseHelper . getCoords ( { pageX : 0 , pageY : 0 } , document . createElement ( 'div' ) , charMeasure , 10 , 10 ) , null ) ;
41- } ) ;
42- } ) ;
43-
44- describe ( 'when pageX/pageY are not supported' , ( ) => {
45- it ( 'should return null' , ( ) => {
46- assert . equal ( mouseHelper . getCoords ( { pageX : undefined , pageY : undefined } , document . createElement ( 'div' ) , charMeasure , 10 , 10 ) , null ) ;
40+ assert . equal ( mouseHelper . getCoords ( { clientX : 0 , clientY : 0 } , document . createElement ( 'div' ) , charMeasure , 10 , 10 ) , null ) ;
4741 } ) ;
4842 } ) ;
4943
5044 it ( 'should return the cell that was clicked' , ( ) => {
5145 let coords : [ number , number ] ;
52- coords = mouseHelper . getCoords ( { pageX : CHAR_WIDTH / 2 , pageY : CHAR_HEIGHT / 2 } , document . createElement ( 'div' ) , charMeasure , 10 , 10 ) ;
46+ coords = mouseHelper . getCoords ( { clientX : CHAR_WIDTH / 2 , clientY : CHAR_HEIGHT / 2 } , document . createElement ( 'div' ) , charMeasure , 10 , 10 ) ;
5347 assert . deepEqual ( coords , [ 1 , 1 ] ) ;
54- coords = mouseHelper . getCoords ( { pageX : CHAR_WIDTH , pageY : CHAR_HEIGHT } , document . createElement ( 'div' ) , charMeasure , 10 , 10 ) ;
48+ coords = mouseHelper . getCoords ( { clientX : CHAR_WIDTH , clientY : CHAR_HEIGHT } , document . createElement ( 'div' ) , charMeasure , 10 , 10 ) ;
5549 assert . deepEqual ( coords , [ 1 , 1 ] ) ;
56- coords = mouseHelper . getCoords ( { pageX : CHAR_WIDTH , pageY : CHAR_HEIGHT + 1 } , document . createElement ( 'div' ) , charMeasure , 10 , 10 ) ;
50+ coords = mouseHelper . getCoords ( { clientX : CHAR_WIDTH , clientY : CHAR_HEIGHT + 1 } , document . createElement ( 'div' ) , charMeasure , 10 , 10 ) ;
5751 assert . deepEqual ( coords , [ 1 , 2 ] ) ;
58- coords = mouseHelper . getCoords ( { pageX : CHAR_WIDTH + 1 , pageY : CHAR_HEIGHT } , document . createElement ( 'div' ) , charMeasure , 10 , 10 ) ;
52+ coords = mouseHelper . getCoords ( { clientX : CHAR_WIDTH + 1 , clientY : CHAR_HEIGHT } , document . createElement ( 'div' ) , charMeasure , 10 , 10 ) ;
5953 assert . deepEqual ( coords , [ 2 , 1 ] ) ;
6054 } ) ;
6155
6256 it ( 'should ensure the coordinates are returned within the terminal bounds' , ( ) => {
6357 let coords : [ number , number ] ;
64- coords = mouseHelper . getCoords ( { pageX : - 1 , pageY : - 1 } , document . createElement ( 'div' ) , charMeasure , 10 , 10 ) ;
58+ coords = mouseHelper . getCoords ( { clientX : - 1 , clientY : - 1 } , document . createElement ( 'div' ) , charMeasure , 10 , 10 ) ;
6559 assert . deepEqual ( coords , [ 1 , 1 ] ) ;
6660 // Event are double the cols/rows
67- coords = mouseHelper . getCoords ( { pageX : CHAR_WIDTH * 20 , pageY : CHAR_HEIGHT * 20 } , document . createElement ( 'div' ) , charMeasure , 10 , 10 ) ;
61+ coords = mouseHelper . getCoords ( { clientX : CHAR_WIDTH * 20 , clientY : CHAR_HEIGHT * 20 } , document . createElement ( 'div' ) , charMeasure , 10 , 10 ) ;
6862 assert . deepEqual ( coords , [ 10 , 10 ] , 'coordinates should never come back as larger than the terminal' ) ;
6963 } ) ;
7064} ) ;
0 commit comments