{"size": 1390, "ext": "js", "max_stars_repo_path": "src/redux/actions/realtime/detail/address.test.js", "max_stars_repo_name": "AT-Labs/command_centre", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/redux/actions/realtime/detail/address.test.js", "max_issues_repo_name": "AT-Labs/command_centre", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/redux/actions/realtime/detail/address.test.js", "max_forks_repo_name": "AT-Labs/command_centre", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 28.3673469388, "max_line_length": 96, "alphanum_fraction": 0.5223021583}
import { expect } from 'chai';
import configureMockStore from 'redux-mock-store';
import thunk from 'redux-thunk';
import sinon from 'sinon';
import ACTION_TYPE from '../../../action-types';
import { addressSelected } from './address';

const mockStore = configureMockStore([thunk]);
let store;
let sandbox;

describe('Address detail actions', () => {
    beforeEach(() => {
        store = mockStore({});
        sandbox = sinon.createSandbox();
    });

    afterEach(() => {
        sandbox.restore();
        store.clearActions();
    });

    context('addressSelected()', () => {
        it('Should dispatch the update selected adresss action and update search terms', () => {
            const address = {
                address: '48 Valley Road, Mount Eden↵Auckland 1024',
                category: '',
                lat: -36.878854,
                lng: 174.756821,
            };

            const expectedActions = [{
                type: ACTION_TYPE.UPDATE_SELECTED_ADDRESS,
                payload: {
                    address,
                },
            }, {
                type: ACTION_TYPE.UPDATE_SEARCH_TERMS,
                payload: {
                    searchTerms: address.address,
                },
            }];

            store.dispatch(addressSelected(address));
            expect(store.getActions()).eql(expectedActions);
        });
    });
});
