@@ -76,58 +76,40 @@ export async function render<WrapperType = WrapperComponent>(
76
76
77
77
## Component RenderOptions
78
78
79
- ### ` componentInputs `
80
79
81
- An object to set ` @Input ` properties of the component . Uses ` setInput ` to set
82
- the input property . Throws if the component property is not annotated with the
83
- ` @Input ` attribute .
80
+ ### ` inputs `
84
81
85
- ** default ** : ` {} `
82
+ An object to set ` @Input ` or ` input() ` properties of the component .
86
83
87
- ** example ** :
84
+ ** default ** : ` {} `
88
85
89
86
` ` ` typescript
90
87
await render(AppComponent, {
91
- componentInputs : {
88
+ inputs : {
92
89
counterValue: 10,
90
+ // explicitly define aliases using ` aliasedInput `
91
+ ...aliasedInput('someAlias', 'someValue'),
93
92
},
94
93
})
95
94
` ` `
96
95
97
- ### ` componentOutputs `
98
-
99
- An object to set ` @Output ` properties of the component .
100
-
101
- ** default ** : ` {} `
102
-
103
- ** example ** :
104
-
105
- ` ` ` typescript
106
- await render(AppComponent, {
107
- componentOutputs: {
108
- clicked: (value) => { ... }
109
- }
110
- })
111
- ` ` `
112
-
113
- ### ` componentProperties `
96
+ ### ` on `
114
97
115
- An object to set ` @Input ` and ` @Output ` properties of the component . Doesn ' t
116
- have a fine - grained control as ` componentInputs ` and ` componentOutputs ` .
98
+ An object with callbacks to subscribe to ` EventEmitters ` and ` Observables ` of
99
+ the component .
117
100
118
101
** default ** : ` {} `
119
102
120
- ** example ** :
103
+ ` ` ` ts
104
+ // using a manual callback
105
+ const sendValue = (value) => { ... }
106
+ // using a (jest) spy
107
+ const sendValueSpy = jest.fn()
121
108
122
- ` ` ` typescript
123
109
await render(AppComponent, {
124
- componentProperties: {
125
- // an input
126
- counterValue: 10,
127
- // an output
128
- send: (value) => { ... }
129
- // a public property
130
- name: 'Tim'
110
+ on: {
111
+ send: (value) => sendValue(value),
112
+ send: sendValueSpy
131
113
}
132
114
})
133
115
` ` `
@@ -157,7 +139,8 @@ Set the defer blocks behavior.
157
139
For more info see the
158
140
[Angular docs ](https :// angular.io/api/core/testing/DeferBlockBehavior)
159
141
160
- ** default ** : ` undefined ` (uses ` DeferBlockBehavior.Manual ` , which is different from the Angular default of ` DeferBlockBehavior.Playthrough ` )
142
+ ** default ** : ` undefined ` (uses ` DeferBlockBehavior.Manual ` , which is different
143
+ from the Angular default of ` DeferBlockBehavior.Playthrough ` )
161
144
162
145
** example ** :
163
146
@@ -403,6 +386,64 @@ await render(AppComponent, {
403
386
})
404
387
` ` `
405
388
389
+
390
+ ### ~~ ` componentInputs ` ~~ (deprecated )
391
+
392
+ An object to set ` @Input ` properties of the component . Uses ` setInput ` to set
393
+ the input property . Throws if the component property is not annotated with the
394
+ ` @Input ` attribute .
395
+
396
+ ** default ** : ` {} `
397
+
398
+ ** example ** :
399
+
400
+ ` ` ` typescript
401
+ await render(AppComponent, {
402
+ componentInputs: {
403
+ counterValue: 10,
404
+ },
405
+ })
406
+ ` ` `
407
+
408
+ ### ~~ ` componentOutputs ` ~~ (deprecated )
409
+
410
+ An object to set ` @Output ` properties of the component .
411
+
412
+ ** default ** : ` {} `
413
+
414
+ ** example ** :
415
+
416
+ ` ` ` typescript
417
+ await render(AppComponent, {
418
+ componentOutputs: {
419
+ clicked: (value) => { ... }
420
+ }
421
+ })
422
+ ` ` `
423
+
424
+ ### ~~ ` componentProperties ` ~~ (deprecated )
425
+
426
+ An object to set ` @Input ` and ` @Output ` properties of the component . Doesn ' t
427
+ have a fine - grained control as ` inputs ` and ` on ` .
428
+
429
+ ** default ** : ` {} `
430
+
431
+ ** example ** :
432
+
433
+ ` ` ` typescript
434
+ await render(AppComponent, {
435
+ componentProperties: {
436
+ // an input
437
+ counterValue: 10,
438
+ // an output
439
+ send: (value) => { ... }
440
+ // a public property
441
+ name: 'Tim'
442
+ }
443
+ })
444
+ ` ` `
445
+
446
+
406
447
## ` RenderResult `
407
448
408
449
### ` container `
@@ -430,13 +471,15 @@ properties that are not defined are cleared.
430
471
431
472
` ` ` typescript
432
473
const {rerender} = await render(Counter, {
433
- componentInputs : {count: 4, name: 'Sarah'},
474
+ inputs : {count: 4, name: 'Sarah'},
434
475
})
435
476
436
477
expect(screen.getByTestId('count-value').textContent).toBe('4')
437
478
expect(screen.getByTestId('name-value').textContent).toBe('Sarah')
438
479
439
- await rerender({componentInputs: {count: 7}})
480
+ await rerender({
481
+ inputs: {count: 7}
482
+ })
440
483
441
484
// count is updated to 7
442
485
expect(screen.getByTestId('count-value').textContent).toBe('7')
@@ -449,13 +492,13 @@ input properties that aren't provided won't be cleared.
449
492
450
493
` ` ` typescript
451
494
const {rerender} = await render(Counter, {
452
- componentInputs : {count: 4, name: 'Sarah'},
495
+ inputs : {count: 4, name: 'Sarah'},
453
496
})
454
497
455
498
expect(screen.getByTestId('count-value').textContent).toBe('4')
456
499
expect(screen.getByTestId('name-value').textContent).toBe('Sarah')
457
500
458
- await rerender({componentInputs : {count: 7}, partialUpdate: true})
501
+ await rerender({inputs : {count: 7}, partialUpdate: true})
459
502
460
503
// count is updated to 7
461
504
expect(screen.getByTestId('count-value').textContent).toBe('7')
0 commit comments