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

Commit cf6c643

Browse files
committed
Update enzyme to v3
1 parent 338be2d commit cf6c643

File tree

6 files changed

+214
-109
lines changed

6 files changed

+214
-109
lines changed

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@
5050
"babel-preset-react": "^6.24.1",
5151
"cross-env": "^5.0.5",
5252
"doctoc": "^1.3.0",
53-
"enzyme": "^2.9.1",
53+
"enzyme": "^3.7.0",
54+
"enzyme-adapter-react-15": "^1.1.1",
5455
"eslint": "^4.6.1",
5556
"eslint-config-prettier": "2.9.0",
5657
"eslint-config-stripe": "^1.0.13",
@@ -74,5 +75,8 @@
7475
"peerDependencies": {
7576
"react": "^15.5.4 || ^16.0.0-0",
7677
"react-dom": "^15.5.4 || ^16.0.0-0"
78+
},
79+
"jest": {
80+
"setupTestFrameworkScriptFile": "<rootDir>/src/setupTests.js"
7781
}
7882
}

src/components/Elements.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ describe('Elements', () => {
3232
</Elements>,
3333
{context: syncContext}
3434
);
35-
const childContext = wrapper.node.getChildContext();
35+
const childContext = wrapper.instance().getChildContext();
3636
expect(Object.keys(childContext)).toEqual([
3737
'addElementsLoadListener',
3838
'registerElement',
@@ -52,7 +52,7 @@ describe('Elements', () => {
5252
</Elements>,
5353
{context: syncContext}
5454
);
55-
const childContext = wrapper.node.getChildContext();
55+
const childContext = wrapper.instance().getChildContext();
5656

5757
const mockCallback = jest.fn();
5858
childContext.addElementsLoadListener(mockCallback);
@@ -76,7 +76,7 @@ describe('Elements', () => {
7676
</Elements>,
7777
{context: asyncContext}
7878
);
79-
const childContext = wrapper.node.getChildContext();
79+
const childContext = wrapper.instance().getChildContext();
8080

8181
const a = new Promise((resolve) =>
8282
childContext.addElementsLoadListener((first) => {

src/components/Provider.test.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ describe('StripeProvider', () => {
102102
<form />
103103
</StripeProvider>
104104
);
105-
const childContext = wrapper.node.getChildContext();
105+
const childContext = wrapper.instance().getChildContext();
106106
expect(childContext).toEqual({stripe: stripeMockResult, tag: 'sync'});
107107
});
108108

@@ -112,7 +112,7 @@ describe('StripeProvider', () => {
112112
<form />
113113
</StripeProvider>
114114
);
115-
const childContext = wrapper.node.getChildContext();
115+
const childContext = wrapper.instance().getChildContext();
116116
expect(childContext).toEqual({stripe: stripeMockResult, tag: 'sync'});
117117
});
118118

@@ -122,7 +122,7 @@ describe('StripeProvider', () => {
122122
<form />
123123
</StripeProvider>
124124
);
125-
const childContext = wrapper.node.getChildContext();
125+
const childContext = wrapper.instance().getChildContext();
126126
expect(childContext).toHaveProperty('addStripeLoadListener');
127127
expect(childContext).toHaveProperty('tag', 'async');
128128
});
@@ -134,7 +134,7 @@ describe('StripeProvider', () => {
134134
</StripeProvider>
135135
);
136136

137-
const childContext = wrapper.node.getChildContext();
137+
const childContext = wrapper.instance().getChildContext();
138138
childContext.addStripeLoadListener((stripe) => {
139139
expect(stripe).toEqual(stripeMockResult);
140140
done();
@@ -152,7 +152,7 @@ describe('StripeProvider', () => {
152152
<form />
153153
</StripeProvider>
154154
);
155-
let childContext = wrapper.node.getChildContext();
155+
let childContext = wrapper.instance().getChildContext();
156156
const keyOneInstance = childContext.stripe;
157157
expect(keyOneInstance).toBeTruthy();
158158

@@ -162,7 +162,7 @@ describe('StripeProvider', () => {
162162
<form />
163163
</StripeProvider>
164164
);
165-
childContext = wrapper.node.getChildContext();
165+
childContext = wrapper.instance().getChildContext();
166166
expect(childContext.stripe).toBe(keyOneInstance);
167167

168168
// Create another, but with a different key!
@@ -171,7 +171,7 @@ describe('StripeProvider', () => {
171171
<form />
172172
</StripeProvider>
173173
);
174-
childContext = wrapper.node.getChildContext();
174+
childContext = wrapper.instance().getChildContext();
175175
expect(childContext.stripe).not.toBe(keyOneInstance);
176176
});
177177

src/components/inject.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ describe('injectStripe()', () => {
267267
context,
268268
});
269269

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

291291
expect(
292-
wrapper.node.getWrappedInstance() instanceof WrappedClassComponent
292+
wrapper.instance().getWrappedInstance() instanceof WrappedClassComponent
293293
).toBe(true);
294294
});
295295
});

src/setupTests.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// @noflow
2+
import { configure } from 'enzyme';
3+
import Adapter from 'enzyme-adapter-react-15';
4+
5+
configure({ adapter: new Adapter() });

0 commit comments

Comments
 (0)