Skip to content

refactor: stronger typing of inputs #473

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Aug 3, 2024
Prev Previous commit
Next Next commit
test: update deprecated componentInputs -> inputs
  • Loading branch information
andreialecu committed Jul 29, 2024
commit ad67fc498cb65f04d64d90e37ab75a8d8644986e
4 changes: 2 additions & 2 deletions apps/example-app/src/app/examples/02-input-output.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ test('is possible to set input and listen for output', async () => {
const sendValue = jest.fn();

await render(InputOutputComponent, {
componentInputs: {
inputs: {
value: 47,
},
on: {
Expand Down Expand Up @@ -64,7 +64,7 @@ test('is possible to set input and listen for output (deprecated)', async () =>
const sendValue = jest.fn();

await render(InputOutputComponent, {
componentInputs: {
inputs: {
value: 47,
},
componentOutputs: {
Expand Down
4 changes: 2 additions & 2 deletions projects/testing-library/tests/integrations/ng-mocks.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { NgIf } from '@angular/common';
test('sends the correct value to the child input', async () => {
const utils = await render(TargetComponent, {
imports: [MockComponent(ChildComponent)],
componentInputs: { value: 'foo' },
inputs: { value: 'foo' },
});

const children = utils.fixture.debugElement.queryAll(By.directive(ChildComponent));
Expand All @@ -21,7 +21,7 @@ test('sends the correct value to the child input', async () => {
test('sends the correct value to the child input 2', async () => {
const utils = await render(TargetComponent, {
imports: [MockComponent(ChildComponent)],
componentInputs: { value: 'bar' },
inputs: { value: 'bar' },
});

const children = utils.fixture.debugElement.queryAll(By.directive(ChildComponent));
Expand Down
12 changes: 6 additions & 6 deletions projects/testing-library/tests/rerender.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ test('rerenders the component with updated inputs', async () => {
expect(screen.getByText('Sarah')).toBeInTheDocument();

const firstName = 'Mark';
await rerender({ componentInputs: { firstName } });
await rerender({ inputs: { firstName } });

expect(screen.getByText(firstName)).toBeInTheDocument();
});
Expand All @@ -52,7 +52,7 @@ test('rerenders the component with updated inputs and resets other props', async
const firstName = 'Mark';
const lastName = 'Peeters';
const { rerender } = await render(FixtureComponent, {
componentInputs: {
inputs: {
firstName,
lastName,
},
Expand All @@ -61,7 +61,7 @@ test('rerenders the component with updated inputs and resets other props', async
expect(screen.getByText(`${firstName} ${lastName}`)).toBeInTheDocument();

const firstName2 = 'Chris';
await rerender({ componentInputs: { firstName: firstName2 } });
await rerender({ inputs: { firstName: firstName2 } });

expect(screen.getByText(firstName2)).toBeInTheDocument();
expect(screen.queryByText(firstName)).not.toBeInTheDocument();
Expand All @@ -87,7 +87,7 @@ test('rerenders the component with updated inputs and keeps other props when par
const firstName = 'Mark';
const lastName = 'Peeters';
const { rerender } = await render(FixtureComponent, {
componentInputs: {
inputs: {
firstName,
lastName,
},
Expand All @@ -96,7 +96,7 @@ test('rerenders the component with updated inputs and keeps other props when par
expect(screen.getByText(`${firstName} ${lastName}`)).toBeInTheDocument();

const firstName2 = 'Chris';
await rerender({ componentInputs: { firstName: firstName2 }, partialUpdate: true });
await rerender({ inputs: { firstName: firstName2 }, partialUpdate: true });

expect(screen.queryByText(firstName)).not.toBeInTheDocument();
expect(screen.getByText(`${firstName2} ${lastName}`)).toBeInTheDocument();
Expand Down Expand Up @@ -181,7 +181,7 @@ test('change detection gets not called if `detectChangesOnRender` is set to fals
expect(screen.getByText('Sarah')).toBeInTheDocument();

const firstName = 'Mark';
await rerender({ componentInputs: { firstName }, detectChangesOnRender: false });
await rerender({ inputs: { firstName }, detectChangesOnRender: false });

expect(screen.getByText('Sarah')).toBeInTheDocument();
expect(screen.queryByText(firstName)).not.toBeInTheDocument();
Expand Down