@@ -76,62 +76,6 @@ export async function render<WrapperType = WrapperComponent>(
76
76
77
77
## Component RenderOptions
78
78
79
- ### ~~ ` componentInputs ` ~~ (deprecated )
80
-
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 .
84
-
85
- ** default ** : ` {} `
86
-
87
- ** example ** :
88
-
89
- ` ` ` typescript
90
- await render(AppComponent, {
91
- componentInputs: {
92
- counterValue: 10,
93
- },
94
- })
95
- ` ` `
96
-
97
- ### ~~ ` componentOutputs ` ~~ (deprecated )
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 ` ~~ (deprecated )
114
-
115
- An object to set ` @Input ` and ` @Output ` properties of the component . Doesn ' t
116
- have a fine - grained control as ` componentInputs ` and ` componentOutputs ` .
117
-
118
- ** default ** : ` {} `
119
-
120
- ** example ** :
121
-
122
- ` ` ` typescript
123
- await render(AppComponent, {
124
- componentProperties: {
125
- // an input
126
- counterValue: 10,
127
- // an output
128
- send: (value) => { ... }
129
- // a public property
130
- name: 'Tim'
131
- }
132
- })
133
- ` ` `
134
-
135
79
### ` declarations `
136
80
137
81
A collection of components , directives and pipes needed to render the component .
@@ -157,7 +101,8 @@ Set the defer blocks behavior.
157
101
For more info see the
158
102
[Angular docs ](https :// angular.io/api/core/testing/DeferBlockBehavior)
159
103
160
- ** default ** : ` undefined ` (uses ` DeferBlockBehavior.Manual ` , which is different from the Angular default of ` DeferBlockBehavior.Playthrough ` )
104
+ ** default ** : ` undefined ` (uses ` DeferBlockBehavior.Manual ` , which is different
105
+ from the Angular default of ` DeferBlockBehavior.Playthrough ` )
161
106
162
107
** example ** :
163
108
@@ -405,6 +350,43 @@ await render(AppComponent, {
405
350
406
351
## ` RenderResult `
407
352
353
+ ### ` inputs `
354
+
355
+ An object to set ` @Input ` or ` input() ` properties of the component .
356
+
357
+ ** default ** : ` {} `
358
+
359
+ ` ` ` typescript
360
+ await render(AppComponent, {
361
+ inputs: {
362
+ counterValue: 10,
363
+ // explicitly define aliases using ` aliasedInput `
364
+ ...aliasedInput('someAlias', 'someValue'),
365
+ },
366
+ })
367
+ ` ` `
368
+
369
+ ### ` on `
370
+
371
+ An object with callbacks to subscribe to ` EventEmitters ` and ` Observables ` of
372
+ the component .
373
+
374
+ ** default ** : ` {} `
375
+
376
+ ` ` ` ts
377
+ // using a manual callback
378
+ const sendValue = (value) => { ... }
379
+ // using a (jest) spy
380
+ const sendValueSpy = jest.fn()
381
+
382
+ await render(AppComponent, {
383
+ on: {
384
+ send: (value) => sendValue(value),
385
+ send: sendValueSpy
386
+ }
387
+ })
388
+ ` ` `
389
+
408
390
### ` container `
409
391
410
392
The containing DOM node of your rendered Angular Component . This is a regular
@@ -430,13 +412,15 @@ properties that are not defined are cleared.
430
412
431
413
` ` ` typescript
432
414
const {rerender} = await render(Counter, {
433
- componentInputs : {count: 4, name: 'Sarah'},
415
+ inputs : {count: 4, name: 'Sarah'},
434
416
})
435
417
436
418
expect(screen.getByTestId('count-value').textContent).toBe('4')
437
419
expect(screen.getByTestId('name-value').textContent).toBe('Sarah')
438
420
439
- await rerender({componentInputs: {count: 7}})
421
+ await rerender({
422
+ inputs: {count: 7}
423
+ })
440
424
441
425
// count is updated to 7
442
426
expect(screen.getByTestId('count-value').textContent).toBe('7')
@@ -449,13 +433,13 @@ input properties that aren't provided won't be cleared.
449
433
450
434
` ` ` typescript
451
435
const {rerender} = await render(Counter, {
452
- componentInputs : {count: 4, name: 'Sarah'},
436
+ inputs : {count: 4, name: 'Sarah'},
453
437
})
454
438
455
439
expect(screen.getByTestId('count-value').textContent).toBe('4')
456
440
expect(screen.getByTestId('name-value').textContent).toBe('Sarah')
457
441
458
- await rerender({componentInputs : {count: 7}, partialUpdate: true})
442
+ await rerender({inputs : {count: 7}, partialUpdate: true})
459
443
460
444
// count is updated to 7
461
445
expect(screen.getByTestId('count-value').textContent).toBe('7')
@@ -546,3 +530,59 @@ expect(screen.getByText(/loading/i)).toBeInTheDocument()
546
530
await renderDeferBlock(DeferBlockState.Complete)
547
531
expect(screen.getByText(/completed/i)).toBeInTheDocument()
548
532
` ` `
533
+
534
+ ### ~~ ` componentInputs ` ~~ (deprecated )
535
+
536
+ An object to set ` @Input ` properties of the component . Uses ` setInput ` to set
537
+ the input property . Throws if the component property is not annotated with the
538
+ ` @Input ` attribute .
539
+
540
+ ** default ** : ` {} `
541
+
542
+ ** example ** :
543
+
544
+ ` ` ` typescript
545
+ await render(AppComponent, {
546
+ componentInputs: {
547
+ counterValue: 10,
548
+ },
549
+ })
550
+ ` ` `
551
+
552
+ ### ~~ ` componentOutputs ` ~~ (deprecated )
553
+
554
+ An object to set ` @Output ` properties of the component .
555
+
556
+ ** default ** : ` {} `
557
+
558
+ ** example ** :
559
+
560
+ ` ` ` typescript
561
+ await render(AppComponent, {
562
+ componentOutputs: {
563
+ clicked: (value) => { ... }
564
+ }
565
+ })
566
+ ` ` `
567
+
568
+ ### ~~ ` componentProperties ` ~~ (deprecated )
569
+
570
+ An object to set ` @Input ` and ` @Output ` properties of the component . Doesn ' t
571
+ have a fine - grained control as ` inputs ` and ` on ` .
572
+
573
+ ** default ** : ` {} `
574
+
575
+ ** example ** :
576
+
577
+ ` ` ` typescript
578
+ await render(AppComponent, {
579
+ componentProperties: {
580
+ // an input
581
+ counterValue: 10,
582
+ // an output
583
+ send: (value) => { ... }
584
+ // a public property
585
+ name: 'Tim'
586
+ }
587
+ })
588
+ ` ` `
0 commit comments