Skip to content

Commit d5df601

Browse files
committed
fixup! refactor: stronger typing of inputs
1 parent d767363 commit d5df601

File tree

3 files changed

+18
-18
lines changed

3 files changed

+18
-18
lines changed

apps/example-app/src/app/examples/22-signal-inputs.component.spec.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { render, screen, within } from '@testing-library/angular';
1+
import { aliasedInputWithValue, render, screen, within } from '@testing-library/angular';
22
import { SignalInputComponent } from './22-signal-inputs.component';
33
import userEvent from '@testing-library/user-event';
44

55
test('works with signal inputs', async () => {
66
await render(SignalInputComponent, {
7-
componentInputs: {
8-
greeting: 'Hello',
7+
inputs: {
8+
greeting: aliasedInputWithValue('Hello'),
99
name: 'world',
1010
},
1111
});
@@ -16,8 +16,8 @@ test('works with signal inputs', async () => {
1616

1717
test('works with computed', async () => {
1818
await render(SignalInputComponent, {
19-
componentInputs: {
20-
greeting: 'Hello',
19+
inputs: {
20+
greeting: aliasedInputWithValue('Hello'),
2121
name: 'world',
2222
},
2323
});
@@ -28,8 +28,8 @@ test('works with computed', async () => {
2828

2929
test('can update signal inputs', async () => {
3030
const { fixture } = await render(SignalInputComponent, {
31-
componentInputs: {
32-
greeting: 'Hello',
31+
inputs: {
32+
greeting: aliasedInputWithValue('Hello'),
3333
name: 'world',
3434
},
3535
});
@@ -51,8 +51,8 @@ test('can update signal inputs', async () => {
5151
test('output emits a value', async () => {
5252
const submitFn = jest.fn();
5353
await render(SignalInputComponent, {
54-
componentInputs: {
55-
greeting: 'Hello',
54+
inputs: {
55+
greeting: aliasedInputWithValue('Hello'),
5656
name: 'world',
5757
},
5858
on: {
@@ -67,8 +67,8 @@ test('output emits a value', async () => {
6767

6868
test('model update also updates the template', async () => {
6969
const { fixture } = await render(SignalInputComponent, {
70-
componentInputs: {
71-
greeting: 'Hello',
70+
inputs: {
71+
greeting: aliasedInputWithValue('Hello'),
7272
name: 'initial',
7373
},
7474
});
@@ -97,8 +97,8 @@ test('model update also updates the template', async () => {
9797

9898
test('works with signal inputs, computed values, and rerenders', async () => {
9999
const view = await render(SignalInputComponent, {
100-
componentInputs: {
101-
greeting: 'Hello',
100+
inputs: {
101+
greeting: aliasedInputWithValue('Hello'),
102102
name: 'world',
103103
},
104104
});
@@ -110,8 +110,8 @@ test('works with signal inputs, computed values, and rerenders', async () => {
110110
expect(computedValue.getByText(/hello world/i)).toBeInTheDocument();
111111

112112
await view.rerender({
113-
componentInputs: {
114-
greeting: 'bye',
113+
inputs: {
114+
greeting: aliasedInputWithValue('bye'),
115115
name: 'test',
116116
},
117117
});

projects/testing-library/src/lib/models.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export interface RenderResult<ComponentType, WrapperType = ComponentType> extend
6868
rerender: (
6969
properties?: Pick<
7070
RenderTemplateOptions<ComponentType>,
71-
'componentProperties' | 'componentInputs' | 'componentOutputs' | 'on' | 'detectChangesOnRender'
71+
'componentProperties' | 'componentInputs' | 'inputs' | 'componentOutputs' | 'on' | 'detectChangesOnRender'
7272
> & { partialUpdate?: boolean },
7373
) => Promise<void>;
7474
/**

projects/testing-library/src/lib/testing-library.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,10 +242,10 @@ export async function render<SutType, WrapperType = SutType>(
242242
const rerender = async (
243243
properties?: Pick<
244244
RenderTemplateOptions<SutType>,
245-
'componentProperties' | 'componentInputs' | 'componentOutputs' | 'on' | 'detectChangesOnRender'
245+
'componentProperties' | 'componentInputs' | 'inputs' | 'componentOutputs' | 'on' | 'detectChangesOnRender'
246246
> & { partialUpdate?: boolean },
247247
) => {
248-
const newComponentInputs = properties?.componentInputs ?? {};
248+
const newComponentInputs = { ...properties?.componentInputs, ...properties?.inputs };
249249
const changesInComponentInput = update(
250250
fixture,
251251
renderedInputKeys,

0 commit comments

Comments
 (0)