@@ -7,6 +7,62 @@ test('is possible to set input and listen for output', async () => {
7
7
const user = userEvent . setup ( ) ;
8
8
const sendValue = jest . fn ( ) ;
9
9
10
+ await render ( InputOutputComponent , {
11
+ componentInputs : {
12
+ value : 47 ,
13
+ } ,
14
+ on : {
15
+ sendValue,
16
+ } ,
17
+ } ) ;
18
+
19
+ const incrementControl = screen . getByRole ( 'button' , { name : / i n c r e m e n t / i } ) ;
20
+ const sendControl = screen . getByRole ( 'button' , { name : / s e n d / i } ) ;
21
+ const valueControl = screen . getByTestId ( 'value' ) ;
22
+
23
+ expect ( valueControl ) . toHaveTextContent ( '47' ) ;
24
+
25
+ await user . click ( incrementControl ) ;
26
+ await user . click ( incrementControl ) ;
27
+ await user . click ( incrementControl ) ;
28
+ expect ( valueControl ) . toHaveTextContent ( '50' ) ;
29
+
30
+ await user . click ( sendControl ) ;
31
+ expect ( sendValue ) . toHaveBeenCalledTimes ( 1 ) ;
32
+ expect ( sendValue ) . toHaveBeenCalledWith ( 50 ) ;
33
+ } ) ;
34
+
35
+ test . skip ( 'is possible to set input and listen for output with the template syntax' , async ( ) => {
36
+ const user = userEvent . setup ( ) ;
37
+ const sendSpy = jest . fn ( ) ;
38
+
39
+ await render ( '<app-fixture [value]="47" (sendValue)="sendValue($event)" />' , {
40
+ imports : [ InputOutputComponent ] ,
41
+ on : {
42
+ sendValue : sendSpy ,
43
+ } ,
44
+ } ) ;
45
+
46
+ const incrementControl = screen . getByRole ( 'button' , { name : / i n c r e m e n t / i } ) ;
47
+ const sendControl = screen . getByRole ( 'button' , { name : / s e n d / i } ) ;
48
+ const valueControl = screen . getByTestId ( 'value' ) ;
49
+
50
+ expect ( valueControl ) . toHaveTextContent ( '47' ) ;
51
+
52
+ await user . click ( incrementControl ) ;
53
+ await user . click ( incrementControl ) ;
54
+ await user . click ( incrementControl ) ;
55
+ expect ( valueControl ) . toHaveTextContent ( '50' ) ;
56
+
57
+ await user . click ( sendControl ) ;
58
+ expect ( sendSpy ) . toHaveBeenCalledTimes ( 1 ) ;
59
+ expect ( sendSpy ) . toHaveBeenCalledWith ( 50 ) ;
60
+ } ) ;
61
+
62
+ test ( 'is possible to set input and listen for output (deprecated)' , async ( ) => {
63
+ const user = userEvent . setup ( ) ;
64
+ const sendValue = jest . fn ( ) ;
65
+
10
66
await render ( InputOutputComponent , {
11
67
componentInputs : {
12
68
value : 47 ,
@@ -34,7 +90,7 @@ test('is possible to set input and listen for output', async () => {
34
90
expect ( sendValue ) . toHaveBeenCalledWith ( 50 ) ;
35
91
} ) ;
36
92
37
- test ( 'is possible to set input and listen for output with the template syntax' , async ( ) => {
93
+ test ( 'is possible to set input and listen for output with the template syntax (deprecated) ' , async ( ) => {
38
94
const user = userEvent . setup ( ) ;
39
95
const sendSpy = jest . fn ( ) ;
40
96
0 commit comments