@@ -29,3 +29,29 @@ test('is possible to set input and listen for output', async () => {
29
29
expect ( sendValue ) . toHaveBeenCalledTimes ( 1 ) ;
30
30
expect ( sendValue ) . toHaveBeenCalledWith ( 50 ) ;
31
31
} ) ;
32
+
33
+ test ( 'is possible to set input and listen for output with the template syntax' , async ( ) => {
34
+ const sendSpy = jest . fn ( ) ;
35
+
36
+ await render ( InputOutputComponent , {
37
+ template : `<app-fixture [value]="47" (sendValue)="sendValue($event)" (clicked)="clicked()"></app-fixture>` ,
38
+ componentProperties : {
39
+ sendValue : sendSpy ,
40
+ } ,
41
+ } ) ;
42
+
43
+ const incrementControl = screen . getByRole ( 'button' , { name : / i n c r e m e n t / i } ) ;
44
+ const sendControl = screen . getByRole ( 'button' , { name : / s e n d / i } ) ;
45
+ const valueControl = screen . getByTestId ( 'value' ) ;
46
+
47
+ expect ( valueControl . textContent ) . toBe ( '47' ) ;
48
+
49
+ fireEvent . click ( incrementControl ) ;
50
+ fireEvent . click ( incrementControl ) ;
51
+ fireEvent . click ( incrementControl ) ;
52
+ expect ( valueControl . textContent ) . toBe ( '50' ) ;
53
+
54
+ fireEvent . click ( sendControl ) ;
55
+ expect ( sendSpy ) . toHaveBeenCalledTimes ( 1 ) ;
56
+ expect ( sendSpy ) . toHaveBeenCalledWith ( 50 ) ;
57
+ } ) ;
0 commit comments