@@ -30,57 +30,57 @@ describe('InputModalityDetector', () => {
30
30
it ( 'should do nothing on non-browser platforms' , ( ) => {
31
31
platform . isBrowser = false ;
32
32
detector = new InputModalityDetector ( platform , ngZone , document ) ;
33
- expect ( detector . inputModality ) . toBe ( null ) ;
33
+ expect ( detector . mostRecentModality ) . toBe ( null ) ;
34
34
35
35
dispatchKeyboardEvent ( document , 'keydown' ) ;
36
- expect ( detector . inputModality ) . toBe ( null ) ;
36
+ expect ( detector . mostRecentModality ) . toBe ( null ) ;
37
37
38
38
dispatchMouseEvent ( document , 'mousedown' ) ;
39
- expect ( detector . inputModality ) . toBe ( null ) ;
39
+ expect ( detector . mostRecentModality ) . toBe ( null ) ;
40
40
41
41
dispatchTouchEvent ( document , 'touchstart' ) ;
42
- expect ( detector . inputModality ) . toBe ( null ) ;
42
+ expect ( detector . mostRecentModality ) . toBe ( null ) ;
43
43
} ) ;
44
44
45
45
it ( 'should detect keyboard input modality' , ( ) => {
46
46
detector = new InputModalityDetector ( platform , ngZone , document ) ;
47
47
dispatchKeyboardEvent ( document , 'keydown' ) ;
48
- expect ( detector . inputModality ) . toBe ( 'keyboard' ) ;
48
+ expect ( detector . mostRecentModality ) . toBe ( 'keyboard' ) ;
49
49
} ) ;
50
50
51
51
it ( 'should detect mouse input modality' , ( ) => {
52
52
detector = new InputModalityDetector ( platform , ngZone , document ) ;
53
53
dispatchMouseEvent ( document , 'mousedown' ) ;
54
- expect ( detector . inputModality ) . toBe ( 'mouse' ) ;
54
+ expect ( detector . mostRecentModality ) . toBe ( 'mouse' ) ;
55
55
} ) ;
56
56
57
57
it ( 'should detect touch input modality' , ( ) => {
58
58
detector = new InputModalityDetector ( platform , ngZone , document ) ;
59
59
dispatchTouchEvent ( document , 'touchstart' ) ;
60
- expect ( detector . inputModality ) . toBe ( 'touch' ) ;
60
+ expect ( detector . mostRecentModality ) . toBe ( 'touch' ) ;
61
61
} ) ;
62
62
63
63
it ( 'should detect changes in input modality' , ( ) => {
64
64
detector = new InputModalityDetector ( platform , ngZone , document ) ;
65
65
66
66
dispatchKeyboardEvent ( document , 'keydown' ) ;
67
- expect ( detector . inputModality ) . toBe ( 'keyboard' ) ;
67
+ expect ( detector . mostRecentModality ) . toBe ( 'keyboard' ) ;
68
68
69
69
dispatchMouseEvent ( document , 'mousedown' ) ;
70
- expect ( detector . inputModality ) . toBe ( 'mouse' ) ;
70
+ expect ( detector . mostRecentModality ) . toBe ( 'mouse' ) ;
71
71
72
72
dispatchTouchEvent ( document , 'touchstart' ) ;
73
- expect ( detector . inputModality ) . toBe ( 'touch' ) ;
73
+ expect ( detector . mostRecentModality ) . toBe ( 'touch' ) ;
74
74
75
75
dispatchKeyboardEvent ( document , 'keydown' ) ;
76
- expect ( detector . inputModality ) . toBe ( 'keyboard' ) ;
76
+ expect ( detector . mostRecentModality ) . toBe ( 'keyboard' ) ;
77
77
} ) ;
78
78
79
79
it ( 'should emit changes in input modality' , ( ) => {
80
80
detector = new InputModalityDetector ( platform , ngZone , document ) ;
81
81
const emitted : InputModality [ ] = [ ] ;
82
- detector . inputModalityChange . subscribe ( ( inputModality : InputModality ) => {
83
- emitted . push ( inputModality ) ;
82
+ detector . modalityChanges . subscribe ( ( modality : InputModality ) => {
83
+ emitted . push ( modality ) ;
84
84
} ) ;
85
85
86
86
expect ( emitted . length ) . toBe ( 0 ) ;
@@ -112,7 +112,7 @@ describe('InputModalityDetector', () => {
112
112
Object . defineProperty ( event , 'buttons' , { get : ( ) => 0 } ) ;
113
113
dispatchEvent ( document , event ) ;
114
114
115
- expect ( detector . inputModality ) . toBe ( null ) ;
115
+ expect ( detector . mostRecentModality ) . toBe ( null ) ;
116
116
} ) ;
117
117
118
118
it ( 'should ignore fake screen-reader touch events' , ( ) => {
@@ -123,7 +123,7 @@ describe('InputModalityDetector', () => {
123
123
Object . defineProperty ( event , 'touches' , { get : ( ) => [ { identifier : - 1 } ] } ) ;
124
124
dispatchEvent ( document , event ) ;
125
125
126
- expect ( detector . inputModality ) . toBe ( null ) ;
126
+ expect ( detector . mostRecentModality ) . toBe ( null ) ;
127
127
} ) ;
128
128
129
129
it ( 'should ignore certain modifier keys by default' , ( ) => {
@@ -134,13 +134,13 @@ describe('InputModalityDetector', () => {
134
134
dispatchKeyboardEvent ( document , 'keydown' , META ) ;
135
135
dispatchKeyboardEvent ( document , 'keydown' , SHIFT ) ;
136
136
137
- expect ( detector . inputModality ) . toBe ( null ) ;
137
+ expect ( detector . mostRecentModality ) . toBe ( null ) ;
138
138
} ) ;
139
139
140
140
it ( 'should not ignore modifier keys if specified' , ( ) => {
141
141
detector = new InputModalityDetector ( platform , ngZone , document , { ignoreKeys : [ ] } ) ;
142
142
dispatchKeyboardEvent ( document , 'keydown' , CONTROL ) ;
143
- expect ( detector . inputModality ) . toBe ( 'keyboard' ) ;
143
+ expect ( detector . mostRecentModality ) . toBe ( 'keyboard' ) ;
144
144
} ) ;
145
145
146
146
it ( 'should ignore additional keys if specified' , ( ) => {
@@ -150,18 +150,18 @@ describe('InputModalityDetector', () => {
150
150
dispatchKeyboardEvent ( document , 'keydown' , B ) ;
151
151
dispatchKeyboardEvent ( document , 'keydown' , C ) ;
152
152
153
- expect ( detector . inputModality ) . toBe ( null ) ;
153
+ expect ( detector . mostRecentModality ) . toBe ( null ) ;
154
154
} ) ;
155
155
156
156
it ( 'should ignore mouse events that occur too closely after a touch event' , fakeAsync ( ( ) => {
157
157
detector = new InputModalityDetector ( platform , ngZone , document ) ;
158
158
159
159
dispatchTouchEvent ( document , 'touchstart' ) ;
160
160
dispatchMouseEvent ( document , 'mousedown' ) ;
161
- expect ( detector . inputModality ) . toBe ( 'touch' ) ;
161
+ expect ( detector . mostRecentModality ) . toBe ( 'touch' ) ;
162
162
163
163
tick ( TOUCH_BUFFER_MS ) ;
164
164
dispatchMouseEvent ( document , 'mousedown' ) ;
165
- expect ( detector . inputModality ) . toBe ( 'mouse' ) ;
165
+ expect ( detector . mostRecentModality ) . toBe ( 'mouse' ) ;
166
166
} ) ) ;
167
167
} ) ;
0 commit comments