Skip to content

Commit c08095a

Browse files
committed
Removed enzyme. Fixed prettier parentheses rule.
1 parent 3f8c41c commit c08095a

File tree

4 files changed

+18
-25
lines changed

4 files changed

+18
-25
lines changed

.prettierrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"singleQuote": true,
33
"trailingComma": "all",
4-
"printWidth": 120
4+
"printWidth": 120,
5+
"arrowParens": "always"
56
}

package.json

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,8 @@
3737
},
3838
"homepage": "https://github.com/launchdarkly/react-client-sdk",
3939
"devDependencies": {
40-
"@testing-library/jest-dom": "^5.16.1",
41-
"@testing-library/react": "^12.1.2",
42-
"@types/enzyme": "^3.10.3",
40+
"@testing-library/jest-dom": "^5.16.4",
41+
"@testing-library/react": "^13.0.1",
4342
"@types/hoist-non-react-statics": "^3.3.1",
4443
"@types/jest": "^27.0.3",
4544
"@types/lodash.camelcase": "^4.3.6",
@@ -48,8 +47,6 @@
4847
"@types/react-dom": "^18.0.0",
4948
"@types/react-test-renderer": "^17.0.1",
5049
"@types/uuid": "^3.4.5",
51-
"enzyme": "^3.10.0",
52-
"enzyme-adapter-react-16": "^1.14.0",
5350
"jest": "^27.4.4",
5451
"jest-environment-jsdom-global": "^3.0.0",
5552
"jest-junit": "^13.0.0",

setupTests.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1 @@
1-
const enzyme = require('enzyme');
2-
const Adapter = require('enzyme-adapter-react-16');
31
require('@testing-library/jest-dom/extend-expect');
4-
5-
enzyme.configure({ adapter: new Adapter() });

src/provider.test.tsx

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
jest.mock('./initLDClient', () => jest.fn());
22
jest.mock('./context', () => ({ Provider: 'Provider' }));
33

4-
import * as React from 'react';
4+
import React, { Component } from 'react';
55
import { create } from 'react-test-renderer';
6-
import { shallow } from 'enzyme';
76
import { LDClient, LDFlagChangeset, LDFlagSet, LDOptions, LDUser } from 'launchdarkly-js-client-sdk';
87
import initLDClient from './initLDClient';
98
import { LDReactOptions, EnhancedComponent, defaultReactOptions, ProviderConfig } from './types';
@@ -40,7 +39,7 @@ describe('LDProvider', () => {
4039
<App />
4140
</LDProvider>
4241
);
43-
const component = create(LaunchDarklyApp);
42+
const component = create(LaunchDarklyApp).toTree()?.instance as Component;
4443
expect(component).toMatchSnapshot();
4544
});
4645

@@ -129,8 +128,8 @@ describe('LDProvider', () => {
129128
<App />
130129
</LDProvider>
131130
);
132-
const component = shallow(LaunchDarklyApp, { disableLifecycleMethods: true });
133-
const initialState = component.state() as HocState;
131+
const component = create(LaunchDarklyApp).toTree()?.instance as Component;
132+
const initialState = component.state as HocState;
134133

135134
expect(initialState.flags).toEqual({});
136135
});
@@ -154,8 +153,8 @@ describe('LDProvider', () => {
154153
<App />
155154
</LDProvider>
156155
);
157-
const component = shallow(LaunchDarklyApp, { disableLifecycleMethods: true });
158-
const initialState = component.state() as HocState;
156+
const component = create(LaunchDarklyApp).toTree()?.instance as Component;
157+
const initialState = component.state as HocState;
159158

160159
expect(mockInitLDClient).not.toHaveBeenCalled();
161160
expect(initialState.flags).toEqual({ testFlag: true, anotherTestFlag: false });
@@ -178,8 +177,8 @@ describe('LDProvider', () => {
178177
<App />
179178
</LDProvider>
180179
);
181-
const component = shallow(LaunchDarklyApp, { disableLifecycleMethods: true });
182-
const initialState = component.state() as HocState;
180+
const component = create(LaunchDarklyApp).toTree()?.instance as Component;
181+
const initialState = component.state as HocState;
183182

184183
expect(mockInitLDClient).not.toHaveBeenCalled();
185184
expect(initialState.flags).toEqual({ 'test-flag': true, 'another-test-flag': false });
@@ -200,8 +199,8 @@ describe('LDProvider', () => {
200199
<App />
201200
</LDProvider>
202201
);
203-
const component = shallow(LaunchDarklyApp, { disableLifecycleMethods: true });
204-
const initialState = component.state() as HocState;
202+
const component = create(LaunchDarklyApp).toTree()?.instance as Component;
203+
const initialState = component.state as HocState;
205204

206205
expect(mockInitLDClient).not.toHaveBeenCalled();
207206
expect(initialState.flags).toEqual({ testFlag: true, anotherTestFlag: false });
@@ -221,8 +220,8 @@ describe('LDProvider', () => {
221220
<App />
222221
</LDProvider>
223222
);
224-
const component = shallow(LaunchDarklyApp, { disableLifecycleMethods: true });
225-
const initialState = component.state() as HocState;
223+
const component = create(LaunchDarklyApp).toTree()?.instance as Component;
224+
const initialState = component.state as HocState;
226225

227226
expect(mockInitLDClient).not.toHaveBeenCalled();
228227
expect(initialState.flags).toEqual({ testFlag: true, anotherTestFlag: false });
@@ -239,8 +238,8 @@ describe('LDProvider', () => {
239238
<App />
240239
</LDProvider>
241240
);
242-
const component = shallow(LaunchDarklyApp, { disableLifecycleMethods: true });
243-
const initialState = component.state() as HocState;
241+
const component = create(LaunchDarklyApp).toTree()?.instance as Component;
242+
const initialState = component.state as HocState;
244243

245244
expect(mockInitLDClient).not.toHaveBeenCalled();
246245
expect(initialState.flags).toEqual({});

0 commit comments

Comments
 (0)