Skip to content

Conversation

@andreialecu
Copy link
Contributor

@andreialecu andreialecu commented Jul 29, 2024

Fixes #464

This PR restores the type safety of inputs and introduces a new property called inputs and deprecates componentInputs. Previously we had an union with { [alias: string]: unknown } which would essentially act as any.

We add a branded type through which aliases can be explicitly supplied.

Usage:

  @Component({
    selector: 'atl-fixture',
    template: `<span>{{ myName() }}</span> <span>{{ myJob() }}</span>`,
  })
  class InputComponent {
    myName = input('foo');

    myJob = input('bar', { alias: 'job' });
  }

  it('should set the input component', async () => {
    await render(InputComponent, {
      inputs: {
        myName: 'Bob',
        ...aliasedInput('job', 'Builder'),
      },
    });

    expect(screen.getByText('Bob')).toBeInTheDocument();
    expect(screen.getByText('Builder')).toBeInTheDocument();
  });

Copy link
Member

@timdeschryver timdeschryver left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your time and great work on this @andreialecu !

@timdeschryver timdeschryver merged commit 3095737 into testing-library:main Aug 3, 2024
@timdeschryver
Copy link
Member

@all-contributors please add @andreialecu for code, ideas, doc

@allcontributors
Copy link
Contributor

@timdeschryver

I've put up a pull request to add @andreialecu! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

signal-based inputs and componentInputs type

2 participants