Skip to content
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

Feature Request: Support MockRenderFactory conditional binding to keep component default values #10423

Open
eliasm307 opened this issue Nov 6, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@eliasm307
Copy link

Describe the feature or problem you'd like to solve

First of all, thanks for this great library, its really useful!

MockRender supports providing an empty object, or omitting some params/inputs to allow default values to be used, ie see https://ng-mocks.sudo.eu/api/MockRender#empty-params

However, for MockRenderFactory this doesnt seem to be possible, ie for the following example in the docs, input1 is explicitly set, however for input2 it seems this input also receives an undefined value which overwrites the component's default value

  const factory = MockRenderFactory(MyComponent, ['input1', 'input2']);
  
  ...

  it('covers one case', () => {
    const fixture = factory({input1: 1});
    expect(fixture.point.componentInstance.input1).toEqual(1);
  });

Also, if I am missing something please let me know.

Proposed solution

Would it be possible for cases like the above to keep the default value if the input value is not explicitly defined? ie for the case above input2 would not be set at all and the default value would be used, or no setters would be called in the component

Additional context

N/A

@eliasm307 eliasm307 added the enhancement New feature or request label Nov 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant