@@ -76,58 +76,40 @@ export async function render<WrapperType = WrapperComponent>(
7676
7777## Component RenderOptions
7878
79- ### ` componentInputs `
8079
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 `
8481
85- ** default ** : ` {} `
82+ An object to set ` @Input ` or ` input() ` properties of the component .
8683
87- ** example ** :
84+ ** default ** : ` {} `
8885
8986` ` ` typescript
9087await render(AppComponent, {
91- componentInputs : {
88+ inputs : {
9289 counterValue: 10,
90+ // explicitly define aliases using ` aliasedInput `
91+ ...aliasedInput('someAlias', 'someValue'),
9392 },
9493})
9594` ` `
9695
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 `
11497
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 .
117100
118101** default ** : ` {} `
119102
120- ** example ** :
103+ ` ` ` ts
104+ // using a manual callback
105+ const sendValue = (value) => { ... }
106+ // using a (jest) spy
107+ const sendValueSpy = jest.fn()
121108
122- ` ` ` typescript
123109await 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
131113 }
132114})
133115` ` `
@@ -157,7 +139,8 @@ Set the defer blocks behavior.
157139For more info see the
158140[Angular docs ](https :// angular.io/api/core/testing/DeferBlockBehavior)
159141
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 ` )
161144
162145** example ** :
163146
@@ -403,6 +386,64 @@ await render(AppComponent, {
403386})
404387` ` `
405388
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+
406447## ` RenderResult `
407448
408449### ` container `
@@ -430,13 +471,15 @@ properties that are not defined are cleared.
430471
431472` ` ` typescript
432473const {rerender} = await render(Counter, {
433- componentInputs : {count: 4, name: 'Sarah'},
474+ inputs : {count: 4, name: 'Sarah'},
434475})
435476
436477expect(screen.getByTestId('count-value').textContent).toBe('4')
437478expect(screen.getByTestId('name-value').textContent).toBe('Sarah')
438479
439- await rerender({componentInputs: {count: 7}})
480+ await rerender({
481+ inputs: {count: 7}
482+ })
440483
441484// count is updated to 7
442485expect(screen.getByTestId('count-value').textContent).toBe('7')
@@ -449,13 +492,13 @@ input properties that aren't provided won't be cleared.
449492
450493` ` ` typescript
451494const {rerender} = await render(Counter, {
452- componentInputs : {count: 4, name: 'Sarah'},
495+ inputs : {count: 4, name: 'Sarah'},
453496})
454497
455498expect(screen.getByTestId('count-value').textContent).toBe('4')
456499expect(screen.getByTestId('name-value').textContent).toBe('Sarah')
457500
458- await rerender({componentInputs : {count: 7}, partialUpdate: true})
501+ await rerender({inputs : {count: 7}, partialUpdate: true})
459502
460503// count is updated to 7
461504expect(screen.getByTestId('count-value').textContent).toBe('7')
0 commit comments