/* eslint func-names:0 */
import { expect } from 'chai';
import { createStore } from 'redux';
import React, { render } from 'react/addons';
import ExecutionEnvironment from 'react/lib/ExecutionEnvironment';
import { Provider } from 'react-redux';
import { Link } from '../../src/react';

describe('React', () => {
    describe('Link', () => {
        let store;
        let div;

        beforeEach(() => {
            store = createStore(() => {});

            if (ExecutionEnvironment.canUseDOM) {
                div = document.createElement('div');
            }
        });

        it('renders anchor with simple path', function() {
            if (!ExecutionEnvironment.canUseDOM) {
                this.skip();
            }

            render(
                (
                    <Provider store={store}>
                        {() => <Link to="/path/123" />}
                    </Provider>
                ),
                div,
                () => {
                    const a = div.querySelector('a');
                    expect(a.getAttribute('href')).to.be.equal('/path/123');
                }
            );
        });

        it('renders anchor with href and query string', function() {
            if (!ExecutionEnvironment.canUseDOM) {
                this.skip();
            }

            render(
                (
                    <Provider store={store}>
                        {() => <Link to="/path/123" query={{ test: 1, name: 'Fero' }} />}
                    </Provider>
                ),
                div,
                () => {
                    const a = div.querySelector('a');
                    expect(a.getAttribute('href')).to.be.equal('/path/123?test=1&name=Fero');
                }
            );
        });
    });
});


@@ -74,22 +74,149 @@
 tore
- %7D from 'redux
+, combineReducers, compose %7D from 'redux';%0Aimport %7B createMemoryHistory %7D from 'history';%0Aimport createRoutex from '../../src/createRoutex.js
 ';%0Ai
@@ -543,36 +543,150 @@
     
-store = createStore(() =%3E %7B%7D
+const routex = createRoutex(%5B%5D, createMemoryHistory());%0A            store = compose(routex.store, createStore)(combineReducers(routex.reducer)
 );%0A%0A

fix missing router in store api in Link test