require('../support')
import ScrollListener from '../../../src/components/ScrollListener'
import { renderIntoDocument } from 'react-addons-test-utils'
import { createElement, spyify, unspyify } from '../../support/helpers'

describe('ScrollListener', () => {
  var onBottom

  beforeEach(() => {
    onBottom = spy(() => {})
    spyify(window, 'addEventListener')
    const component = createElement(ScrollListener, {onBottom})
    renderIntoDocument(component)
    document.body.scrollHeight = 5000
    window.innerHeight = 400
  })

  afterEach(() => {
    unspyify(window, 'addEventListener')
  })

  it('does not fire onBottom when the window is not scrolled to the bottom', () => {
    window.pageYOffset = 4349
    window.dispatchEvent(new window.UIEvent('scroll'))
    expect(onBottom).not.to.have.been.called()
  })

  it('fires onBottom when the window is scrolled to the bottom', () => {
    window.pageYOffset = 4351
    window.dispatchEvent(new window.UIEvent('scroll'))
    expect(onBottom).to.have.been.called()
  })
})

@@ -96,83 +96,64 @@
 t %7B 
-renderIntoDocument %7D from 'react-addons-test-utils'%0Aimport %7B createElement,
+mount %7D from 'enzyme'%0Aimport React from 'react'%0Aimport %7B
  spy
@@ -346,40 +346,15 @@
     
-const component = createEleme
+mou
 nt(
+%3C
 Scro
@@ -367,19 +367,17 @@
 ener
-, %7B
+ 
 onBottom
 %7D)%0A 
@@ -376,43 +376,21 @@
 ttom
-%7D)%0A    renderIntoDocument(component
+=%7BonBottom%7D/%3E
 )%0A  

update a test to use enzyme