Skip to content

Commit

Permalink
#9 factored appWrapper creation to a helper func.
Browse files Browse the repository at this point in the history
  • Loading branch information
abbr committed Oct 9, 2017
1 parent 9b7d779 commit 3b2cc3b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 20 deletions.
8 changes: 2 additions & 6 deletions test/components/AppTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
// import React from 'react/addons';
// const TestUtils = React.addons.TestUtils;
// import createComponent from 'helpers/shallowRenderHelper'
import { mount } from 'enzyme'
import Main from 'components/app'
import React from 'react'

// describe('MainComponent', () => {
// let MainComponent
Expand All @@ -21,10 +18,9 @@ import React from 'react'
// expect(MainComponent.props.className).to.equal('sp-main-container')
// })
// })

import {appWrapper} from 'helpers/fullRenderHelper'
describe('App', () => {
it('should have its component className as sp-main-container', () => {
const wrapper = mount(<Main />, { attachTo: app })
expect(wrapper.children().is('.sp-main-container')).to.equal(true)
expect(appWrapper.children().is('.sp-main-container')).to.equal(true)
})
})
25 changes: 11 additions & 14 deletions test/components/header/indexTest.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,23 @@
import { mount } from 'enzyme'
import Main from 'components/app'
import React from 'react'
import { appWrapper } from 'helpers/fullRenderHelper'

describe('Header', () => {
it('should add a text widget when clicking insert object button', () => {
const wrapper = mount(<Main />, { attachTo: app })
expect(wrapper.state().deck.getActiveSlide().components.length).to.equal(1)
wrapper
expect(appWrapper.state().deck.getActiveSlide().components.length).to.equal(
1
)
appWrapper
.find(
'.sp-main-container .navbar .container-fluid #sp-navbar-collapse-1 .navbar-left button'
)
.first()
.simulate('click')
expect(wrapper.state().deck.getActiveSlide().components.length).to.equal(2)
expect(appWrapper.state().deck.getActiveSlide().components.length).to.equal(
2
)
expect(
wrapper.state().deck.getActiveSlide().components[1].selected
appWrapper.state().deck.getActiveSlide().components[1].selected
).to.equal(true)
expect(
wrapper.state().deck.getActiveSlide().components[1].x
).to.equal(0)
expect(
wrapper.state().deck.getActiveSlide().components[1].y
).to.equal(0)
expect(appWrapper.state().deck.getActiveSlide().components[1].x).to.equal(0)
expect(appWrapper.state().deck.getActiveSlide().components[1].y).to.equal(0)
})
})
5 changes: 5 additions & 0 deletions test/helpers/fullRenderHelper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { mount } from 'enzyme'
import App from 'components/app'
import React from 'react'

export const appWrapper = mount(<App />, { attachTo: app })

0 comments on commit 3b2cc3b

Please sign in to comment.