| 
									
										
										
										
											2015-05-26 09:25:39 -07:00
										 |  |  | import { | 
					
						
							|  |  |  |   describe, | 
					
						
							|  |  |  |   ddescribe, | 
					
						
							|  |  |  |   it, | 
					
						
							|  |  |  |   iit, | 
					
						
							|  |  |  |   xit, | 
					
						
							|  |  |  |   xdescribe, | 
					
						
							|  |  |  |   expect, | 
					
						
							|  |  |  |   beforeEach, | 
					
						
							|  |  |  |   el | 
					
						
							|  |  |  | } from 'angular2/test_lib'; | 
					
						
							| 
									
										
											  
											
												feat(keyEvents): support for <div (keyup.enter)="callback()">
This commit adds a plugin for the event manager, to allow a key name to
be appended to the event name (for keyup and keydown events), so that
the callback is only called for that key.
Here are some examples:
 (keydown.shift.enter)
 (keyup.space)
 (keydown.control.shift.a)
 (keyup.f1)
Key names mostly follow the DOM Level 3 event key values:
http://www.w3.org/TR/DOM-Level-3-Events-key/#key-value-tables
There are some limitations to be worked on (cf details
in https://github.com/angular/angular/pull/1136) but for now, this
implementation is reliable for the following keys (by "reliable" I mean
compatible with Chrome and Firefox and not depending on the keyboard
layout):
- alt, control, shift, meta (those keys can be combined with other keys)
- tab, enter, backspace, pause, scrolllock, capslock, numlock
- insert, delete, home, end, pageup, pagedown
- arrowup, arrowdown, arrowleft, arrowright
- latin letters (a-z), function keys (f1-f12)
- numbers on the numeric keypad (but those keys are not correctly simulated
by Chromedriver)
There is a sample to play with in examples/src/key_events/.
close #523
close #1136
											
										 
											2015-04-10 13:22:00 +02:00
										 |  |  | import {KeyEventsPlugin} from 'angular2/src/render/dom/events/key_events'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export function main() { | 
					
						
							|  |  |  |   describe('KeyEvents', () => { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     it('should ignore unrecognized events', () => { | 
					
						
							|  |  |  |       expect(KeyEventsPlugin.parseEventName('keydown')).toEqual(null); | 
					
						
							|  |  |  |       expect(KeyEventsPlugin.parseEventName('keyup')).toEqual(null); | 
					
						
							|  |  |  |       expect(KeyEventsPlugin.parseEventName('keydown.unknownmodifier.enter')).toEqual(null); | 
					
						
							|  |  |  |       expect(KeyEventsPlugin.parseEventName('keyup.unknownmodifier.enter')).toEqual(null); | 
					
						
							|  |  |  |       expect(KeyEventsPlugin.parseEventName('unknownevent.control.shift.enter')).toEqual(null); | 
					
						
							|  |  |  |       expect(KeyEventsPlugin.parseEventName('unknownevent.enter')).toEqual(null); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     it('should correctly parse event names', () => { | 
					
						
							|  |  |  |       // key with no modifier
 | 
					
						
							| 
									
										
										
										
											2015-05-26 09:25:39 -07:00
										 |  |  |       expect(KeyEventsPlugin.parseEventName('keydown.enter')) | 
					
						
							|  |  |  |           .toEqual({'domEventName': 'keydown', 'fullKey': 'enter'}); | 
					
						
							|  |  |  |       expect(KeyEventsPlugin.parseEventName('keyup.enter')) | 
					
						
							|  |  |  |           .toEqual({'domEventName': 'keyup', 'fullKey': 'enter'}); | 
					
						
							| 
									
										
											  
											
												feat(keyEvents): support for <div (keyup.enter)="callback()">
This commit adds a plugin for the event manager, to allow a key name to
be appended to the event name (for keyup and keydown events), so that
the callback is only called for that key.
Here are some examples:
 (keydown.shift.enter)
 (keyup.space)
 (keydown.control.shift.a)
 (keyup.f1)
Key names mostly follow the DOM Level 3 event key values:
http://www.w3.org/TR/DOM-Level-3-Events-key/#key-value-tables
There are some limitations to be worked on (cf details
in https://github.com/angular/angular/pull/1136) but for now, this
implementation is reliable for the following keys (by "reliable" I mean
compatible with Chrome and Firefox and not depending on the keyboard
layout):
- alt, control, shift, meta (those keys can be combined with other keys)
- tab, enter, backspace, pause, scrolllock, capslock, numlock
- insert, delete, home, end, pageup, pagedown
- arrowup, arrowdown, arrowleft, arrowright
- latin letters (a-z), function keys (f1-f12)
- numbers on the numeric keypad (but those keys are not correctly simulated
by Chromedriver)
There is a sample to play with in examples/src/key_events/.
close #523
close #1136
											
										 
											2015-04-10 13:22:00 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |       // key with modifiers:
 | 
					
						
							| 
									
										
										
										
											2015-05-26 09:25:39 -07:00
										 |  |  |       expect(KeyEventsPlugin.parseEventName('keydown.control.shift.enter')) | 
					
						
							|  |  |  |           .toEqual({'domEventName': 'keydown', 'fullKey': 'control.shift.enter'}); | 
					
						
							|  |  |  |       expect(KeyEventsPlugin.parseEventName('keyup.control.shift.enter')) | 
					
						
							|  |  |  |           .toEqual({'domEventName': 'keyup', 'fullKey': 'control.shift.enter'}); | 
					
						
							| 
									
										
											  
											
												feat(keyEvents): support for <div (keyup.enter)="callback()">
This commit adds a plugin for the event manager, to allow a key name to
be appended to the event name (for keyup and keydown events), so that
the callback is only called for that key.
Here are some examples:
 (keydown.shift.enter)
 (keyup.space)
 (keydown.control.shift.a)
 (keyup.f1)
Key names mostly follow the DOM Level 3 event key values:
http://www.w3.org/TR/DOM-Level-3-Events-key/#key-value-tables
There are some limitations to be worked on (cf details
in https://github.com/angular/angular/pull/1136) but for now, this
implementation is reliable for the following keys (by "reliable" I mean
compatible with Chrome and Firefox and not depending on the keyboard
layout):
- alt, control, shift, meta (those keys can be combined with other keys)
- tab, enter, backspace, pause, scrolllock, capslock, numlock
- insert, delete, home, end, pageup, pagedown
- arrowup, arrowdown, arrowleft, arrowright
- latin letters (a-z), function keys (f1-f12)
- numbers on the numeric keypad (but those keys are not correctly simulated
by Chromedriver)
There is a sample to play with in examples/src/key_events/.
close #523
close #1136
											
										 
											2015-04-10 13:22:00 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |       // key with modifiers in a different order:
 | 
					
						
							| 
									
										
										
										
											2015-05-26 09:25:39 -07:00
										 |  |  |       expect(KeyEventsPlugin.parseEventName('keydown.shift.control.enter')) | 
					
						
							|  |  |  |           .toEqual({'domEventName': 'keydown', 'fullKey': 'control.shift.enter'}); | 
					
						
							|  |  |  |       expect(KeyEventsPlugin.parseEventName('keyup.shift.control.enter')) | 
					
						
							|  |  |  |           .toEqual({'domEventName': 'keyup', 'fullKey': 'control.shift.enter'}); | 
					
						
							| 
									
										
											  
											
												feat(keyEvents): support for <div (keyup.enter)="callback()">
This commit adds a plugin for the event manager, to allow a key name to
be appended to the event name (for keyup and keydown events), so that
the callback is only called for that key.
Here are some examples:
 (keydown.shift.enter)
 (keyup.space)
 (keydown.control.shift.a)
 (keyup.f1)
Key names mostly follow the DOM Level 3 event key values:
http://www.w3.org/TR/DOM-Level-3-Events-key/#key-value-tables
There are some limitations to be worked on (cf details
in https://github.com/angular/angular/pull/1136) but for now, this
implementation is reliable for the following keys (by "reliable" I mean
compatible with Chrome and Firefox and not depending on the keyboard
layout):
- alt, control, shift, meta (those keys can be combined with other keys)
- tab, enter, backspace, pause, scrolllock, capslock, numlock
- insert, delete, home, end, pageup, pagedown
- arrowup, arrowdown, arrowleft, arrowright
- latin letters (a-z), function keys (f1-f12)
- numbers on the numeric keypad (but those keys are not correctly simulated
by Chromedriver)
There is a sample to play with in examples/src/key_events/.
close #523
close #1136
											
										 
											2015-04-10 13:22:00 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |       // key that is also a modifier:
 | 
					
						
							| 
									
										
										
										
											2015-05-26 09:25:39 -07:00
										 |  |  |       expect(KeyEventsPlugin.parseEventName('keydown.shift.control')) | 
					
						
							|  |  |  |           .toEqual({'domEventName': 'keydown', 'fullKey': 'shift.control'}); | 
					
						
							|  |  |  |       expect(KeyEventsPlugin.parseEventName('keyup.shift.control')) | 
					
						
							|  |  |  |           .toEqual({'domEventName': 'keyup', 'fullKey': 'shift.control'}); | 
					
						
							| 
									
										
											  
											
												feat(keyEvents): support for <div (keyup.enter)="callback()">
This commit adds a plugin for the event manager, to allow a key name to
be appended to the event name (for keyup and keydown events), so that
the callback is only called for that key.
Here are some examples:
 (keydown.shift.enter)
 (keyup.space)
 (keydown.control.shift.a)
 (keyup.f1)
Key names mostly follow the DOM Level 3 event key values:
http://www.w3.org/TR/DOM-Level-3-Events-key/#key-value-tables
There are some limitations to be worked on (cf details
in https://github.com/angular/angular/pull/1136) but for now, this
implementation is reliable for the following keys (by "reliable" I mean
compatible with Chrome and Firefox and not depending on the keyboard
layout):
- alt, control, shift, meta (those keys can be combined with other keys)
- tab, enter, backspace, pause, scrolllock, capslock, numlock
- insert, delete, home, end, pageup, pagedown
- arrowup, arrowdown, arrowleft, arrowright
- latin letters (a-z), function keys (f1-f12)
- numbers on the numeric keypad (but those keys are not correctly simulated
by Chromedriver)
There is a sample to play with in examples/src/key_events/.
close #523
close #1136
											
										 
											2015-04-10 13:22:00 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-26 09:25:39 -07:00
										 |  |  |       expect(KeyEventsPlugin.parseEventName('keydown.control.shift')) | 
					
						
							|  |  |  |           .toEqual({'domEventName': 'keydown', 'fullKey': 'control.shift'}); | 
					
						
							|  |  |  |       expect(KeyEventsPlugin.parseEventName('keyup.control.shift')) | 
					
						
							|  |  |  |           .toEqual({'domEventName': 'keyup', 'fullKey': 'control.shift'}); | 
					
						
							| 
									
										
											  
											
												feat(keyEvents): support for <div (keyup.enter)="callback()">
This commit adds a plugin for the event manager, to allow a key name to
be appended to the event name (for keyup and keydown events), so that
the callback is only called for that key.
Here are some examples:
 (keydown.shift.enter)
 (keyup.space)
 (keydown.control.shift.a)
 (keyup.f1)
Key names mostly follow the DOM Level 3 event key values:
http://www.w3.org/TR/DOM-Level-3-Events-key/#key-value-tables
There are some limitations to be worked on (cf details
in https://github.com/angular/angular/pull/1136) but for now, this
implementation is reliable for the following keys (by "reliable" I mean
compatible with Chrome and Firefox and not depending on the keyboard
layout):
- alt, control, shift, meta (those keys can be combined with other keys)
- tab, enter, backspace, pause, scrolllock, capslock, numlock
- insert, delete, home, end, pageup, pagedown
- arrowup, arrowdown, arrowleft, arrowright
- latin letters (a-z), function keys (f1-f12)
- numbers on the numeric keypad (but those keys are not correctly simulated
by Chromedriver)
There is a sample to play with in examples/src/key_events/.
close #523
close #1136
											
										 
											2015-04-10 13:22:00 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-20 08:51:31 +02:00
										 |  |  |     it('should alias esc to escape', () => { | 
					
						
							|  |  |  |       expect(KeyEventsPlugin.parseEventName('keyup.control.esc')) | 
					
						
							|  |  |  |           .toEqual(KeyEventsPlugin.parseEventName('keyup.control.escape')); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												feat(keyEvents): support for <div (keyup.enter)="callback()">
This commit adds a plugin for the event manager, to allow a key name to
be appended to the event name (for keyup and keydown events), so that
the callback is only called for that key.
Here are some examples:
 (keydown.shift.enter)
 (keyup.space)
 (keydown.control.shift.a)
 (keyup.f1)
Key names mostly follow the DOM Level 3 event key values:
http://www.w3.org/TR/DOM-Level-3-Events-key/#key-value-tables
There are some limitations to be worked on (cf details
in https://github.com/angular/angular/pull/1136) but for now, this
implementation is reliable for the following keys (by "reliable" I mean
compatible with Chrome and Firefox and not depending on the keyboard
layout):
- alt, control, shift, meta (those keys can be combined with other keys)
- tab, enter, backspace, pause, scrolllock, capslock, numlock
- insert, delete, home, end, pageup, pagedown
- arrowup, arrowdown, arrowleft, arrowright
- latin letters (a-z), function keys (f1-f12)
- numbers on the numeric keypad (but those keys are not correctly simulated
by Chromedriver)
There is a sample to play with in examples/src/key_events/.
close #523
close #1136
											
										 
											2015-04-10 13:22:00 +02:00
										 |  |  |   }); | 
					
						
							|  |  |  | } |