# 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});
        });
    })
});
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://rangle-io.gitbook.io/react-training/index-7/actions.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
