Catch control.setValue action on Storybook (Angular)

645 views Asked by At

The issue is for Angular 9 although the question should be valid for any case.

I have a component that looks more or less as the following:

export class MyComponent {
  @Input() config: Config;
  @Input() control: FormControl;
};

And function inside the component that do several steps and ends with a this.control.setValue(value);

I want to catch the function using the addon-actions but I was unable to do that since I cant found a way of how to capture the nested event.

I usually do:

export const Default: Story<MyComponent > = TEMPLATE.bind({});
FormattersDe.args = {
  config: {
     ...
  },
  control: new FormControl()
};

But of course there is no action catched, I also try with:

export const Default: Story<MyComponent > = TEMPLATE.bind({});
FormattersDe.args = {
  config: {
     ...
  },
  control: MOCKED_CONTROL
};
const MOCKED_CONTROL = {
   ...new FormControl(),
   setValue: action.setValue
}

But it seems since is not on the first level there is no capture there.

0

There are 0 answers