Skip to content

Commit

Permalink
fixed reshow-flux unit test with enzyme Shallow Rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
HillLiu committed Sep 29, 2017
1 parent fe6acb0 commit 09a3b6c
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 10 deletions.
1 change: 1 addition & 0 deletions packages/reshow-flux/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"babel-preset-stage-0": "^6.5.0",
"chai": "*",
"enzyme": "*",
"enzyme-adapter-react-16": "*",
"mocha": "*",
"react": "*",
"react-dom": "*",
Expand Down
10 changes: 8 additions & 2 deletions packages/reshow-flux/tests/src/ContainerTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ import {
Container
} from '../../src/index';
import {expect} from 'chai';
import {shallow} from 'enzyme';
import {shallow, configure} from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
configure({ adapter: new Adapter() });



describe('Test Container', ()=>{
class FakeStore extends ReduceStore
Expand Down Expand Up @@ -81,6 +85,7 @@ describe('Test Container', ()=>{
const html = shallow(vDom);
expect(calculateTimes).to.equal(1);
dispatcher.dispatch({aaa: 'Hello dispatcher!'});
html.update();
expect(calculateTimes).to.equal(2);
expect(html.html()).to.equal('<div>Hello dispatcher!</div>');
html.unmount();
Expand Down Expand Up @@ -131,7 +136,7 @@ describe('Test Container', ()=>{
render()
{
let foo = null;
if (this.state) {
if (this.state && this.state.foo) {
foo = this.state.foo;
}
return <FakeContainer foo={foo} />;
Expand All @@ -145,6 +150,7 @@ describe('Test Container', ()=>{
expect(getStoresProps).to.deep.equal({ foo: null });
expect(calculateStateProps).to.deep.equal({ foo: null });
changeFoo('bar');
html.update();
expect(html.html()).to.equal('<div>bar</div>');
expect(getStoresProps).to.deep.equal({ foo: 'bar' });
expect(calculateStateProps).to.deep.equal({ foo: 'bar' });
Expand Down
6 changes: 5 additions & 1 deletion packages/reshow-flux/tests/src/FunctionalContainerTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import {
FunctionalContainer
} from '../../src/index';
import {expect} from 'chai';
import {shallow} from 'enzyme';
import {shallow, configure} from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
configure({ adapter: new Adapter() });

describe('Test Functional Container', ()=>{
class FakeStore extends ReduceStore
Expand All @@ -24,6 +26,7 @@ describe('Test Functional Container', ()=>{
}
let dispatcher = new Dispatcher();
let store = new FakeStore(dispatcher);

it('could register with store', ()=>{
const FakeComponent = ({aaa}) =>
<div>{aaa}</div>;
Expand All @@ -40,6 +43,7 @@ describe('Test Functional Container', ()=>{
let vDom = <FakeContainer />;
const html = shallow(vDom);
dispatcher.dispatch({aaa: 'Hello dispatcher!'});
html.update();
expect(html.html()).to.equal('<div>Hello dispatcher!</div>');
});
});
32 changes: 25 additions & 7 deletions packages/reshow-flux/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
resolved "https://registry.yarnpkg.com/@types/node/-/node-6.0.88.tgz#f618f11a944f6a18d92b5c472028728a3e3d4b66"

abbrev@1:
version "1.1.0"
resolved "https://registry.yarnpkg.com/abbrev/-/abbrev-1.1.0.tgz#d0554c2256636e2f56e7c2e5ad183f859428d81f"
version "1.1.1"
resolved "https://registry.yarnpkg.com/abbrev/-/abbrev-1.1.1.tgz#f8f2c887ad10bf67f634f005b6987fed3179aac8"

ajv@^4.9.1:
version "4.11.8"
Expand Down Expand Up @@ -884,8 +884,8 @@ browserslist@^2.1.2:
electron-to-chromium "^1.3.18"

caniuse-lite@^1.0.30000718:
version "1.0.30000738"
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30000738.tgz#1820c3c9adb9a117e311a5bdca1d25bc34288eba"
version "1.0.30000739"
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30000739.tgz#9ee8c7016f5c522dbb0c0863d55c61efb453ae95"

caseless@~0.12.0:
version "0.12.0"
Expand Down Expand Up @@ -1112,8 +1112,8 @@ ecc-jsbn@~0.1.1:
jsbn "~0.1.0"

electron-to-chromium@^1.3.18:
version "1.3.22"
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.22.tgz#4322d52c151406e3eaef74ad02676883e8416418"
version "1.3.23"
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.23.tgz#e6668ab18cb69afb8f577c8a9fc23d002788be74"

encoding@^0.1.11:
version "0.1.12"
Expand All @@ -1125,6 +1125,24 @@ entities@^1.1.1, entities@~1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/entities/-/entities-1.1.1.tgz#6e5c2d0a5621b5dadaecef80b90edfb5cd7772f0"

enzyme-adapter-react-16@*:
version "1.0.0"
resolved "https://registry.yarnpkg.com/enzyme-adapter-react-16/-/enzyme-adapter-react-16-1.0.0.tgz#e7edd5536743818dcbef336d40d7da59b3a7db8e"
dependencies:
enzyme-adapter-utils "^1.0.0"
lodash "^4.17.4"
object.assign "^4.0.4"
object.values "^1.0.4"
prop-types "^15.5.10"

enzyme-adapter-utils@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/enzyme-adapter-utils/-/enzyme-adapter-utils-1.0.0.tgz#e94eee63da9a798d498adb1162a2102ed04fc638"
dependencies:
lodash "^4.17.4"
object.assign "^4.0.4"
prop-types "^15.5.10"

enzyme@*:
version "3.0.0"
resolved "https://registry.yarnpkg.com/enzyme/-/enzyme-3.0.0.tgz#94ce364254dc654c4e619b25eecc644bf6481de7"
Expand Down Expand Up @@ -1975,7 +1993,7 @@ promise@^7.1.1:
dependencies:
asap "~2.0.3"

prop-types@^15.6.0:
prop-types@^15.5.10, prop-types@^15.6.0:
version "15.6.0"
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.6.0.tgz#ceaf083022fc46b4a35f69e13ef75aed0d639856"
dependencies:
Expand Down

0 comments on commit 09a3b6c

Please sign in to comment.