2
2
<img width =" 100% " height =" 100% " src =" https://raw.githubusercontent.com/ngneat/spectator/master/image.svg?sanitize=true " >
3
3
</p >
4
4
5
- [ ![ All Contributors] ( https://img.shields.io/badge/all_contributors-47 -orange.svg?style=flat-square )] ( #contributors )
5
+ [ ![ All Contributors] ( https://img.shields.io/badge/all_contributors-48 -orange.svg?style=flat-square )] ( #contributors )
6
6
[ ![ spectator] ( https://img.shields.io/badge/tested%20with-spectator-2196F3.svg?style=flat-square )] ( )
7
7
[ ![ MIT] ( https://img.shields.io/packagist/l/doctrine/orm.svg?style=flat-square )] ( )
8
8
[ ![ commitizen] ( https://img.shields.io/badge/commitizen-friendly-brightgreen.svg?style=flat-square )] ( )
@@ -36,6 +36,7 @@ Spectator helps you get rid of all the boilerplate grunt work, leaving you with
36
36
- [ Testing Components] ( #testing-components )
37
37
- [ Events API] ( #events-api )
38
38
- [ Custom Events] ( #custom-events )
39
+ - [ Event Creators] ( #event-creators )
39
40
- [ Keyboard helpers] ( #keyboard-helpers )
40
41
- [ Mouse helpers] ( #mouse-helpers )
41
42
- [ Queries] ( #queries )
@@ -225,7 +226,7 @@ spectator.typeInElement(value, byText('Element'));
225
226
spectator .dispatchMouseEvent (SpectatorElement , ' mouseout' );
226
227
spectator .dispatchMouseEvent (SpectatorElement , ' mouseout' ), x , y , event );
227
228
spectator .dispatchMouseEvent (byText (' Element' ), ' mouseout' );
228
- spectator .dispatchMouseEvent (byText (' Element' ), ' mouseout' ) , x , y , event );
229
+ spectator .dispatchMouseEvent (byText (' Element' ), ' mouseout' , x , y , event );
229
230
```
230
231
- ` dispatchKeyboardEvent() ` - Triggers a keyboard event:
231
232
``` ts
@@ -248,6 +249,17 @@ spectator.triggerEventHandler(MyChildComponent, 'myCustomEvent', 'eventValue');
248
249
spectator .triggerEventHandler (' app-child-component' , ' myCustomEvent' , ' eventValue' );
249
250
```
250
251
252
+ #### Event Creators
253
+
254
+ In case you want to test events independently of any template (e.g. in presenter services) you can fallback on the underlying event creators.
255
+ They are basically providing the same signature without the preceding element.
256
+ ``` ts
257
+ const keyboardEvent = createKeyboardEvent (' keyup' , ' ArrowDown' /* , targetElement */ );
258
+ const mouseEvent = createMouseEvent (' mouseout' );
259
+ const touchEvent = createTouchEvent (' touchmove' );
260
+ const fakeEvent = createFakeEvent (' input' );
261
+ ```
262
+
251
263
### Keyboard helpers
252
264
``` ts
253
265
spectator .keyboard .pressEnter ();
@@ -1153,7 +1165,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
1153
1165
| [<img src="https://avatars1.githubusercontent.com/u/20629635?v=4" width="100px;"/><br /><sub><b>Chris Cooper</b></sub>](https://github.com/cjcoops)<br />[💻](https://github.com/ngneat/spectator/commits?author=cjcoops "Code") | [<img src="https://avatars1.githubusercontent.com/u/5886709?v=4" width="100px;"/><br /><sub><b>Marc Scheib</b></sub>](https://github.com/MarcScheib)<br />[📖](https://github.com/ngneat/spectator/commits?author=MarcScheib "Documentation") | [<img src="https://avatars1.githubusercontent.com/u/2036391?v=4" width="100px;"/><br /><sub><b>dgsmith2</b></sub>](https://github.com/dgsmith2)<br />[💻](https://github.com/ngneat/spectator/commits?author=dgsmith2 "Code") | [<img src="https://avatars1.githubusercontent.com/u/50801476?v=4" width="100px;"/><br /><sub><b>dedwardstech</b></sub>](https://github.com/dedwardstech)<br />[💻](https://github.com/ngneat/spectator/commits?author=dedwardstech "Code") [🤔](#ideas-dedwardstech "Ideas, Planning, & Feedback") | [<img src="https://avatars2.githubusercontent.com/u/11571461?v=4" width="100px;"/><br /><sub><b>tamasfoldi</b></sub>](https://github.com/tamasfoldi)<br />[💻](https://github.com/ngneat/spectator/commits?author=tamasfoldi "Code") [🤔](#ideas-tamasfoldi "Ideas, Planning, & Feedback") | [<img src="https://avatars0.githubusercontent.com/u/10036108?v=4" width="100px;"/><br /><sub><b>Paolo Caleffi</b></sub>](https://github.com/IlCallo)<br />[💻](https://github.com/ngneat/spectator/commits?author=IlCallo "Code") | [<img src="https://avatars2.githubusercontent.com/u/7110786?v=4" width="100px;"/><br /><sub><b>Toni Villena</b></sub>](https://github.com/tonivj5)<br />[💻](https://github.com/ngneat/spectator/commits?author=tonivj5 "Code") |
1154
1166
| [<img src="https://avatars2.githubusercontent.com/u/6719615?v=4" width="100px;"/><br /><sub><b>Itay Oded</b></sub>](https://github.com/itayod)<br />[💻](https://github.com/ngneat/spectator/commits?author=itayod "Code") | [<img src="https://avatars0.githubusercontent.com/u/1236069?v=4" width="100px;"/><br /><sub><b>Guillaume de Jabrun</b></sub>](https://twitter.com/Wykks)<br />[💻](https://github.com/ngneat/spectator/commits?author=Wykks "Code") | [<img src="https://avatars2.githubusercontent.com/u/5392144?v=4" width="100px;"/><br /><sub><b>Anand Tiwary</b></sub>](https://github.com/codeNoobie)<br />[💻](https://github.com/ngneat/spectator/commits?author=codeNoobie "Code") | [<img src="https://avatars3.githubusercontent.com/u/13190278?v=4" width="100px;"/><br /><sub><b>Ales Doganoc</b></sub>](https://github.com/AlesDo)<br />[💻](https://github.com/ngneat/spectator/commits?author=AlesDo "Code") | [<img src="https://avatars3.githubusercontent.com/u/1009783?v=4" width="100px;"/><br /><sub><b>Zoltan</b></sub>](https://zoltan.nz)<br />[💻](https://github.com/ngneat/spectator/commits?author=zoltan-nz "Code") | [<img src="https://avatars1.githubusercontent.com/u/13370430?v=4" width="100px;"/><br /><sub><b>Vitalii Baziuk</b></sub>](https://github.com/Coffee-Tea)<br />[💻](https://github.com/ngneat/spectator/commits?author=Coffee-Tea "Code") | [<img src="https://avatars0.githubusercontent.com/u/50454150?v=4" width="100px;"/><br /><sub><b>clementlemarc-certua</b></sub>](https://github.com/clementlemarc-certua)<br />[💻](https://github.com/ngneat/spectator/commits?author=clementlemarc-certua "Code") |
1155
1167
| [<img src="https://avatars1.githubusercontent.com/u/302213?v=4" width="100px;"/><br /><sub><b>Yuriy Grunin</b></sub>](https://github.com/th0r)<br />[💻](https://github.com/ngneat/spectator/commits?author=th0r "Code") | [<img src="https://avatars2.githubusercontent.com/u/11780854?v=4" width="100px;"/><br /><sub><b>Andrey Chalkin</b></sub>](https://t.me/L2jLiga)<br />[💻](https://github.com/ngneat/spectator/commits?author=L2jLiga "Code") | [<img src="https://avatars3.githubusercontent.com/u/7720242?s=400&v=4" width="100px;"/><br /><sub><b>Steven Harris</b></sub>](https://stevenharrisdev.com)<br />[💻](https://github.com/ngneat/spectator/commits?author=Steven-Harris "Code") [📖](https://github.com/ngneat/spectator/commits?author=Steven-Harris "Documentation") | [<img src="https://avatars2.githubusercontent.com/u/4697912?v=4" width="100px;"/><br /><sub><b>Richard Sahrakorpi</b></sub>](http://rjgunning.com)<br />[💻](https://github.com/ngneat/spectator/commits?author=RGunning "Code") | [<img src="https://avatars2.githubusercontent.com/u/13023533?v=4" width="100px;"/><br /><sub><b>Dominik Kremer</b></sub>](https://github.com/kremerd)<br />[💻](https://github.com/ngneat/spectator/commits?author=kremerd "Code") | [<img src="https://avatars1.githubusercontent.com/u/5039606?v=4" width="100px;"/><br /><sub><b>Mehmet Ozan Turhan</b></sub>](https://medium.com/@ozanturhan)<br />[💻](https://github.com/ngneat/spectator/commits?author=ozanturhan "Code") | [<img src="https://avatars2.githubusercontent.com/u/13765663?v=4" width="100px;"/><br /><sub><b>Vlad Lashko</b></sub>](https://github.com/thunderer199)<br />[💻](https://github.com/ngneat/spectator/commits?author=thunderer199 "Code") |
1156
- | [<img src="https://avatars0.githubusercontent.com/u/20136906?v=4" width="100px;"/><br /><sub><b>William Tjondrosuharto</b></sub>](https://github.com/williamjuan027)<br />[💻](https://github.com/ngneat/spectator/commits?author=williamjuan027 "Code") | [<img src="https://avatars0.githubusercontent.com/u/1752170?v=4" width="100px;"/><br /><sub><b>Chaz Gatian</b></sub>](https://twitter.com/Cgatian)<br />[💻](https://github.com/ngneat/spectator/commits?author=cgatian "Code") | [<img src="https://avatars2.githubusercontent.com/u/27703381?v=4" width="100px;"/><br /><sub><b>Pavel Korobov</b></sub>](https://github.com/shirados90)<br />[💻](https://github.com/ngneat/spectator/commits?author=shirados90 "Code") | [<img src="https://avatars3.githubusercontent.com/u/25953659?v=4" width="100px;"/><br /><sub><b>Enno Lohmann</b></sub>](https://github.com/EnnoLohmann)<br />[💻](https://github.com/ngneat/spectator/commits?author=EnnoLohmann "Code") | [<img src="https://avatars2.githubusercontent.com/u/5169399?v=4" width="100px;"/><br /><sub><b>Pawel Boguslawski</b></sub>](https://github.com/bogusweb)<br />[💻](https://github.com/ngneat/spectator/commits?author=bogusweb "Code") |
1168
+ | [<img src="https://avatars0.githubusercontent.com/u/20136906?v=4" width="100px;"/><br /><sub><b>William Tjondrosuharto</b></sub>](https://github.com/williamjuan027)<br />[💻](https://github.com/ngneat/spectator/commits?author=williamjuan027 "Code") | [<img src="https://avatars0.githubusercontent.com/u/1752170?v=4" width="100px;"/><br /><sub><b>Chaz Gatian</b></sub>](https://twitter.com/Cgatian)<br />[💻](https://github.com/ngneat/spectator/commits?author=cgatian "Code") | [<img src="https://avatars2.githubusercontent.com/u/27703381?v=4" width="100px;"/><br /><sub><b>Pavel Korobov</b></sub>](https://github.com/shirados90)<br />[💻](https://github.com/ngneat/spectator/commits?author=shirados90 "Code") | [<img src="https://avatars3.githubusercontent.com/u/25953659?v=4" width="100px;"/><br /><sub><b>Enno Lohmann</b></sub>](https://github.com/EnnoLohmann)<br />[💻](https://github.com/ngneat/spectator/commits?author=EnnoLohmann "Code") | [<img src="https://avatars2.githubusercontent.com/u/5169399?v=4" width="100px;"/><br /><sub><b>Pawel Boguslawski</b></sub>](https://github.com/bogusweb)<br />[💻](https://github.com/ngneat/spectator/commits?author=bogusweb "Code") | [<img src="https://avatars1.githubusercontent.com/u/8677948?v=4" width="100px;"/><br /><sub><b>Tobias Wittwer</b></sub>](https://github.com/twittwer)<br />[💻](https://github.com/ngneat/spectator/commits?author=twittwer "Code") [📖](https://github.com/ngneat/spectator/commits?author=twittwer "Documentation") |
1157
1169
<!-- ALL -CONTRIBUTORS -LIST : END -->
1158
1170
1159
1171
This project follows the [all -contributors ](https : // allcontributors.org/docs/en/emoji-key) specification. Contributions of any kind welcome!
0 commit comments