react-state-rxjs
  • Introduction
  • Main differences
  • Performance first
  • GETTING STARTED
    • Instalation
    • Examples
  • Core concepts
    • Main idea
      • More complex flow visualization
    • Configuration
    • Store
      • Operators
      • Optimistic updates plugin
      • Form manager plugin
        • ShouldUpdateState hook
        • Custom form elements
      • Persist state plugin
        • Configuring custom storage
    • Actions
      • Immer
      • ImutableJs
      • Async
    • Components with Actions
    • @InjectStore decorator
    • @ComponentState decorator
    • ComponentState Hook
    • Dispatcher
    • Router / History
  • DIFFERENT SCENARIOS
    • Passing list item index via router
  • UNIT TESTING
    • Setup
    • Test store
    • Test actions
    • Test component with actions
    • Test with Enzyme
  • Debugging
    • Setup
    • Redux DevTools
    • Automated changes output
    • Manual state changes check
    • Additional debugging information
  • Production
    • Production mode
  • Other information
    • Best practices
    • CLI
      • Custom Configurations
    • Performance
    • Blog Posts
    • Contributing
Powered by GitBook
On this page

Was this helpful?

  1. UNIT TESTING

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');
PreviousTest actionsNextTest with Enzyme

Last updated 5 years ago

Was this helpful?