Test component with actions

In order to test components with actions you do not need to do anything. Actions instances are kept in array and are assigned automatically to components during their creation:

beforeEach(() => {
    const actions = ... // Create actions see example above
    component = new TodoComponent();
});

However sometimes youmight want to assign explicit actions to component. This can be done by calling NgStateTestBed.setActionsToComponent method with actions and instance of component:

const actions = ... // Create actions see example above
ReactStateTestBed.setActionsToComponent(actions, component);

expect(component.actions.todoDescription).toEqual('test description');

Last updated