bright-components 10.2.7 → 10.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/circle.yml +1 -2
- package/deploy.sh +6 -0
- package/dist/components/DayPicker/NewDayPicker/index.js +0 -28
- package/dist/components/DayPicker/index.js +2 -20
- package/dist/components/DayPickerPanel/HeaderDayPickerPanel/index.js +1 -18
- package/dist/components/DayPickerPanel/HeaderMonthPanel/index.js +0 -14
- package/dist/components/DayPickerPanel/HeaderYearPanel/index.js +2 -15
- package/dist/components/DayPickerPanel/Shortcuts/index.js +2 -16
- package/dist/components/DayPickerPanel/index.js +2 -74
- package/dist/components/EmployeeCard/index.js +1 -14
- package/dist/components/EmployeePicker/FilterBar/index.js +1 -28
- package/dist/components/EmployeePicker/Group/index.js +1 -41
- package/dist/components/FilterRadioGroup/index.js +2 -14
- package/dist/components/Form/index.js +4 -47
- package/dist/components/Modal/index.js +1 -23
- package/dist/components/RadioBlock/index.js +10 -41
- package/dist/components/Snackbar/index.js +1 -17
- package/dist/components/Time/OverlayBase/index.js +2 -25
- package/dist/components/Time/TimePicker/TimeOverlay/index.js +3 -26
- package/dist/components/TimePicker/Time/TimeOverlay/index.js +1 -58
- package/dist/setupTests.js +0 -7
- package/package.json +5 -7
- package/src/components/DayPicker/NewDayPicker/index.js +0 -21
- package/src/components/DayPicker/index.js +1 -16
- package/src/components/DayPicker/test.js +0 -85
- package/src/components/DayPickerPanel/HeaderDayPickerPanel/index.js +2 -22
- package/src/components/DayPickerPanel/HeaderDayPickerPanel/test.js +0 -34
- package/src/components/DayPickerPanel/HeaderMonthPanel/index.js +0 -10
- package/src/components/DayPickerPanel/HeaderMonthPanel/test.js +0 -25
- package/src/components/DayPickerPanel/HeaderYearPanel/index.js +3 -12
- package/src/components/DayPickerPanel/HeaderYearPanel/test.js +0 -17
- package/src/components/DayPickerPanel/Shortcuts/index.js +3 -17
- package/src/components/DayPickerPanel/Shortcuts/test.js +0 -39
- package/src/components/DayPickerPanel/index.js +1 -69
- package/src/components/DayPickerPanel/test.js +0 -177
- package/src/components/EmployeeCard/index.js +1 -15
- package/src/components/EmployeeCard/test.js +0 -20
- package/src/components/EmployeePicker/FilterBar/index.js +2 -26
- package/src/components/EmployeePicker/FilterBar/test.js +0 -29
- package/src/components/EmployeePicker/Group/index.js +1 -42
- package/src/components/EmployeePicker/Group/test.js +0 -21
- package/src/components/FilterRadioGroup/index.js +2 -14
- package/src/components/FilterRadioGroup/test.js +0 -13
- package/src/components/Form/index.js +1 -49
- package/src/components/Form/test.js +0 -73
- package/src/components/Modal/index.js +1 -22
- package/src/components/Modal/test.js +9 -9
- package/src/components/RadioBlock/index.js +14 -33
- package/src/components/RadioBlock/test.js +35 -155
- package/src/components/ResponsiveTabs/test.js +49 -86
- package/src/components/Snackbar/index.js +1 -16
- package/src/components/Time/OverlayBase/index.js +3 -21
- package/src/components/Time/OverlayBase/test.js +0 -50
- package/src/components/Time/TimePicker/TimeOverlay/index.js +4 -30
- package/src/components/Time/TimePicker/TimeOverlay/test.js +0 -24
- package/src/components/TimePicker/DayPart/test.js +1 -1
- package/src/components/TimePicker/Time/TimeOverlay/index.js +2 -50
- package/src/components/TimePicker/Time/TimeOverlay/test.js +1 -220
- package/src/index.js +1 -1
- package/src/setupTests.js +0 -2
- package/dist/components/TimePicker/utils/PickerGA/index.js +0 -24
- package/dist/utils/trackForm/index.js +0 -48
- package/src/components/TimePicker/utils/PickerGA/index.js +0 -6
- package/src/components/TimePicker/utils/PickerGA/test.js +0 -29
- package/src/utils/trackForm/index.js +0 -36
- package/src/utils/trackForm/test.js +0 -110
@@ -1,7 +1,6 @@
|
|
1
1
|
import React, { useCallback, useEffect, forwardRef } from 'react';
|
2
|
-
import { arrayOf, func, number, oneOfType, shape
|
2
|
+
import { arrayOf, func, number, oneOfType, shape } from 'prop-types';
|
3
3
|
import styled from 'styled-components';
|
4
|
-
import { event } from 'react-ga';
|
5
4
|
import Colors from 'constants/colors';
|
6
5
|
import Spacing from 'constants/spacing';
|
7
6
|
import Zindex from 'constants/z-index';
|
@@ -74,7 +73,6 @@ const OverlayBase = forwardRef(
|
|
74
73
|
onHide,
|
75
74
|
hourIncrements,
|
76
75
|
minuteIncrements,
|
77
|
-
GA,
|
78
76
|
onIncrement,
|
79
77
|
onChange,
|
80
78
|
onApply
|
@@ -130,12 +128,6 @@ const OverlayBase = forwardRef(
|
|
130
128
|
type="button"
|
131
129
|
onClick={() => {
|
132
130
|
onHide();
|
133
|
-
if (GA) {
|
134
|
-
event({
|
135
|
-
category: GA.category,
|
136
|
-
action: `${GA.action} (Cancel)`
|
137
|
-
});
|
138
|
-
}
|
139
131
|
}}
|
140
132
|
>
|
141
133
|
Cancel
|
@@ -145,14 +137,6 @@ const OverlayBase = forwardRef(
|
|
145
137
|
onClick={() => {
|
146
138
|
onApply(value);
|
147
139
|
onHide();
|
148
|
-
|
149
|
-
if (GA) {
|
150
|
-
event({
|
151
|
-
category: GA.category,
|
152
|
-
action: `${GA.action} (Apply)`,
|
153
|
-
label: `${hours} hrs ${minutes} mins`
|
154
|
-
});
|
155
|
-
}
|
156
140
|
}}
|
157
141
|
data-e2e="time-apply"
|
158
142
|
>
|
@@ -174,14 +158,12 @@ OverlayBase.propTypes = {
|
|
174
158
|
onHide: func.isRequired,
|
175
159
|
onIncrement: func.isRequired,
|
176
160
|
minuteIncrements: oneOfType([arrayOf(number), number]),
|
177
|
-
hourIncrements: number
|
178
|
-
GA: shape({ category: string, action: string })
|
161
|
+
hourIncrements: number
|
179
162
|
};
|
180
163
|
|
181
164
|
OverlayBase.defaultProps = {
|
182
165
|
minuteIncrements: 1,
|
183
|
-
hourIncrements: 1
|
184
|
-
GA: undefined
|
166
|
+
hourIncrements: 1
|
185
167
|
};
|
186
168
|
|
187
169
|
export default OverlayBase;
|
@@ -1,17 +1,8 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
import { render, fireEvent } from '@testing-library/react';
|
3
|
-
import { event } from 'react-ga';
|
4
3
|
import OverlayBase from '.';
|
5
4
|
|
6
|
-
jest.mock('react-ga');
|
7
|
-
|
8
5
|
describe('<OverlayBase />', () => {
|
9
|
-
const ga = { category: 'Cat', action: 'Act' };
|
10
|
-
|
11
|
-
beforeEach(() => {
|
12
|
-
event.mockClear();
|
13
|
-
});
|
14
|
-
|
15
6
|
it('should render input boxes', () => {
|
16
7
|
const { queryAllByRole } = render(
|
17
8
|
<OverlayBase
|
@@ -107,26 +98,6 @@ describe('<OverlayBase />', () => {
|
|
107
98
|
expect(onHide).toHaveBeenCalled();
|
108
99
|
});
|
109
100
|
|
110
|
-
it('should log a tracking event when apply is clicked', () => {
|
111
|
-
const { getByText } = render(
|
112
|
-
<OverlayBase
|
113
|
-
value={{ hours: 12, minutes: 45 }}
|
114
|
-
onChange={() => {}}
|
115
|
-
onApply={() => {}}
|
116
|
-
onHide={() => {}}
|
117
|
-
onIncrement={() => {}}
|
118
|
-
GA={ga}
|
119
|
-
/>
|
120
|
-
);
|
121
|
-
|
122
|
-
fireEvent.click(getByText('Apply'));
|
123
|
-
expect(event).toHaveBeenCalledWith({
|
124
|
-
category: ga.category,
|
125
|
-
action: `${ga.action} (Apply)`,
|
126
|
-
label: '12 hrs 45 mins'
|
127
|
-
});
|
128
|
-
});
|
129
|
-
|
130
101
|
it('should hide when cancelled', () => {
|
131
102
|
const onChange = jest.fn();
|
132
103
|
const onHide = jest.fn();
|
@@ -145,25 +116,4 @@ describe('<OverlayBase />', () => {
|
|
145
116
|
expect(onChange).not.toHaveBeenCalled();
|
146
117
|
expect(onHide).toHaveBeenCalled();
|
147
118
|
});
|
148
|
-
|
149
|
-
it('should log a tracking event when cancelled', () => {
|
150
|
-
const onChange = jest.fn();
|
151
|
-
const onHide = jest.fn();
|
152
|
-
const { getByText } = render(
|
153
|
-
<OverlayBase
|
154
|
-
value={{ hours: 12, minutes: 45 }}
|
155
|
-
onChange={onChange}
|
156
|
-
onIncrement={() => {}}
|
157
|
-
onApply={() => {}}
|
158
|
-
onHide={onHide}
|
159
|
-
GA={ga}
|
160
|
-
/>
|
161
|
-
);
|
162
|
-
|
163
|
-
fireEvent.click(getByText('Cancel'));
|
164
|
-
expect(event).toHaveBeenCalledWith({
|
165
|
-
category: ga.category,
|
166
|
-
action: `${ga.action} (Cancel)`
|
167
|
-
});
|
168
|
-
});
|
169
119
|
});
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import React, { useState, forwardRef } from 'react';
|
2
|
-
import { arrayOf, func, number, oneOfType, shape
|
2
|
+
import { arrayOf, func, number, oneOfType, shape } from 'prop-types';
|
3
3
|
import millisecondsToDuration from 'utils/time/millisecondsToDuration';
|
4
4
|
import styled from 'styled-components';
|
5
5
|
import Spacing from 'constants/spacing';
|
@@ -8,7 +8,6 @@ import Variables from 'constants/vars';
|
|
8
8
|
import Colors from 'constants/colors';
|
9
9
|
import getBoundedValue from 'utils/numbers/getBoundedValue';
|
10
10
|
import OutlineButton from 'components/Button/OutlineButton';
|
11
|
-
import { event } from 'react-ga';
|
12
11
|
import BrandButton from 'components/Button/BrandButton';
|
13
12
|
import roundTo from 'utils/roundTo';
|
14
13
|
import durationToMilliseconds from 'utils/time/durationToMilliseconds';
|
@@ -87,16 +86,7 @@ const convertHours = hour => {
|
|
87
86
|
|
88
87
|
const TimeOverlay = forwardRef(
|
89
88
|
(
|
90
|
-
{
|
91
|
-
value,
|
92
|
-
onChange,
|
93
|
-
onHide,
|
94
|
-
hourIncrements,
|
95
|
-
minuteIncrements,
|
96
|
-
min,
|
97
|
-
max,
|
98
|
-
GA
|
99
|
-
},
|
89
|
+
{ value, onChange, onHide, hourIncrements, minuteIncrements, min, max },
|
100
90
|
ref
|
101
91
|
) => {
|
102
92
|
const sanitizeValue = unsanitizedValue =>
|
@@ -156,12 +146,6 @@ const TimeOverlay = forwardRef(
|
|
156
146
|
type="button"
|
157
147
|
onClick={() => {
|
158
148
|
onHide();
|
159
|
-
if (GA) {
|
160
|
-
event({
|
161
|
-
category: GA.category,
|
162
|
-
action: `${GA.action} (Cancel)`
|
163
|
-
});
|
164
|
-
}
|
165
149
|
}}
|
166
150
|
>
|
167
151
|
Cancel
|
@@ -180,14 +164,6 @@ const TimeOverlay = forwardRef(
|
|
180
164
|
onClick={() => {
|
181
165
|
onChange({ hours, minutes });
|
182
166
|
onHide();
|
183
|
-
|
184
|
-
if (GA) {
|
185
|
-
event({
|
186
|
-
category: GA.category,
|
187
|
-
action: `${GA.action} (Apply)`,
|
188
|
-
label: `${hours} hrs ${minutes} mins`
|
189
|
-
});
|
190
|
-
}
|
191
167
|
}}
|
192
168
|
data-e2e="time-apply"
|
193
169
|
>
|
@@ -211,14 +187,12 @@ TimeOverlay.propTypes = {
|
|
211
187
|
onChange: func.isRequired,
|
212
188
|
onHide: func.isRequired,
|
213
189
|
minuteIncrements: oneOfType([arrayOf(number), number]),
|
214
|
-
hourIncrements: number
|
215
|
-
GA: shape({ category: string, action: string })
|
190
|
+
hourIncrements: number
|
216
191
|
};
|
217
192
|
|
218
193
|
TimeOverlay.defaultProps = {
|
219
194
|
minuteIncrements: 1,
|
220
|
-
hourIncrements: 1
|
221
|
-
GA: undefined
|
195
|
+
hourIncrements: 1
|
222
196
|
};
|
223
197
|
|
224
198
|
export default TimeOverlay;
|
@@ -1,17 +1,8 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
import { render, fireEvent, within } from '@testing-library/react';
|
3
|
-
import { event } from 'react-ga';
|
4
3
|
import TimeOverlay from '.';
|
5
4
|
|
6
|
-
jest.mock('react-ga');
|
7
|
-
|
8
|
-
const gaSpec = { category: 'Cat', action: 'Action' };
|
9
|
-
|
10
5
|
describe('<TimeOverlay />', () => {
|
11
|
-
beforeEach(() => {
|
12
|
-
event.mockReset();
|
13
|
-
});
|
14
|
-
|
15
6
|
it('should call onChange with the new value when apply is clicked', () => {
|
16
7
|
const onChange = jest.fn();
|
17
8
|
const { getAllByRole, getByText } = render(
|
@@ -96,7 +87,6 @@ describe('<TimeOverlay />', () => {
|
|
96
87
|
value={{ hours: 3, minutes: 0 }}
|
97
88
|
min={{ hours: 0, minutes: 0 }}
|
98
89
|
max={{ hours: 23, minutes: 59 }}
|
99
|
-
GA={gaSpec}
|
100
90
|
/>
|
101
91
|
);
|
102
92
|
|
@@ -105,7 +95,6 @@ describe('<TimeOverlay />', () => {
|
|
105
95
|
|
106
96
|
expect(onHide).not.toHaveBeenCalled();
|
107
97
|
expect(onChange).not.toHaveBeenCalled();
|
108
|
-
expect(event).not.toHaveBeenCalled();
|
109
98
|
|
110
99
|
fireEvent.click(getByText('Apply'));
|
111
100
|
|
@@ -113,11 +102,6 @@ describe('<TimeOverlay />', () => {
|
|
113
102
|
expect.objectContaining({ hours: 5, minutes: 0 })
|
114
103
|
);
|
115
104
|
expect(onHide).toHaveBeenCalledTimes(1);
|
116
|
-
expect(event).toHaveBeenCalledWith({
|
117
|
-
category: gaSpec.category,
|
118
|
-
action: `${gaSpec.action} (Apply)`,
|
119
|
-
label: '5 hrs 0 mins'
|
120
|
-
});
|
121
105
|
});
|
122
106
|
|
123
107
|
it('should hide the panel and not apply the value when cancel is clicked', () => {
|
@@ -130,22 +114,15 @@ describe('<TimeOverlay />', () => {
|
|
130
114
|
value={{ hours: 3, minutes: 0 }}
|
131
115
|
min={{ hours: 0, minutes: 0 }}
|
132
116
|
max={{ hours: 23, minutes: 59 }}
|
133
|
-
GA={gaSpec}
|
134
117
|
/>
|
135
118
|
);
|
136
119
|
|
137
120
|
expect(onHide).not.toHaveBeenCalled();
|
138
121
|
expect(onChange).not.toHaveBeenCalled();
|
139
|
-
expect(event).not.toHaveBeenCalled();
|
140
122
|
|
141
123
|
fireEvent.click(getByText('Cancel'));
|
142
124
|
expect(onChange).not.toHaveBeenCalled();
|
143
125
|
expect(onHide).toHaveBeenCalledTimes(1);
|
144
|
-
|
145
|
-
expect(event).toHaveBeenCalledWith({
|
146
|
-
category: gaSpec.category,
|
147
|
-
action: `${gaSpec.action} (Cancel)`
|
148
|
-
});
|
149
126
|
});
|
150
127
|
|
151
128
|
it('should display the selected time in 12 and 24 hour formats', () => {
|
@@ -156,7 +133,6 @@ describe('<TimeOverlay />', () => {
|
|
156
133
|
value={{ hours: 0, minutes: 15 }}
|
157
134
|
min={{ hours: 0, minutes: 0 }}
|
158
135
|
max={{ hours: 23, minutes: 59 }}
|
159
|
-
GA={gaSpec}
|
160
136
|
/>
|
161
137
|
);
|
162
138
|
|
@@ -102,7 +102,7 @@ describe('TimePicker', () => {
|
|
102
102
|
});
|
103
103
|
|
104
104
|
it('should close overlay when clicked outside of the picker', () => {
|
105
|
-
// overlay initially closed
|
105
|
+
// overlay initially closed here
|
106
106
|
expect(element.queryByTestId('overlay')).not.toBeInTheDocument();
|
107
107
|
|
108
108
|
// open overlay
|
@@ -1,14 +1,13 @@
|
|
1
1
|
/* eslint max-lines: 0 */
|
2
2
|
|
3
3
|
import React from 'react';
|
4
|
-
import { number, bool, func, shape
|
4
|
+
import { number, bool, func, shape } from 'prop-types';
|
5
5
|
import plur from 'pluralize';
|
6
6
|
import styled from 'styled-components';
|
7
7
|
import autobind from 'react-autobind';
|
8
8
|
import BrandButton from 'components/Button/BrandButton';
|
9
9
|
import loopAround from '../../utils/loopAround';
|
10
10
|
import loopAroundMinutes from '../../utils/loopAroundMinutes';
|
11
|
-
import PickerGA from '../../utils/PickerGA';
|
12
11
|
import LOOP_STATUS from '../../utils/constants/loopStatus';
|
13
12
|
import TimeInput from '../TimeInput';
|
14
13
|
import Actions from '../../Elements/Actions';
|
@@ -36,10 +35,6 @@ const DurationLabel = styled.span`
|
|
36
35
|
`;
|
37
36
|
DurationLabel.displayName = 'DurationLabel';
|
38
37
|
|
39
|
-
const pad = value => (value < 10 ? `0${value}` : value);
|
40
|
-
|
41
|
-
const getGATimeString = ({ hour, minute }) => `${pad(hour)}:${pad(minute)}`;
|
42
|
-
|
43
38
|
class TimePickerOverlay extends React.Component {
|
44
39
|
constructor(props) {
|
45
40
|
super(props);
|
@@ -194,8 +189,7 @@ class TimePickerOverlay extends React.Component {
|
|
194
189
|
onApply,
|
195
190
|
onCancel,
|
196
191
|
isDurationPicker,
|
197
|
-
isDurationMinsOnly
|
198
|
-
GA
|
192
|
+
isDurationMinsOnly
|
199
193
|
} = this.props;
|
200
194
|
const { minute, hour } = this.state;
|
201
195
|
const showHoursPicker = !(isDurationPicker && isDurationMinsOnly);
|
@@ -225,13 +219,6 @@ class TimePickerOverlay extends React.Component {
|
|
225
219
|
setTime={(newTime, shouldApply) =>
|
226
220
|
this.setState({ hour: newTime }, () => {
|
227
221
|
if (shouldApply) {
|
228
|
-
PickerGA({
|
229
|
-
category: GA.category,
|
230
|
-
action: `Apply time (${GA.action})`,
|
231
|
-
label: getGATimeString(
|
232
|
-
this.state
|
233
|
-
)
|
234
|
-
});
|
235
222
|
onApply(this.state);
|
236
223
|
}
|
237
224
|
})
|
@@ -278,11 +265,6 @@ class TimePickerOverlay extends React.Component {
|
|
278
265
|
setTime={(newTime, shouldApply) =>
|
279
266
|
this.setState({ minute: newTime }, () => {
|
280
267
|
if (shouldApply) {
|
281
|
-
PickerGA({
|
282
|
-
category: GA.category,
|
283
|
-
action: `Apply time (${GA.action})`,
|
284
|
-
label: getGATimeString(this.state)
|
285
|
-
});
|
286
268
|
onApply(this.state);
|
287
269
|
}
|
288
270
|
})
|
@@ -316,40 +298,12 @@ class TimePickerOverlay extends React.Component {
|
|
316
298
|
<CancelLink
|
317
299
|
onClick={() => {
|
318
300
|
onCancel();
|
319
|
-
PickerGA({
|
320
|
-
category: GA.category,
|
321
|
-
action: `Cancel time (${GA.action})`
|
322
|
-
});
|
323
301
|
}}
|
324
302
|
>
|
325
303
|
Cancel
|
326
304
|
</CancelLink>
|
327
305
|
<BrandButton
|
328
306
|
onClick={() => {
|
329
|
-
if (
|
330
|
-
this.state.hasUserUsedArrowIcons &&
|
331
|
-
this.state.hasUserEnteredInputManually
|
332
|
-
) {
|
333
|
-
PickerGA({
|
334
|
-
category: GA.category,
|
335
|
-
action: 'Both Arrow and Manual input used'
|
336
|
-
});
|
337
|
-
} else if (this.state.hasUserUsedArrowIcons) {
|
338
|
-
PickerGA({
|
339
|
-
category: GA.category,
|
340
|
-
action: 'Only arrows used'
|
341
|
-
});
|
342
|
-
} else if (this.state.hasUserEnteredInputManually) {
|
343
|
-
PickerGA({
|
344
|
-
category: GA.category,
|
345
|
-
action: 'Only Manual input used'
|
346
|
-
});
|
347
|
-
}
|
348
|
-
PickerGA({
|
349
|
-
category: GA.category,
|
350
|
-
action: `Apply time (${GA.action})`,
|
351
|
-
label: getGATimeString(this.state)
|
352
|
-
});
|
353
307
|
onApply(this.state);
|
354
308
|
}}
|
355
309
|
data-e2e="time-apply"
|
@@ -364,7 +318,6 @@ class TimePickerOverlay extends React.Component {
|
|
364
318
|
TimePickerOverlay.displayName = 'TimePickerOverlay';
|
365
319
|
|
366
320
|
TimePickerOverlay.propTypes = {
|
367
|
-
GA: shape({ action: string, label: string }),
|
368
321
|
minute: number.isRequired,
|
369
322
|
stepMinutes: number,
|
370
323
|
minMinutes: number,
|
@@ -383,7 +336,6 @@ TimePickerOverlay.propTypes = {
|
|
383
336
|
};
|
384
337
|
|
385
338
|
TimePickerOverlay.defaultProps = {
|
386
|
-
GA: { action: '', label: '' },
|
387
339
|
stepMinutes: 1,
|
388
340
|
stepHours: 1,
|
389
341
|
isDurationPicker: false,
|
@@ -1,10 +1,8 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
import { mount } from 'enzyme';
|
3
|
-
import ReactGA from 'react-ga';
|
4
3
|
import TimeOverlayComp from '.';
|
5
4
|
|
6
5
|
const consoleSpy = jest.spyOn(global.console, 'warn').mockImplementation();
|
7
|
-
const GASpy = jest.spyOn(ReactGA, 'event');
|
8
6
|
const onApply = jest.fn;
|
9
7
|
const onCancel = jest.fn;
|
10
8
|
|
@@ -53,8 +51,7 @@ describe('TestOverlay', () => {
|
|
53
51
|
it('should pass the right props down to TimeInput elements', () => {
|
54
52
|
const Overlay = getTimeOverlay({
|
55
53
|
onCancel: onCancelCallback,
|
56
|
-
onApply: onApplyCallback
|
57
|
-
GA: { action: 'something else', category: 'something' }
|
54
|
+
onApply: onApplyCallback
|
58
55
|
});
|
59
56
|
|
60
57
|
const HourInput = Overlay.find('TimeInput').at(0);
|
@@ -532,222 +529,6 @@ describe('TestOverlay', () => {
|
|
532
529
|
expect(mins).toBe(15);
|
533
530
|
});
|
534
531
|
|
535
|
-
describe('GA', () => {
|
536
|
-
it('should amend state correctly when the GATrigger prop is invoked', () => {
|
537
|
-
const DurationPicker = getTimeOverlay();
|
538
|
-
|
539
|
-
DurationPicker.setState({ hasUserEnteredInputManually: false });
|
540
|
-
DurationPicker.find('TimeInput')
|
541
|
-
.at(0)
|
542
|
-
.prop('hasUserEnteredInputManually')();
|
543
|
-
expect(DurationPicker.state('hasUserEnteredInputManually')).toBe(
|
544
|
-
true
|
545
|
-
);
|
546
|
-
|
547
|
-
DurationPicker.setState({ hasUserEnteredInputManually: false });
|
548
|
-
DurationPicker.find('TimeInput')
|
549
|
-
.at(1)
|
550
|
-
.prop('hasUserEnteredInputManually')();
|
551
|
-
expect(DurationPicker.state('hasUserEnteredInputManually')).toBe(
|
552
|
-
true
|
553
|
-
);
|
554
|
-
});
|
555
|
-
|
556
|
-
describe('should call the correct GA tag depending on what is in state', () => {
|
557
|
-
// note: this section describes behaviour of GA in the specific
|
558
|
-
// sections of the TimePicker. Upon clicking apply, GA will fire a
|
559
|
-
// single event confirming that the user has hit apply. A second GA
|
560
|
-
// event will also fire if the user has clicked either the manual input
|
561
|
-
// or the arrow inputs. The tests below describe each case and also
|
562
|
-
// the case where neither is clicked.
|
563
|
-
beforeEach(() => {
|
564
|
-
GASpy.mockReset();
|
565
|
-
});
|
566
|
-
|
567
|
-
const DurationPicker = getTimeOverlay({
|
568
|
-
GA: { category: 'cat' },
|
569
|
-
onCancel: onCancelCallback,
|
570
|
-
onApply: onApplyCallback
|
571
|
-
});
|
572
|
-
|
573
|
-
it('should call the correct GA tag if user used both arrows and manual input', () => {
|
574
|
-
DurationPicker.setState({
|
575
|
-
hasUserEnteredInputManually: true,
|
576
|
-
hasUserUsedArrowIcons: true
|
577
|
-
});
|
578
|
-
DurationPicker.find('BrandButton').prop('onClick')();
|
579
|
-
expect(GASpy).toHaveBeenCalledWith({
|
580
|
-
action: 'Both Arrow and Manual input used',
|
581
|
-
category: 'cat',
|
582
|
-
label: undefined
|
583
|
-
});
|
584
|
-
expect(GASpy).toHaveBeenCalledTimes(2);
|
585
|
-
});
|
586
|
-
|
587
|
-
it('should call the correct GA tag if the user only used manual input', () => {
|
588
|
-
DurationPicker.setState({
|
589
|
-
hasUserEnteredInputManually: true,
|
590
|
-
hasUserUsedArrowIcons: false
|
591
|
-
});
|
592
|
-
DurationPicker.find('BrandButton').prop('onClick')();
|
593
|
-
expect(GASpy).toHaveBeenCalledWith({
|
594
|
-
action: 'Only Manual input used',
|
595
|
-
category: 'cat',
|
596
|
-
label: undefined
|
597
|
-
});
|
598
|
-
expect(GASpy).toHaveBeenCalledTimes(2);
|
599
|
-
});
|
600
|
-
|
601
|
-
it('should call the correct GA tag if the user only used arrows', () => {
|
602
|
-
DurationPicker.setState({
|
603
|
-
hasUserEnteredInputManually: false,
|
604
|
-
hasUserUsedArrowIcons: true
|
605
|
-
});
|
606
|
-
DurationPicker.find('BrandButton').prop('onClick')();
|
607
|
-
expect(GASpy).toHaveBeenCalledWith({
|
608
|
-
action: 'Only arrows used',
|
609
|
-
category: 'cat',
|
610
|
-
label: undefined
|
611
|
-
});
|
612
|
-
expect(GASpy).toHaveBeenCalledTimes(2);
|
613
|
-
});
|
614
|
-
|
615
|
-
it('should only call the "apply" GA if the user has not used arrows or manual input', () => {
|
616
|
-
DurationPicker.setState({
|
617
|
-
hasUserEnteredInputManually: false,
|
618
|
-
hasUserUsedArrowIcons: false
|
619
|
-
});
|
620
|
-
DurationPicker.find('BrandButton').prop('onClick')();
|
621
|
-
expect(GASpy).toHaveBeenCalledTimes(1);
|
622
|
-
});
|
623
|
-
});
|
624
|
-
|
625
|
-
it('should not call ga when category is not specified', () => {
|
626
|
-
const DurationPicker = getTimeOverlay({
|
627
|
-
onCancel: onCancelCallback,
|
628
|
-
onApply: onApplyCallback
|
629
|
-
});
|
630
|
-
|
631
|
-
DurationPicker.find('UpIcon')
|
632
|
-
.at(0)
|
633
|
-
.simulate('click');
|
634
|
-
|
635
|
-
expect(GASpy).not.toHaveBeenCalled();
|
636
|
-
});
|
637
|
-
|
638
|
-
it('should call ga when cancelling', () => {
|
639
|
-
const DurationPicker = getTimeOverlay({
|
640
|
-
onCancel: onCancelCallback,
|
641
|
-
onApply: onApplyCallback,
|
642
|
-
GA: { category: 'cat', action: 'start' }
|
643
|
-
});
|
644
|
-
DurationPicker.find('CancelLink').simulate('click');
|
645
|
-
|
646
|
-
expect(GASpy).toHaveBeenLastCalledWith({
|
647
|
-
action: 'Cancel time (start)',
|
648
|
-
category: 'cat',
|
649
|
-
label: undefined
|
650
|
-
});
|
651
|
-
});
|
652
|
-
|
653
|
-
it('should call ga when applying', () => {
|
654
|
-
const DurationPicker = getTimeOverlay({
|
655
|
-
onCancel: onCancelCallback,
|
656
|
-
onApply: onApplyCallback,
|
657
|
-
GA: { category: 'cat', action: 'start' }
|
658
|
-
});
|
659
|
-
DurationPicker.find('BrandButton').simulate('click');
|
660
|
-
|
661
|
-
expect(GASpy).toHaveBeenLastCalledWith({
|
662
|
-
action: 'Apply time (start)',
|
663
|
-
category: 'cat',
|
664
|
-
label: '23:55'
|
665
|
-
});
|
666
|
-
});
|
667
|
-
|
668
|
-
it('should call onApply and GA when shouldAppy is true (hrs)', () => {
|
669
|
-
const DurationPicker = getTimeOverlay({
|
670
|
-
onCancel: onCancelCallback,
|
671
|
-
onApply: onApplyCallback,
|
672
|
-
GA: { category: 'cat', action: 'start' }
|
673
|
-
});
|
674
|
-
|
675
|
-
expect(GASpy).not.toHaveBeenCalled();
|
676
|
-
const input = DurationPicker.find('TimeInput').at(0);
|
677
|
-
input.prop('setTime')(10, true);
|
678
|
-
|
679
|
-
expect(onApplyCallback).toHaveBeenCalled();
|
680
|
-
expect(GASpy).toHaveBeenLastCalledWith({
|
681
|
-
action: 'Apply time (start)',
|
682
|
-
category: 'cat',
|
683
|
-
label: '10:55'
|
684
|
-
});
|
685
|
-
});
|
686
|
-
|
687
|
-
it('should call onApply when shouldAppy is true (mins)', () => {
|
688
|
-
const DurationPicker = getTimeOverlay({
|
689
|
-
onCancel: onCancelCallback,
|
690
|
-
onApply: onApplyCallback,
|
691
|
-
GA: { category: 'cat', action: 'start' }
|
692
|
-
});
|
693
|
-
|
694
|
-
expect(GASpy).not.toHaveBeenCalled();
|
695
|
-
const input = DurationPicker.find('TimeInput').at(1);
|
696
|
-
input.prop('setTime')(10, true);
|
697
|
-
|
698
|
-
expect(onApplyCallback).toHaveBeenCalled();
|
699
|
-
expect(GASpy).toHaveBeenLastCalledWith({
|
700
|
-
action: 'Apply time (start)',
|
701
|
-
category: 'cat',
|
702
|
-
label: '23:10'
|
703
|
-
});
|
704
|
-
});
|
705
|
-
|
706
|
-
it('should pad values that are less than 10', () => {
|
707
|
-
const DurationPicker = getTimeOverlay({
|
708
|
-
onCancel: onCancelCallback,
|
709
|
-
onApply: onApplyCallback,
|
710
|
-
GA: { category: 'cat', action: 'start' }
|
711
|
-
});
|
712
|
-
|
713
|
-
expect(GASpy).not.toHaveBeenCalled();
|
714
|
-
const input = DurationPicker.find('TimeInput').at(0);
|
715
|
-
input.prop('setTime')(9, true);
|
716
|
-
|
717
|
-
const minsInput = DurationPicker.find('TimeInput').at(1);
|
718
|
-
minsInput.prop('setTime')(9, true);
|
719
|
-
|
720
|
-
expect(onApplyCallback).toHaveBeenCalled();
|
721
|
-
expect(GASpy).toHaveBeenLastCalledWith({
|
722
|
-
action: 'Apply time (start)',
|
723
|
-
category: 'cat',
|
724
|
-
label: '09:09'
|
725
|
-
});
|
726
|
-
});
|
727
|
-
|
728
|
-
it('should call set the label with correct time when hour is greater than 23', () => {
|
729
|
-
const DurationPicker = getTimeOverlay({
|
730
|
-
onCancel: onCancelCallback,
|
731
|
-
onApply: onApplyCallback,
|
732
|
-
GA: { category: 'cat', action: 'start' }
|
733
|
-
});
|
734
|
-
|
735
|
-
expect(GASpy).not.toHaveBeenCalled();
|
736
|
-
const input = DurationPicker.find('TimeInput').at(0);
|
737
|
-
input.prop('setTime')(25, true);
|
738
|
-
|
739
|
-
const minsInput = DurationPicker.find('TimeInput').at(1);
|
740
|
-
minsInput.prop('setTime')(10, true);
|
741
|
-
|
742
|
-
expect(onApplyCallback).toHaveBeenCalled();
|
743
|
-
expect(GASpy).toHaveBeenLastCalledWith({
|
744
|
-
action: 'Apply time (start)',
|
745
|
-
category: 'cat',
|
746
|
-
label: '25:10'
|
747
|
-
});
|
748
|
-
});
|
749
|
-
});
|
750
|
-
|
751
532
|
describe('should focus on input field on mount', () => {
|
752
533
|
it('should focus on hour field', () => {
|
753
534
|
getTimeOverlay({
|
package/src/index.js
CHANGED
package/src/setupTests.js
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
import { configure } from 'enzyme';
|
2
2
|
import { configure as RTLConfig } from '@testing-library/react';
|
3
3
|
import Adapter from 'enzyme-adapter-react-16';
|
4
|
-
import ReactGA from 'react-ga';
|
5
4
|
import 'jest-enzyme';
|
6
5
|
import 'jest-styled-components';
|
7
6
|
import '@testing-library/jest-dom/extend-expect';
|
@@ -24,7 +23,6 @@ beforeEach(() => {
|
|
24
23
|
|
25
24
|
Element.prototype.scrollIntoView = jest.fn();
|
26
25
|
|
27
|
-
ReactGA.initialize('foo', { testMode: true });
|
28
26
|
jest.clearAllMocks();
|
29
27
|
});
|
30
28
|
|
@@ -1,24 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
exports.__esModule = true;
|
4
|
-
exports.default = void 0;
|
5
|
-
|
6
|
-
var _reactGa = _interopRequireDefault(require("react-ga"));
|
7
|
-
|
8
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
9
|
-
|
10
|
-
const PickerGA = _ref => {
|
11
|
-
let {
|
12
|
-
action,
|
13
|
-
category,
|
14
|
-
label
|
15
|
-
} = _ref;
|
16
|
-
return category && _reactGa.default.event({
|
17
|
-
category,
|
18
|
-
action,
|
19
|
-
label
|
20
|
-
});
|
21
|
-
};
|
22
|
-
|
23
|
-
var _default = PickerGA;
|
24
|
-
exports.default = _default;
|