From 12676f6f20116e167725016452da01dce86f6e5e Mon Sep 17 00:00:00 2001 From: "Curtis M. Humphrey, Ph.D" Date: Fri, 26 Feb 2016 13:44:57 -0600 Subject: [PATCH] fix(chai-enzyme): fix issues when using cheerio when chai, add tests to confirm --- build/karma.conf.js | 1 - build/webpack.config.js | 2 +- tests/framework.spec.js | 24 ++++++++++++++++++++++++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/build/karma.conf.js b/build/karma.conf.js index f8e2803..a66d504 100644 --- a/build/karma.conf.js +++ b/build/karma.conf.js @@ -47,7 +47,6 @@ const karmaConfig = { }, externals: { ...webpackConfig.externals, - cheerio: 'window', 'react/lib/ExecutionEnvironment': true, 'react/lib/ReactContext': 'window', 'text-encoding': 'window' diff --git a/build/webpack.config.js b/build/webpack.config.js index 573a21f..a622013 100644 --- a/build/webpack.config.js +++ b/build/webpack.config.js @@ -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: {} } diff --git a/tests/framework.spec.js b/tests/framework.spec.js index ce90fcf..9a6c652 100644 --- a/tests/framework.spec.js +++ b/tests/framework.spec.js @@ -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 ( +
+ + +
+ ) + } +} describe('(Framework) Karma Plugins', function () { it('Should expose "expect" globally.', function () { @@ -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() + expect(wrapper.find('#checked')).to.be.checked() + + wrapper = mount() + expect(wrapper.find('#checked')).to.be.checked() + + wrapper = render() + expect(wrapper.find('#checked')).to.be.checked() + }) })