> For the complete documentation index, see [llms.txt](https://rangle-io.gitbook.io/react-training/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://rangle-io.gitbook.io/react-training/index-7/actions.md).

# Actions

Simple actions can be tested like reducers, as pure functions (i.e. given params, confirm the expected object/response). The [Redux gitbook](http://redux.js.org/docs/recipes/WritingTests.html#async-action-creators) contains more examples, including handling tricky async actions.

## Example

```javascript
// ./actions/counter.js
import { INCREMENT_COUNTER, DECREMENT_COUNTER } from '../constants';

export function increment() {
  return {
    type: INCREMENT_COUNTER,
  };
}

...
```

```javascript
// ./actions/counter.test.js

import { assert } from 'chai';
import { INCREMENT_COUNTER, DECREMENT_COUNTER } from '../constants';
import { increment } from '../actions/counter';

describe('Counter Actions', () => {
    describe('increment', () => {
        let obj;
        beforeEach(() => {
            obj = increment();
        });

        it('should return an object', () => {
            assert.isObject(obj)
        });

        it('should return an object with correct type property', () => {
            assert.deepEqual(obj, {type: INCREMENT_COUNTER});
        });
    })
});
```
