const assert = require('assert')
const React = require('react')
const ReactDOM = require('react-dom')
const ReactRedux = require('react-redux')
const Redux = require('redux')
const TestUtils = require('react-addons-test-utils')
const fetchMock = require('fetch-mock')

const App = require('../../src/components/App')
const reducer = require('../../src/reducers/reducer')

describe('App', () => {
  let store

  before(() => {
    store = Redux.createStore(reducer)
    fetchMock.mock('*', {})
  })

  after(() => {
    fetchMock.restore()
  })

  it('renders', () => {
    const appComponent = TestUtils.renderIntoDocument(
      <ReactRedux.Provider store={store}>
        <App />
      </ReactRedux.Provider>
    )

    assert(ReactDOM.findDOMNode(appComponent))

    const fetchedCalls = fetchMock.calls().matched
    assert.equal(1, fetchedCalls.length, 'Only one fetch call should be made.')
    assert(fetchedCalls[0][0].match(/\/search\/issues\?/), 'It should be to the search API')
  })
})

@@ -363,16 +363,75 @@
 educer')
+%0Aconst GitHubAuth = require('../../src/models/github-auth')
 %0A%0Adescri
@@ -816,16 +816,553 @@
 ponent))
+%0A  %7D)%0A%0A  it('does not make request without a token', () =%3E %7B%0A    TestUtils.renderIntoDocument(%0A      %3CReactRedux.Provider store=%7Bstore%7D%3E%0A        %3CApp /%3E%0A      %3C/ReactRedux.Provider%3E%0A    )%0A%0A    const fetchedCalls = fetchMock.calls().matched%0A    assert.equal(0, fetchedCalls.length, 'No fetch calls should be made.')%0A  %7D)%0A%0A  it('fetches user when auth token is set', () =%3E %7B%0A    GitHubAuth.setToken('test-whee')%0A%0A    TestUtils.renderIntoDocument(%0A      %3CReactRedux.Provider store=%7Bstore%7D%3E%0A        %3CApp /%3E%0A      %3C/ReactRedux.Provider%3E%0A    )
 %0A%0A    co
@@ -1529,31 +1529,38 @@
 (/%5C/
+u
 se
-arch%5C/issues%5C?/), 'It
+r/),%0A           'Fetch call
  sho
@@ -1577,14 +1577,12 @@
 the 
+u
 se
-arch
+r
  API

Update App tests