Skip to content
This repository has been archived by the owner on Mar 27, 2021. It is now read-only.

Commit

Permalink
Update enzyme to v3
Browse files Browse the repository at this point in the history
  • Loading branch information
rynobax committed Oct 7, 2018
1 parent 8e0ba8f commit 20258c3
Show file tree
Hide file tree
Showing 6 changed files with 214 additions and 97 deletions.
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
"babel-preset-react": "^6.24.1",
"cross-env": "^5.0.5",
"doctoc": "^1.3.0",
"enzyme": "^2.9.1",
"enzyme": "^3.7.0",
"enzyme-adapter-react-15": "^1.1.1",
"eslint": "^4.6.1",
"eslint-config-prettier": "2.9.0",
"eslint-config-stripe": "^1.0.13",
Expand All @@ -73,5 +74,8 @@
"peerDependencies": {
"react": "^15.5.4 || ^16.0.0-0",
"react-dom": "^15.5.4 || ^16.0.0-0"
},
"jest": {
"setupTestFrameworkScriptFile": "<rootDir>/src/setupTests.js"
}
}
6 changes: 3 additions & 3 deletions src/components/Elements.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe('Elements', () => {
</Elements>,
{context: syncContext}
);
const childContext = wrapper.node.getChildContext();
const childContext = wrapper.instance().getChildContext();
expect(Object.keys(childContext)).toEqual([
'addElementsLoadListener',
'registerElement',
Expand All @@ -52,7 +52,7 @@ describe('Elements', () => {
</Elements>,
{context: syncContext}
);
const childContext = wrapper.node.getChildContext();
const childContext = wrapper.instance().getChildContext();

const mockCallback = jest.fn();
childContext.addElementsLoadListener(mockCallback);
Expand All @@ -76,7 +76,7 @@ describe('Elements', () => {
</Elements>,
{context: asyncContext}
);
const childContext = wrapper.node.getChildContext();
const childContext = wrapper.instance().getChildContext();

const a = new Promise((resolve) =>
childContext.addElementsLoadListener((first) => {
Expand Down
14 changes: 7 additions & 7 deletions src/components/Provider.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ describe('StripeProvider', () => {
<form />
</StripeProvider>
);
const childContext = wrapper.node.getChildContext();
const childContext = wrapper.instance().getChildContext();
expect(childContext).toEqual({stripe: stripeMockResult, tag: 'sync'});
});

Expand All @@ -112,7 +112,7 @@ describe('StripeProvider', () => {
<form />
</StripeProvider>
);
const childContext = wrapper.node.getChildContext();
const childContext = wrapper.instance().getChildContext();
expect(childContext).toEqual({stripe: stripeMockResult, tag: 'sync'});
});

Expand All @@ -122,7 +122,7 @@ describe('StripeProvider', () => {
<form />
</StripeProvider>
);
const childContext = wrapper.node.getChildContext();
const childContext = wrapper.instance().getChildContext();
expect(childContext).toHaveProperty('addStripeLoadListener');
expect(childContext).toHaveProperty('tag', 'async');
});
Expand All @@ -134,7 +134,7 @@ describe('StripeProvider', () => {
</StripeProvider>
);

const childContext = wrapper.node.getChildContext();
const childContext = wrapper.instance().getChildContext();
childContext.addStripeLoadListener((stripe) => {
expect(stripe).toEqual(stripeMockResult);
done();
Expand All @@ -152,7 +152,7 @@ describe('StripeProvider', () => {
<form />
</StripeProvider>
);
let childContext = wrapper.node.getChildContext();
let childContext = wrapper.instance().getChildContext();
const keyOneInstance = childContext.stripe;
expect(keyOneInstance).toBeTruthy();

Expand All @@ -162,7 +162,7 @@ describe('StripeProvider', () => {
<form />
</StripeProvider>
);
childContext = wrapper.node.getChildContext();
childContext = wrapper.instance().getChildContext();
expect(childContext.stripe).toBe(keyOneInstance);

// Create another, but with a different key!
Expand All @@ -171,7 +171,7 @@ describe('StripeProvider', () => {
<form />
</StripeProvider>
);
childContext = wrapper.node.getChildContext();
childContext = wrapper.instance().getChildContext();
expect(childContext.stripe).not.toBe(keyOneInstance);
});

Expand Down
4 changes: 2 additions & 2 deletions src/components/inject.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ describe('injectStripe()', () => {
context,
});

expect(() => wrapper.node.getWrappedInstance()).toThrow(
expect(() => wrapper.instance().getWrappedInstance()).toThrow(
'To access the wrapped instance, the `{withRef: true}` option must be set when calling `injectStripe()`'
);
});
Expand All @@ -289,7 +289,7 @@ describe('injectStripe()', () => {
});

expect(
wrapper.node.getWrappedInstance() instanceof WrappedClassComponent
wrapper.instance().getWrappedInstance() instanceof WrappedClassComponent
).toBe(true);
});
});
Expand Down
5 changes: 5 additions & 0 deletions src/setupTests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// @noflow
import { configure } from 'enzyme';
import Adapter from 'enzyme-adapter-react-15';

configure({ adapter: new Adapter() });
Loading

0 comments on commit 20258c3

Please sign in to comment.