Skip to content

Commit b4c921a

Browse files
committed
refactor(classnames, gettestid): remove obsolete helper functions
1 parent 4e543f8 commit b4c921a

File tree

6 files changed

+34
-159
lines changed

6 files changed

+34
-159
lines changed

src/components/Tooltip/Tooltip.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import React, { useState } from 'react';
22
import propTypes from 'prop-types';
33
import styled from 'styled-components';
44

5-
import getTestId from '../common/getTestId';
65
import { shadow } from '../common';
76

87
const Tip = styled.span`
@@ -41,7 +40,6 @@ const Tooltip = React.forwardRef(function Tooltip(props, ref) {
4140
onMouseLeave,
4241
onOpen,
4342
style,
44-
testId,
4543
text,
4644
...otherProps
4745
} = props;
@@ -120,7 +118,7 @@ const Tooltip = React.forwardRef(function Tooltip(props, ref) {
120118

121119
return (
122120
<Wrapper
123-
data-testid={getTestId(testId, 'Wrapper')}
121+
data-testid='tooltip-wrapper'
124122
onBlur={blurCb}
125123
onFocus={focusCb}
126124
onMouseEnter={mouseEnterCb}
@@ -129,7 +127,7 @@ const Tooltip = React.forwardRef(function Tooltip(props, ref) {
129127
>
130128
<Tip
131129
className={className}
132-
data-testid={testId}
130+
data-testid='tooltip'
133131
show={show}
134132
style={style}
135133
ref={ref}
@@ -154,8 +152,7 @@ Tooltip.defaultProps = {
154152
onMouseEnter: undefined,
155153
onMouseLeave: undefined,
156154
onOpen: undefined,
157-
style: {},
158-
testId: undefined
155+
style: {}
159156
};
160157

161158
Tooltip.propTypes = {
@@ -172,7 +169,6 @@ Tooltip.propTypes = {
172169
onMouseLeave: propTypes.func,
173170
onOpen: propTypes.func,
174171
style: propTypes.shape({}),
175-
testId: propTypes.string,
176172
text: propTypes.string.isRequired
177173
};
178174

src/components/Tooltip/Tooltip.spec.js

Lines changed: 31 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ const getProps = (props = {}) => ({
1616
onMouseLeave: jest.fn(),
1717
onOpen: jest.fn(),
1818
style: props.style,
19-
testId: 'tip',
2019
text: 'I am the tooltip'
2120
});
2221

@@ -31,16 +30,16 @@ describe('<Tooltip />', () => {
3130
it('should render wrapper element', () => {
3231
const { getByTestId } = render(renderTooltip(getProps()));
3332

34-
const tipWrapper = getByTestId('tipWrapper');
33+
const wrapper = getByTestId('tooltip-wrapper');
3534

36-
expect(tipWrapper).toBeInTheDocument();
37-
expect(tipWrapper.tagName).toBe('DIV');
35+
expect(wrapper).toBeInTheDocument();
36+
expect(wrapper.tagName).toBe('DIV');
3837
});
3938

4039
it('should render inner tooltip', () => {
4140
const { getByTestId } = render(renderTooltip(getProps()));
4241

43-
const tip = getByTestId('tip');
42+
const tip = getByTestId('tooltip');
4443

4544
expect(tip).toBeInTheDocument();
4645
expect(tip.tagName).toBe('SPAN');
@@ -64,7 +63,7 @@ describe('<Tooltip />', () => {
6463
)
6564
);
6665

67-
const tip = getByTestId('tip');
66+
const tip = getByTestId('tooltip');
6867

6968
expect(tip.className.includes('my-tip')).toBeTruthy();
7069
});
@@ -88,9 +87,9 @@ describe('<Tooltip />', () => {
8887
)
8988
);
9089

91-
const tipWrapper = getByTestId('tipWrapper');
90+
const wrapper = getByTestId('tooltip-wrapper');
9291

93-
fireEvent.focus(tipWrapper);
92+
fireEvent.focus(wrapper);
9493

9594
expect(setTimeout).toHaveBeenCalledWith(expect.any(Function), 5);
9695
});
@@ -104,9 +103,9 @@ describe('<Tooltip />', () => {
104103
)
105104
);
106105

107-
const tipWrapper = getByTestId('tipWrapper');
106+
const wrapper = getByTestId('tooltip-wrapper');
108107

109-
fireEvent.blur(tipWrapper);
108+
fireEvent.blur(wrapper);
110109

111110
expect(setTimeout).toHaveBeenCalledWith(expect.any(Function), 6);
112111
});
@@ -118,10 +117,10 @@ describe('<Tooltip />', () => {
118117

119118
const { getByTestId } = render(renderTooltip(props));
120119

121-
const tip = getByTestId('tip');
122-
const tipWrapper = getByTestId('tipWrapper');
120+
const tip = getByTestId('tooltip');
121+
const wrapper = getByTestId('tooltip-wrapper');
123122

124-
fireEvent.focus(tipWrapper);
123+
fireEvent.focus(wrapper);
125124

126125
await waitForDomChange({ container: tip });
127126

@@ -134,12 +133,12 @@ describe('<Tooltip />', () => {
134133

135134
const { getByTestId } = render(renderTooltip(props));
136135

137-
const tip = getByTestId('tip');
138-
const tipWrapper = getByTestId('tipWrapper');
136+
const tip = getByTestId('tooltip');
137+
const wrapper = getByTestId('tooltip-wrapper');
139138

140-
fireEvent.focus(tipWrapper);
139+
fireEvent.focus(wrapper);
141140
await waitForDomChange({ container: tip });
142-
fireEvent.blur(tipWrapper);
141+
fireEvent.blur(wrapper);
143142
await waitForDomChange({ container: tip });
144143

145144
expect(props.onBlur).toHaveBeenCalled();
@@ -151,10 +150,10 @@ describe('<Tooltip />', () => {
151150

152151
const { getByTestId } = render(renderTooltip(props));
153152

154-
const tip = getByTestId('tip');
155-
const tipWrapper = getByTestId('tipWrapper');
153+
const tip = getByTestId('tooltip');
154+
const wrapper = getByTestId('tooltip-wrapper');
156155

157-
fireEvent.mouseEnter(tipWrapper);
156+
fireEvent.mouseEnter(wrapper);
158157
await waitForDomChange({ container: tip });
159158

160159
expect(props.onMouseEnter).toHaveBeenCalled();
@@ -166,12 +165,12 @@ describe('<Tooltip />', () => {
166165

167166
const { getByTestId } = render(renderTooltip(props));
168167

169-
const tip = getByTestId('tip');
170-
const tipWrapper = getByTestId('tipWrapper');
168+
const tip = getByTestId('tooltip');
169+
const wrapper = getByTestId('tooltip-wrapper');
171170

172-
fireEvent.mouseEnter(tipWrapper);
171+
fireEvent.mouseEnter(wrapper);
173172
await waitForDomChange({ container: tip });
174-
fireEvent.mouseLeave(tipWrapper);
173+
fireEvent.mouseLeave(wrapper);
175174
await waitForDomChange({ container: tip });
176175

177176
expect(props.onMouseLeave).toHaveBeenCalled();
@@ -183,9 +182,9 @@ describe('<Tooltip />', () => {
183182

184183
const { getByTestId } = render(renderTooltip(props));
185184

186-
const tipWrapper = getByTestId('tipWrapper');
185+
const wrapper = getByTestId('tooltip-wrapper');
187186

188-
fireEvent.focus(tipWrapper);
187+
fireEvent.focus(wrapper);
189188

190189
expect(props.onFocus).not.toHaveBeenCalled();
191190
});
@@ -195,9 +194,9 @@ describe('<Tooltip />', () => {
195194

196195
const { getByTestId } = render(renderTooltip(props));
197196

198-
const tipWrapper = getByTestId('tipWrapper');
197+
const wrapper = getByTestId('tooltip-wrapper');
199198

200-
fireEvent.blur(tipWrapper);
199+
fireEvent.blur(wrapper);
201200

202201
expect(props.onBlur).not.toHaveBeenCalled();
203202
});
@@ -207,9 +206,9 @@ describe('<Tooltip />', () => {
207206

208207
const { getByTestId } = render(renderTooltip(props));
209208

210-
const tipWrapper = getByTestId('tipWrapper');
209+
const wrapper = getByTestId('tooltip-wrapper');
211210

212-
fireEvent.mouseEnter(tipWrapper);
211+
fireEvent.mouseEnter(wrapper);
213212

214213
expect(props.onMouseEnter).not.toHaveBeenCalled();
215214
});
@@ -219,9 +218,9 @@ describe('<Tooltip />', () => {
219218

220219
const { getByTestId } = render(renderTooltip(props));
221220

222-
const tipWrapper = getByTestId('tipWrapper');
221+
const wrapper = getByTestId('tooltip-wrapper');
223222

224-
fireEvent.mouseLeave(tipWrapper);
223+
fireEvent.mouseLeave(wrapper);
225224

226225
expect(props.onMouseLeave).not.toHaveBeenCalled();
227226
});

src/components/common/classNames.js

Lines changed: 0 additions & 54 deletions
This file was deleted.

src/components/common/classNames.spec.js

Lines changed: 0 additions & 47 deletions
This file was deleted.

src/components/common/getTestId.js

Lines changed: 0 additions & 4 deletions
This file was deleted.

src/components/common/getTestId.spec.js

Lines changed: 0 additions & 15 deletions
This file was deleted.

0 commit comments

Comments
 (0)