Skip to content

Commit

Permalink
fix(chai-enzyme): fix issues when using cheerio when chai, add tests …
Browse files Browse the repository at this point in the history
…to confirm
  • Loading branch information
Curtis M. Humphrey, Ph.D authored and David Zukowski committed Feb 27, 2016
1 parent e7b49ac commit 12676f6
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
1 change: 0 additions & 1 deletion build/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ const karmaConfig = {
},
externals: {
...webpackConfig.externals,
cheerio: 'window',
'react/lib/ExecutionEnvironment': true,
'react/lib/ReactContext': 'window',
'text-encoding': 'window'
Expand Down
2 changes: 1 addition & 1 deletion build/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const webpackConfig = {
devtool: config.compiler_devtool,
resolve: {
root: paths.base(config.dir_client),
extensions: ['', '.js', '.jsx']
extensions: ['', '.js', '.jsx', '.json']
},
module: {}
}
Expand Down
24 changes: 24 additions & 0 deletions tests/framework.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
import assert from 'assert'
import React from 'react'
import {mount, render, shallow} from 'enzyme'

class Fixture extends React.Component {
render () {
return (
<div>
<input id='checked' defaultChecked />
<input id='not' defaultChecked={false} />
</div>
)
}
}

describe('(Framework) Karma Plugins', function () {
it('Should expose "expect" globally.', function () {
Expand All @@ -18,4 +31,15 @@ describe('(Framework) Karma Plugins', function () {
expect(fail).to.not.be.fulfilled
])
})

it('should have chai-enzyme working', function() {
let wrapper = shallow(<Fixture />)
expect(wrapper.find('#checked')).to.be.checked()

wrapper = mount(<Fixture />)
expect(wrapper.find('#checked')).to.be.checked()

wrapper = render(<Fixture />)
expect(wrapper.find('#checked')).to.be.checked()
})
})

0 comments on commit 12676f6

Please sign in to comment.