@pie-lib/charting 7.0.13 → 7.1.0-beta
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/CHANGELOG.md +0 -44
- package/lib/__tests__/actions-button.test.js +332 -0
- package/lib/__tests__/actions-button.test.js.map +1 -0
- package/lib/__tests__/axes.test.js +746 -0
- package/lib/__tests__/axes.test.js.map +1 -0
- package/lib/__tests__/chart-setup.test.js +796 -0
- package/lib/__tests__/chart-setup.test.js.map +1 -0
- package/lib/__tests__/chart-type.test.js +25 -0
- package/lib/__tests__/chart-type.test.js.map +1 -0
- package/lib/__tests__/chart.test.js +103 -0
- package/lib/__tests__/chart.test.js.map +1 -0
- package/lib/__tests__/grid.test.js +39 -0
- package/lib/__tests__/grid.test.js.map +1 -0
- package/lib/__tests__/key-legend.test.js +235 -0
- package/lib/__tests__/key-legend.test.js.map +1 -0
- package/lib/__tests__/mark-label.test.js +46 -0
- package/lib/__tests__/mark-label.test.js.map +1 -0
- package/lib/__tests__/tool-menu.test.js +627 -0
- package/lib/__tests__/tool-menu.test.js.map +1 -0
- package/lib/__tests__/utils.js +56 -0
- package/lib/__tests__/utils.js.map +1 -0
- package/lib/__tests__/utils.test.js +186 -0
- package/lib/__tests__/utils.test.js.map +1 -0
- package/lib/bars/__tests__/bar.test.js +53 -0
- package/lib/bars/__tests__/bar.test.js.map +1 -0
- package/lib/bars/__tests__/histogram.test.js +53 -0
- package/lib/bars/__tests__/histogram.test.js.map +1 -0
- package/lib/bars/__tests__/utils.js +50 -0
- package/lib/bars/__tests__/utils.js.map +1 -0
- package/lib/bars/common/__tests__/bars.test.js +76 -0
- package/lib/bars/common/__tests__/bars.test.js.map +1 -0
- package/lib/bars/common/__tests__/utils.js +50 -0
- package/lib/bars/common/__tests__/utils.js.map +1 -0
- package/lib/common/__tests__/correctness-indicators.test.js +887 -0
- package/lib/common/__tests__/correctness-indicators.test.js.map +1 -0
- package/lib/common/__tests__/drag-handle.test.js +73 -0
- package/lib/common/__tests__/drag-handle.test.js.map +1 -0
- package/lib/common/__tests__/utils.js +50 -0
- package/lib/common/__tests__/utils.js.map +1 -0
- package/lib/line/__tests__/line-cross.test.js +617 -0
- package/lib/line/__tests__/line-cross.test.js.map +1 -0
- package/lib/line/__tests__/line-dot.test.js +47 -0
- package/lib/line/__tests__/line-dot.test.js.map +1 -0
- package/lib/line/__tests__/utils.js +56 -0
- package/lib/line/__tests__/utils.js.map +1 -0
- package/lib/line/common/__tests__/drag-handle.test.js +73 -0
- package/lib/line/common/__tests__/drag-handle.test.js.map +1 -0
- package/lib/line/common/__tests__/line.test.js +92 -0
- package/lib/line/common/__tests__/line.test.js.map +1 -0
- package/lib/line/common/__tests__/utils.js +50 -0
- package/lib/line/common/__tests__/utils.js.map +1 -0
- package/lib/plot/__tests__/dot.test.js +513 -0
- package/lib/plot/__tests__/dot.test.js.map +1 -0
- package/lib/plot/__tests__/line.test.js +566 -0
- package/lib/plot/__tests__/line.test.js.map +1 -0
- package/lib/plot/__tests__/utils.js +50 -0
- package/lib/plot/__tests__/utils.js.map +1 -0
- package/lib/plot/common/__tests__/plot.test.js +79 -0
- package/lib/plot/common/__tests__/plot.test.js.map +1 -0
- package/lib/plot/common/__tests__/utils.js +50 -0
- package/lib/plot/common/__tests__/utils.js.map +1 -0
- package/package.json +5 -5
- package/LICENSE.md +0 -5
|
@@ -0,0 +1,887 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
5
|
+
var _react = _interopRequireDefault(require("react"));
|
|
6
|
+
var _react2 = require("@testing-library/react");
|
|
7
|
+
var _styles = require("@mui/material/styles");
|
|
8
|
+
var _correctnessIndicators = require("../correctness-indicators");
|
|
9
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
10
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
11
|
+
jest.mock('@pie-lib/render-ui', function () {
|
|
12
|
+
return {
|
|
13
|
+
color: {
|
|
14
|
+
correct: function correct() {
|
|
15
|
+
return '#00ff00';
|
|
16
|
+
},
|
|
17
|
+
incorrectWithIcon: function incorrectWithIcon() {
|
|
18
|
+
return '#ff0000';
|
|
19
|
+
},
|
|
20
|
+
defaults: {
|
|
21
|
+
WHITE: '#ffffff'
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
});
|
|
26
|
+
jest.mock('@mui/icons-material/Check', function () {
|
|
27
|
+
return function Check(props) {
|
|
28
|
+
return /*#__PURE__*/_react["default"].createElement("svg", {
|
|
29
|
+
"data-testid": "check-icon",
|
|
30
|
+
title: props.title,
|
|
31
|
+
className: props.className
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
});
|
|
35
|
+
jest.mock('@mui/icons-material/Close', function () {
|
|
36
|
+
return function Close(props) {
|
|
37
|
+
return /*#__PURE__*/_react["default"].createElement("svg", {
|
|
38
|
+
"data-testid": "close-icon",
|
|
39
|
+
title: props.title,
|
|
40
|
+
className: props.className
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
});
|
|
44
|
+
var theme;
|
|
45
|
+
beforeAll(function () {
|
|
46
|
+
theme = (0, _styles.createTheme)();
|
|
47
|
+
});
|
|
48
|
+
describe('CorrectnessIndicator', function () {
|
|
49
|
+
var mockScale = {
|
|
50
|
+
x: jest.fn(function (val) {
|
|
51
|
+
return val * 10;
|
|
52
|
+
}),
|
|
53
|
+
y: jest.fn(function (val) {
|
|
54
|
+
return val * 10;
|
|
55
|
+
})
|
|
56
|
+
};
|
|
57
|
+
beforeEach(function () {
|
|
58
|
+
jest.clearAllMocks();
|
|
59
|
+
});
|
|
60
|
+
var renderComponent = function renderComponent() {
|
|
61
|
+
var extras = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
62
|
+
var defaults = {
|
|
63
|
+
scale: mockScale,
|
|
64
|
+
x: 5,
|
|
65
|
+
y: 10,
|
|
66
|
+
correctness: {
|
|
67
|
+
value: 'correct',
|
|
68
|
+
label: 'Correct Answer'
|
|
69
|
+
},
|
|
70
|
+
interactive: true
|
|
71
|
+
};
|
|
72
|
+
var props = _objectSpread(_objectSpread({}, defaults), extras);
|
|
73
|
+
return (0, _react2.render)(/*#__PURE__*/_react["default"].createElement(_styles.ThemeProvider, {
|
|
74
|
+
theme: theme
|
|
75
|
+
}, /*#__PURE__*/_react["default"].createElement("svg", null, /*#__PURE__*/_react["default"].createElement(_correctnessIndicators.CorrectnessIndicator, props))));
|
|
76
|
+
};
|
|
77
|
+
describe('rendering', function () {
|
|
78
|
+
it('should render without crashing', function () {
|
|
79
|
+
var _renderComponent = renderComponent(),
|
|
80
|
+
container = _renderComponent.container;
|
|
81
|
+
expect(container).toBeInTheDocument();
|
|
82
|
+
});
|
|
83
|
+
it('should render foreignObject element', function () {
|
|
84
|
+
var _renderComponent2 = renderComponent(),
|
|
85
|
+
container = _renderComponent2.container;
|
|
86
|
+
var foreignObject = container.querySelector('foreignObject');
|
|
87
|
+
expect(foreignObject).toBeInTheDocument();
|
|
88
|
+
});
|
|
89
|
+
it('should render check icon for correct answer', function () {
|
|
90
|
+
var _renderComponent3 = renderComponent({
|
|
91
|
+
correctness: {
|
|
92
|
+
value: 'correct',
|
|
93
|
+
label: 'Correct'
|
|
94
|
+
}
|
|
95
|
+
}),
|
|
96
|
+
getByTestId = _renderComponent3.getByTestId;
|
|
97
|
+
expect(getByTestId('check-icon')).toBeInTheDocument();
|
|
98
|
+
});
|
|
99
|
+
it('should render close icon for incorrect answer', function () {
|
|
100
|
+
var _renderComponent4 = renderComponent({
|
|
101
|
+
correctness: {
|
|
102
|
+
value: 'incorrect',
|
|
103
|
+
label: 'Incorrect'
|
|
104
|
+
}
|
|
105
|
+
}),
|
|
106
|
+
getByTestId = _renderComponent4.getByTestId;
|
|
107
|
+
expect(getByTestId('close-icon')).toBeInTheDocument();
|
|
108
|
+
});
|
|
109
|
+
it('should not render when correctness is null', function () {
|
|
110
|
+
var _renderComponent5 = renderComponent({
|
|
111
|
+
correctness: null
|
|
112
|
+
}),
|
|
113
|
+
container = _renderComponent5.container;
|
|
114
|
+
var foreignObject = container.querySelector('foreignObject');
|
|
115
|
+
expect(foreignObject).not.toBeInTheDocument();
|
|
116
|
+
});
|
|
117
|
+
it('should not render when correctness is undefined', function () {
|
|
118
|
+
var _renderComponent6 = renderComponent({
|
|
119
|
+
correctness: undefined
|
|
120
|
+
}),
|
|
121
|
+
container = _renderComponent6.container;
|
|
122
|
+
var foreignObject = container.querySelector('foreignObject');
|
|
123
|
+
expect(foreignObject).not.toBeInTheDocument();
|
|
124
|
+
});
|
|
125
|
+
it('should not render when interactive is false', function () {
|
|
126
|
+
var _renderComponent7 = renderComponent({
|
|
127
|
+
interactive: false
|
|
128
|
+
}),
|
|
129
|
+
container = _renderComponent7.container;
|
|
130
|
+
var foreignObject = container.querySelector('foreignObject');
|
|
131
|
+
expect(foreignObject).not.toBeInTheDocument();
|
|
132
|
+
});
|
|
133
|
+
it('should render with correct title for correct answer', function () {
|
|
134
|
+
var _renderComponent8 = renderComponent({
|
|
135
|
+
correctness: {
|
|
136
|
+
value: 'correct',
|
|
137
|
+
label: 'Well done!'
|
|
138
|
+
}
|
|
139
|
+
}),
|
|
140
|
+
getByTestId = _renderComponent8.getByTestId;
|
|
141
|
+
var icon = getByTestId('check-icon');
|
|
142
|
+
expect(icon).toHaveAttribute('title', 'Well done!');
|
|
143
|
+
});
|
|
144
|
+
it('should render with correct title for incorrect answer', function () {
|
|
145
|
+
var _renderComponent9 = renderComponent({
|
|
146
|
+
correctness: {
|
|
147
|
+
value: 'incorrect',
|
|
148
|
+
label: 'Try again'
|
|
149
|
+
}
|
|
150
|
+
}),
|
|
151
|
+
getByTestId = _renderComponent9.getByTestId;
|
|
152
|
+
var icon = getByTestId('close-icon');
|
|
153
|
+
expect(icon).toHaveAttribute('title', 'Try again');
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
describe('positioning with scale', function () {
|
|
157
|
+
it('should use scale to calculate position', function () {
|
|
158
|
+
var _renderComponent0 = renderComponent({
|
|
159
|
+
scale: mockScale,
|
|
160
|
+
x: 5,
|
|
161
|
+
y: 10
|
|
162
|
+
}),
|
|
163
|
+
container = _renderComponent0.container;
|
|
164
|
+
var foreignObject = container.querySelector('foreignObject');
|
|
165
|
+
expect(mockScale.x).toHaveBeenCalledWith(5);
|
|
166
|
+
expect(mockScale.y).toHaveBeenCalledWith(10);
|
|
167
|
+
// position is scaled value - 11 (half of 22px icon size)
|
|
168
|
+
expect(foreignObject).toHaveAttribute('x', '39'); // 50 - 11
|
|
169
|
+
expect(foreignObject).toHaveAttribute('y', '89'); // 100 - 11
|
|
170
|
+
});
|
|
171
|
+
it('should have correct size attributes', function () {
|
|
172
|
+
var _renderComponent1 = renderComponent(),
|
|
173
|
+
container = _renderComponent1.container;
|
|
174
|
+
var foreignObject = container.querySelector('foreignObject');
|
|
175
|
+
expect(foreignObject).toHaveAttribute('width', '22');
|
|
176
|
+
expect(foreignObject).toHaveAttribute('height', '22');
|
|
177
|
+
});
|
|
178
|
+
it('should handle different x and y values', function () {
|
|
179
|
+
var _renderComponent10 = renderComponent({
|
|
180
|
+
x: 20,
|
|
181
|
+
y: 30
|
|
182
|
+
}),
|
|
183
|
+
container = _renderComponent10.container;
|
|
184
|
+
expect(mockScale.x).toHaveBeenCalledWith(20);
|
|
185
|
+
expect(mockScale.y).toHaveBeenCalledWith(30);
|
|
186
|
+
});
|
|
187
|
+
it('should use raw values when scale is not provided', function () {
|
|
188
|
+
var _renderComponent11 = renderComponent({
|
|
189
|
+
scale: null,
|
|
190
|
+
x: 50,
|
|
191
|
+
y: 100
|
|
192
|
+
}),
|
|
193
|
+
container = _renderComponent11.container;
|
|
194
|
+
var foreignObject = container.querySelector('foreignObject');
|
|
195
|
+
expect(foreignObject).toHaveAttribute('x', '39'); // 50 - 11
|
|
196
|
+
expect(foreignObject).toHaveAttribute('y', '89'); // 100 - 11
|
|
197
|
+
});
|
|
198
|
+
});
|
|
199
|
+
describe('edge cases', function () {
|
|
200
|
+
it('should handle zero coordinates', function () {
|
|
201
|
+
var _renderComponent12 = renderComponent({
|
|
202
|
+
x: 0,
|
|
203
|
+
y: 0
|
|
204
|
+
}),
|
|
205
|
+
container = _renderComponent12.container;
|
|
206
|
+
var foreignObject = container.querySelector('foreignObject');
|
|
207
|
+
expect(foreignObject).toHaveAttribute('x', '-11');
|
|
208
|
+
expect(foreignObject).toHaveAttribute('y', '-11');
|
|
209
|
+
});
|
|
210
|
+
it('should handle negative coordinates', function () {
|
|
211
|
+
var _renderComponent13 = renderComponent({
|
|
212
|
+
x: -5,
|
|
213
|
+
y: -10
|
|
214
|
+
}),
|
|
215
|
+
container = _renderComponent13.container;
|
|
216
|
+
expect(mockScale.x).toHaveBeenCalledWith(-5);
|
|
217
|
+
expect(mockScale.y).toHaveBeenCalledWith(-10);
|
|
218
|
+
});
|
|
219
|
+
it('should handle large coordinates', function () {
|
|
220
|
+
var _renderComponent14 = renderComponent({
|
|
221
|
+
x: 1000,
|
|
222
|
+
y: 2000
|
|
223
|
+
}),
|
|
224
|
+
container = _renderComponent14.container;
|
|
225
|
+
expect(mockScale.x).toHaveBeenCalledWith(1000);
|
|
226
|
+
expect(mockScale.y).toHaveBeenCalledWith(2000);
|
|
227
|
+
});
|
|
228
|
+
it('should handle correctness with empty label', function () {
|
|
229
|
+
var _renderComponent15 = renderComponent({
|
|
230
|
+
correctness: {
|
|
231
|
+
value: 'correct',
|
|
232
|
+
label: ''
|
|
233
|
+
}
|
|
234
|
+
}),
|
|
235
|
+
getByTestId = _renderComponent15.getByTestId;
|
|
236
|
+
var icon = getByTestId('check-icon');
|
|
237
|
+
expect(icon).toHaveAttribute('title', '');
|
|
238
|
+
});
|
|
239
|
+
it('should handle correctness with undefined label', function () {
|
|
240
|
+
var _renderComponent16 = renderComponent({
|
|
241
|
+
correctness: {
|
|
242
|
+
value: 'correct',
|
|
243
|
+
label: undefined
|
|
244
|
+
}
|
|
245
|
+
}),
|
|
246
|
+
getByTestId = _renderComponent16.getByTestId;
|
|
247
|
+
expect(getByTestId('check-icon')).toBeInTheDocument();
|
|
248
|
+
});
|
|
249
|
+
it('should render when both correctness and interactive are true', function () {
|
|
250
|
+
var _renderComponent17 = renderComponent({
|
|
251
|
+
correctness: {
|
|
252
|
+
value: 'correct',
|
|
253
|
+
label: 'Test'
|
|
254
|
+
},
|
|
255
|
+
interactive: true
|
|
256
|
+
}),
|
|
257
|
+
container = _renderComponent17.container;
|
|
258
|
+
expect(container.querySelector('foreignObject')).toBeInTheDocument();
|
|
259
|
+
});
|
|
260
|
+
it('should not render when interactive is false even with correctness', function () {
|
|
261
|
+
var _renderComponent18 = renderComponent({
|
|
262
|
+
correctness: {
|
|
263
|
+
value: 'correct',
|
|
264
|
+
label: 'Test'
|
|
265
|
+
},
|
|
266
|
+
interactive: false
|
|
267
|
+
}),
|
|
268
|
+
container = _renderComponent18.container;
|
|
269
|
+
expect(container.querySelector('foreignObject')).not.toBeInTheDocument();
|
|
270
|
+
});
|
|
271
|
+
});
|
|
272
|
+
});
|
|
273
|
+
describe('SmallCorrectPointIndicator', function () {
|
|
274
|
+
var mockScale = {
|
|
275
|
+
x: jest.fn(function (val) {
|
|
276
|
+
return val * 10;
|
|
277
|
+
}),
|
|
278
|
+
y: jest.fn(function (val) {
|
|
279
|
+
return val * 10;
|
|
280
|
+
})
|
|
281
|
+
};
|
|
282
|
+
var correctData = [{
|
|
283
|
+
label: 'A',
|
|
284
|
+
value: 10
|
|
285
|
+
}, {
|
|
286
|
+
label: 'B',
|
|
287
|
+
value: 20
|
|
288
|
+
}, {
|
|
289
|
+
label: 'C',
|
|
290
|
+
value: '30'
|
|
291
|
+
}];
|
|
292
|
+
beforeEach(function () {
|
|
293
|
+
jest.clearAllMocks();
|
|
294
|
+
});
|
|
295
|
+
var renderComponent = function renderComponent() {
|
|
296
|
+
var extras = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
297
|
+
var defaults = {
|
|
298
|
+
scale: mockScale,
|
|
299
|
+
x: 5,
|
|
300
|
+
correctness: {
|
|
301
|
+
value: 'incorrect',
|
|
302
|
+
label: 'Incorrect'
|
|
303
|
+
},
|
|
304
|
+
correctData: correctData,
|
|
305
|
+
label: 'A'
|
|
306
|
+
};
|
|
307
|
+
var props = _objectSpread(_objectSpread({}, defaults), extras);
|
|
308
|
+
return (0, _react2.render)(/*#__PURE__*/_react["default"].createElement(_styles.ThemeProvider, {
|
|
309
|
+
theme: theme
|
|
310
|
+
}, /*#__PURE__*/_react["default"].createElement("svg", null, /*#__PURE__*/_react["default"].createElement(_correctnessIndicators.SmallCorrectPointIndicator, props))));
|
|
311
|
+
};
|
|
312
|
+
describe('rendering', function () {
|
|
313
|
+
it('should render without crashing', function () {
|
|
314
|
+
var _renderComponent19 = renderComponent(),
|
|
315
|
+
container = _renderComponent19.container;
|
|
316
|
+
expect(container).toBeInTheDocument();
|
|
317
|
+
});
|
|
318
|
+
it('should render foreignObject when incorrect', function () {
|
|
319
|
+
var _renderComponent20 = renderComponent({
|
|
320
|
+
correctness: {
|
|
321
|
+
value: 'incorrect',
|
|
322
|
+
label: 'Wrong'
|
|
323
|
+
},
|
|
324
|
+
label: 'A'
|
|
325
|
+
}),
|
|
326
|
+
container = _renderComponent20.container;
|
|
327
|
+
var foreignObject = container.querySelector('foreignObject');
|
|
328
|
+
expect(foreignObject).toBeInTheDocument();
|
|
329
|
+
});
|
|
330
|
+
it('should render small check icon when incorrect', function () {
|
|
331
|
+
var _renderComponent21 = renderComponent({
|
|
332
|
+
correctness: {
|
|
333
|
+
value: 'incorrect',
|
|
334
|
+
label: 'Wrong'
|
|
335
|
+
},
|
|
336
|
+
label: 'A'
|
|
337
|
+
}),
|
|
338
|
+
getByTestId = _renderComponent21.getByTestId;
|
|
339
|
+
var icon = getByTestId('check-icon');
|
|
340
|
+
expect(icon).toBeInTheDocument();
|
|
341
|
+
expect(icon).toHaveClass('small');
|
|
342
|
+
});
|
|
343
|
+
it('should not render when correctness is correct', function () {
|
|
344
|
+
var _renderComponent22 = renderComponent({
|
|
345
|
+
correctness: {
|
|
346
|
+
value: 'correct',
|
|
347
|
+
label: 'Correct'
|
|
348
|
+
}
|
|
349
|
+
}),
|
|
350
|
+
container = _renderComponent22.container;
|
|
351
|
+
var foreignObject = container.querySelector('foreignObject');
|
|
352
|
+
expect(foreignObject).not.toBeInTheDocument();
|
|
353
|
+
});
|
|
354
|
+
it('should not render when correctness is null', function () {
|
|
355
|
+
var _renderComponent23 = renderComponent({
|
|
356
|
+
correctness: null
|
|
357
|
+
}),
|
|
358
|
+
container = _renderComponent23.container;
|
|
359
|
+
var foreignObject = container.querySelector('foreignObject');
|
|
360
|
+
expect(foreignObject).not.toBeInTheDocument();
|
|
361
|
+
});
|
|
362
|
+
it('should not render when correctness is undefined', function () {
|
|
363
|
+
var _renderComponent24 = renderComponent({
|
|
364
|
+
correctness: undefined
|
|
365
|
+
}),
|
|
366
|
+
container = _renderComponent24.container;
|
|
367
|
+
var foreignObject = container.querySelector('foreignObject');
|
|
368
|
+
expect(foreignObject).not.toBeInTheDocument();
|
|
369
|
+
});
|
|
370
|
+
});
|
|
371
|
+
describe('positioning', function () {
|
|
372
|
+
it('should calculate correct position for label A', function () {
|
|
373
|
+
var _renderComponent25 = renderComponent({
|
|
374
|
+
x: 5,
|
|
375
|
+
label: 'A'
|
|
376
|
+
}),
|
|
377
|
+
container = _renderComponent25.container;
|
|
378
|
+
var foreignObject = container.querySelector('foreignObject');
|
|
379
|
+
expect(mockScale.x).toHaveBeenCalledWith(5);
|
|
380
|
+
expect(mockScale.y).toHaveBeenCalledWith(10); // value from correctData for label A
|
|
381
|
+
// Position is scaled value - 7.5 (half of 15px small icon size)
|
|
382
|
+
expect(foreignObject).toHaveAttribute('x', '42.5'); // 50 - 7.5
|
|
383
|
+
expect(foreignObject).toHaveAttribute('y', '92.5'); // 100 - 7.5
|
|
384
|
+
});
|
|
385
|
+
it('should calculate correct position for label B', function () {
|
|
386
|
+
var _renderComponent26 = renderComponent({
|
|
387
|
+
x: 5,
|
|
388
|
+
label: 'B'
|
|
389
|
+
}),
|
|
390
|
+
container = _renderComponent26.container;
|
|
391
|
+
expect(mockScale.y).toHaveBeenCalledWith(20);
|
|
392
|
+
});
|
|
393
|
+
it('should calculate correct position for label C with string value', function () {
|
|
394
|
+
var _renderComponent27 = renderComponent({
|
|
395
|
+
x: 5,
|
|
396
|
+
label: 'C'
|
|
397
|
+
}),
|
|
398
|
+
container = _renderComponent27.container;
|
|
399
|
+
expect(mockScale.y).toHaveBeenCalledWith(30);
|
|
400
|
+
});
|
|
401
|
+
it('should have correct size attributes for small icon', function () {
|
|
402
|
+
var _renderComponent28 = renderComponent({
|
|
403
|
+
label: 'A'
|
|
404
|
+
}),
|
|
405
|
+
container = _renderComponent28.container;
|
|
406
|
+
var foreignObject = container.querySelector('foreignObject');
|
|
407
|
+
expect(foreignObject).toHaveAttribute('width', '15');
|
|
408
|
+
expect(foreignObject).toHaveAttribute('height', '15');
|
|
409
|
+
});
|
|
410
|
+
});
|
|
411
|
+
describe('correctData handling', function () {
|
|
412
|
+
it('should find correct value from correctData by label', function () {
|
|
413
|
+
var _renderComponent29 = renderComponent({
|
|
414
|
+
label: 'B'
|
|
415
|
+
}),
|
|
416
|
+
container = _renderComponent29.container;
|
|
417
|
+
var foreignObject = container.querySelector('foreignObject');
|
|
418
|
+
expect(foreignObject).toBeInTheDocument();
|
|
419
|
+
expect(mockScale.y).toHaveBeenCalledWith(20);
|
|
420
|
+
});
|
|
421
|
+
it('should not render when label is not in correctData', function () {
|
|
422
|
+
var _renderComponent30 = renderComponent({
|
|
423
|
+
label: 'Z'
|
|
424
|
+
}),
|
|
425
|
+
container = _renderComponent30.container;
|
|
426
|
+
var foreignObject = container.querySelector('foreignObject');
|
|
427
|
+
expect(foreignObject).not.toBeInTheDocument();
|
|
428
|
+
});
|
|
429
|
+
it('should not render when correctData value is NaN', function () {
|
|
430
|
+
var _renderComponent31 = renderComponent({
|
|
431
|
+
correctData: [{
|
|
432
|
+
label: 'A',
|
|
433
|
+
value: 'invalid'
|
|
434
|
+
}],
|
|
435
|
+
label: 'A'
|
|
436
|
+
}),
|
|
437
|
+
container = _renderComponent31.container;
|
|
438
|
+
var foreignObject = container.querySelector('foreignObject');
|
|
439
|
+
expect(foreignObject).not.toBeInTheDocument();
|
|
440
|
+
});
|
|
441
|
+
it('should handle empty correctData array', function () {
|
|
442
|
+
var _renderComponent32 = renderComponent({
|
|
443
|
+
correctData: [],
|
|
444
|
+
label: 'A'
|
|
445
|
+
}),
|
|
446
|
+
container = _renderComponent32.container;
|
|
447
|
+
var foreignObject = container.querySelector('foreignObject');
|
|
448
|
+
expect(foreignObject).not.toBeInTheDocument();
|
|
449
|
+
});
|
|
450
|
+
it('should not render when correctData is undefined (correctness not incorrect)', function () {
|
|
451
|
+
var _renderComponent33 = renderComponent({
|
|
452
|
+
correctness: {
|
|
453
|
+
value: 'correct',
|
|
454
|
+
label: 'Correct'
|
|
455
|
+
},
|
|
456
|
+
correctData: undefined,
|
|
457
|
+
label: 'A'
|
|
458
|
+
}),
|
|
459
|
+
container = _renderComponent33.container;
|
|
460
|
+
var foreignObject = container.querySelector('foreignObject');
|
|
461
|
+
expect(foreignObject).not.toBeInTheDocument();
|
|
462
|
+
});
|
|
463
|
+
it('should parse string values correctly', function () {
|
|
464
|
+
var _renderComponent34 = renderComponent({
|
|
465
|
+
correctData: [{
|
|
466
|
+
label: 'D',
|
|
467
|
+
value: '45.5'
|
|
468
|
+
}],
|
|
469
|
+
label: 'D'
|
|
470
|
+
}),
|
|
471
|
+
container = _renderComponent34.container;
|
|
472
|
+
var foreignObject = container.querySelector('foreignObject');
|
|
473
|
+
expect(foreignObject).toBeInTheDocument();
|
|
474
|
+
expect(mockScale.y).toHaveBeenCalledWith(45.5);
|
|
475
|
+
});
|
|
476
|
+
it('should handle zero values', function () {
|
|
477
|
+
var _renderComponent35 = renderComponent({
|
|
478
|
+
correctData: [{
|
|
479
|
+
label: 'E',
|
|
480
|
+
value: 0
|
|
481
|
+
}],
|
|
482
|
+
label: 'E'
|
|
483
|
+
}),
|
|
484
|
+
container = _renderComponent35.container;
|
|
485
|
+
var foreignObject = container.querySelector('foreignObject');
|
|
486
|
+
expect(foreignObject).toBeInTheDocument();
|
|
487
|
+
expect(mockScale.y).toHaveBeenCalledWith(0);
|
|
488
|
+
});
|
|
489
|
+
it('should handle negative values', function () {
|
|
490
|
+
var _renderComponent36 = renderComponent({
|
|
491
|
+
correctData: [{
|
|
492
|
+
label: 'F',
|
|
493
|
+
value: -10
|
|
494
|
+
}],
|
|
495
|
+
label: 'F'
|
|
496
|
+
}),
|
|
497
|
+
container = _renderComponent36.container;
|
|
498
|
+
var foreignObject = container.querySelector('foreignObject');
|
|
499
|
+
expect(foreignObject).toBeInTheDocument();
|
|
500
|
+
expect(mockScale.y).toHaveBeenCalledWith(-10);
|
|
501
|
+
});
|
|
502
|
+
});
|
|
503
|
+
describe('icon properties', function () {
|
|
504
|
+
it('should render icon with correct title', function () {
|
|
505
|
+
var _renderComponent37 = renderComponent({
|
|
506
|
+
correctness: {
|
|
507
|
+
value: 'incorrect',
|
|
508
|
+
label: 'Not quite right'
|
|
509
|
+
},
|
|
510
|
+
label: 'A'
|
|
511
|
+
}),
|
|
512
|
+
getByTestId = _renderComponent37.getByTestId;
|
|
513
|
+
var icon = getByTestId('check-icon');
|
|
514
|
+
expect(icon).toHaveAttribute('title', 'Not quite right');
|
|
515
|
+
});
|
|
516
|
+
it('should render icon with small className', function () {
|
|
517
|
+
var _renderComponent38 = renderComponent({
|
|
518
|
+
label: 'A'
|
|
519
|
+
}),
|
|
520
|
+
getByTestId = _renderComponent38.getByTestId;
|
|
521
|
+
var icon = getByTestId('check-icon');
|
|
522
|
+
expect(icon).toHaveClass('small');
|
|
523
|
+
});
|
|
524
|
+
});
|
|
525
|
+
describe('edge cases', function () {
|
|
526
|
+
it('should handle missing label prop', function () {
|
|
527
|
+
var _renderComponent39 = renderComponent({
|
|
528
|
+
label: undefined
|
|
529
|
+
}),
|
|
530
|
+
container = _renderComponent39.container;
|
|
531
|
+
var foreignObject = container.querySelector('foreignObject');
|
|
532
|
+
expect(foreignObject).not.toBeInTheDocument();
|
|
533
|
+
});
|
|
534
|
+
it('should handle empty string label', function () {
|
|
535
|
+
var _renderComponent40 = renderComponent({
|
|
536
|
+
label: ''
|
|
537
|
+
}),
|
|
538
|
+
container = _renderComponent40.container;
|
|
539
|
+
var foreignObject = container.querySelector('foreignObject');
|
|
540
|
+
expect(foreignObject).not.toBeInTheDocument();
|
|
541
|
+
});
|
|
542
|
+
it('should handle very large values in correctData', function () {
|
|
543
|
+
var _renderComponent41 = renderComponent({
|
|
544
|
+
correctData: [{
|
|
545
|
+
label: 'G',
|
|
546
|
+
value: 999999
|
|
547
|
+
}],
|
|
548
|
+
label: 'G'
|
|
549
|
+
}),
|
|
550
|
+
container = _renderComponent41.container;
|
|
551
|
+
var foreignObject = container.querySelector('foreignObject');
|
|
552
|
+
expect(foreignObject).toBeInTheDocument();
|
|
553
|
+
expect(mockScale.y).toHaveBeenCalledWith(999999);
|
|
554
|
+
});
|
|
555
|
+
it('should only render for incorrect answers', function () {
|
|
556
|
+
var _renderComponent42 = renderComponent({
|
|
557
|
+
correctness: {
|
|
558
|
+
value: 'incorrect',
|
|
559
|
+
label: 'Wrong'
|
|
560
|
+
},
|
|
561
|
+
label: 'A'
|
|
562
|
+
}),
|
|
563
|
+
incorrectContainer = _renderComponent42.container;
|
|
564
|
+
expect(incorrectContainer.querySelector('foreignObject')).toBeInTheDocument();
|
|
565
|
+
var _renderComponent43 = renderComponent({
|
|
566
|
+
correctness: {
|
|
567
|
+
value: 'correct',
|
|
568
|
+
label: 'Right'
|
|
569
|
+
},
|
|
570
|
+
label: 'A'
|
|
571
|
+
}),
|
|
572
|
+
correctContainer = _renderComponent43.container;
|
|
573
|
+
expect(correctContainer.querySelector('foreignObject')).not.toBeInTheDocument();
|
|
574
|
+
});
|
|
575
|
+
});
|
|
576
|
+
});
|
|
577
|
+
describe('TickCorrectnessIndicator', function () {
|
|
578
|
+
beforeEach(function () {
|
|
579
|
+
jest.clearAllMocks();
|
|
580
|
+
});
|
|
581
|
+
var renderComponent = function renderComponent() {
|
|
582
|
+
var extras = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
583
|
+
var defaults = {
|
|
584
|
+
correctness: {
|
|
585
|
+
value: 'correct',
|
|
586
|
+
label: 'Correct Answer'
|
|
587
|
+
},
|
|
588
|
+
interactive: true
|
|
589
|
+
};
|
|
590
|
+
var props = _objectSpread(_objectSpread({}, defaults), extras);
|
|
591
|
+
return (0, _react2.render)(/*#__PURE__*/_react["default"].createElement(_styles.ThemeProvider, {
|
|
592
|
+
theme: theme
|
|
593
|
+
}, /*#__PURE__*/_react["default"].createElement(_correctnessIndicators.TickCorrectnessIndicator, props)));
|
|
594
|
+
};
|
|
595
|
+
describe('rendering', function () {
|
|
596
|
+
it('should render without crashing', function () {
|
|
597
|
+
var _renderComponent44 = renderComponent(),
|
|
598
|
+
container = _renderComponent44.container;
|
|
599
|
+
expect(container).toBeInTheDocument();
|
|
600
|
+
});
|
|
601
|
+
it('should render check icon for correct answer', function () {
|
|
602
|
+
var _renderComponent45 = renderComponent({
|
|
603
|
+
correctness: {
|
|
604
|
+
value: 'correct',
|
|
605
|
+
label: 'Correct'
|
|
606
|
+
}
|
|
607
|
+
}),
|
|
608
|
+
getByTestId = _renderComponent45.getByTestId;
|
|
609
|
+
expect(getByTestId('check-icon')).toBeInTheDocument();
|
|
610
|
+
});
|
|
611
|
+
it('should render close icon for incorrect answer', function () {
|
|
612
|
+
var _renderComponent46 = renderComponent({
|
|
613
|
+
correctness: {
|
|
614
|
+
value: 'incorrect',
|
|
615
|
+
label: 'Incorrect'
|
|
616
|
+
}
|
|
617
|
+
}),
|
|
618
|
+
getByTestId = _renderComponent46.getByTestId;
|
|
619
|
+
expect(getByTestId('close-icon')).toBeInTheDocument();
|
|
620
|
+
});
|
|
621
|
+
it('should not render when correctness is null', function () {
|
|
622
|
+
var _renderComponent47 = renderComponent({
|
|
623
|
+
correctness: null
|
|
624
|
+
}),
|
|
625
|
+
queryByTestId = _renderComponent47.queryByTestId;
|
|
626
|
+
expect(queryByTestId('check-icon')).not.toBeInTheDocument();
|
|
627
|
+
expect(queryByTestId('close-icon')).not.toBeInTheDocument();
|
|
628
|
+
});
|
|
629
|
+
it('should not render when correctness is undefined', function () {
|
|
630
|
+
var _renderComponent48 = renderComponent({
|
|
631
|
+
correctness: undefined
|
|
632
|
+
}),
|
|
633
|
+
queryByTestId = _renderComponent48.queryByTestId;
|
|
634
|
+
expect(queryByTestId('check-icon')).not.toBeInTheDocument();
|
|
635
|
+
expect(queryByTestId('close-icon')).not.toBeInTheDocument();
|
|
636
|
+
});
|
|
637
|
+
it('should not render when interactive is false', function () {
|
|
638
|
+
var _renderComponent49 = renderComponent({
|
|
639
|
+
interactive: false
|
|
640
|
+
}),
|
|
641
|
+
queryByTestId = _renderComponent49.queryByTestId;
|
|
642
|
+
expect(queryByTestId('check-icon')).not.toBeInTheDocument();
|
|
643
|
+
expect(queryByTestId('close-icon')).not.toBeInTheDocument();
|
|
644
|
+
});
|
|
645
|
+
it('should render with correct title for correct answer', function () {
|
|
646
|
+
var _renderComponent50 = renderComponent({
|
|
647
|
+
correctness: {
|
|
648
|
+
value: 'correct',
|
|
649
|
+
label: 'Great job!'
|
|
650
|
+
}
|
|
651
|
+
}),
|
|
652
|
+
getByTestId = _renderComponent50.getByTestId;
|
|
653
|
+
var icon = getByTestId('check-icon');
|
|
654
|
+
expect(icon).toHaveAttribute('title', 'Great job!');
|
|
655
|
+
});
|
|
656
|
+
it('should render with correct title for incorrect answer', function () {
|
|
657
|
+
var _renderComponent51 = renderComponent({
|
|
658
|
+
correctness: {
|
|
659
|
+
value: 'incorrect',
|
|
660
|
+
label: 'Not correct'
|
|
661
|
+
}
|
|
662
|
+
}),
|
|
663
|
+
getByTestId = _renderComponent51.getByTestId;
|
|
664
|
+
var icon = getByTestId('close-icon');
|
|
665
|
+
expect(icon).toHaveAttribute('title', 'Not correct');
|
|
666
|
+
});
|
|
667
|
+
});
|
|
668
|
+
describe('interactive flag', function () {
|
|
669
|
+
it('should render when interactive is true', function () {
|
|
670
|
+
var _renderComponent52 = renderComponent({
|
|
671
|
+
interactive: true,
|
|
672
|
+
correctness: {
|
|
673
|
+
value: 'correct',
|
|
674
|
+
label: 'Test'
|
|
675
|
+
}
|
|
676
|
+
}),
|
|
677
|
+
getByTestId = _renderComponent52.getByTestId;
|
|
678
|
+
expect(getByTestId('check-icon')).toBeInTheDocument();
|
|
679
|
+
});
|
|
680
|
+
it('should not render when interactive is false', function () {
|
|
681
|
+
var _renderComponent53 = renderComponent({
|
|
682
|
+
interactive: false,
|
|
683
|
+
correctness: {
|
|
684
|
+
value: 'correct',
|
|
685
|
+
label: 'Test'
|
|
686
|
+
}
|
|
687
|
+
}),
|
|
688
|
+
queryByTestId = _renderComponent53.queryByTestId;
|
|
689
|
+
expect(queryByTestId('check-icon')).not.toBeInTheDocument();
|
|
690
|
+
});
|
|
691
|
+
it('should not render when interactive is undefined', function () {
|
|
692
|
+
var _renderComponent54 = renderComponent({
|
|
693
|
+
interactive: undefined,
|
|
694
|
+
correctness: {
|
|
695
|
+
value: 'correct',
|
|
696
|
+
label: 'Test'
|
|
697
|
+
}
|
|
698
|
+
}),
|
|
699
|
+
queryByTestId = _renderComponent54.queryByTestId;
|
|
700
|
+
expect(queryByTestId('check-icon')).not.toBeInTheDocument();
|
|
701
|
+
});
|
|
702
|
+
it('should not render when interactive is null', function () {
|
|
703
|
+
var _renderComponent55 = renderComponent({
|
|
704
|
+
interactive: null,
|
|
705
|
+
correctness: {
|
|
706
|
+
value: 'correct',
|
|
707
|
+
label: 'Test'
|
|
708
|
+
}
|
|
709
|
+
}),
|
|
710
|
+
queryByTestId = _renderComponent55.queryByTestId;
|
|
711
|
+
expect(queryByTestId('check-icon')).not.toBeInTheDocument();
|
|
712
|
+
});
|
|
713
|
+
});
|
|
714
|
+
describe('correctness values', function () {
|
|
715
|
+
it('should render check icon when value is "correct"', function () {
|
|
716
|
+
var _renderComponent56 = renderComponent({
|
|
717
|
+
correctness: {
|
|
718
|
+
value: 'correct',
|
|
719
|
+
label: 'Test'
|
|
720
|
+
}
|
|
721
|
+
}),
|
|
722
|
+
getByTestId = _renderComponent56.getByTestId,
|
|
723
|
+
queryByTestId = _renderComponent56.queryByTestId;
|
|
724
|
+
expect(getByTestId('check-icon')).toBeInTheDocument();
|
|
725
|
+
expect(queryByTestId('close-icon')).not.toBeInTheDocument();
|
|
726
|
+
});
|
|
727
|
+
it('should render close icon when value is "incorrect"', function () {
|
|
728
|
+
var _renderComponent57 = renderComponent({
|
|
729
|
+
correctness: {
|
|
730
|
+
value: 'incorrect',
|
|
731
|
+
label: 'Test'
|
|
732
|
+
}
|
|
733
|
+
}),
|
|
734
|
+
getByTestId = _renderComponent57.getByTestId,
|
|
735
|
+
queryByTestId = _renderComponent57.queryByTestId;
|
|
736
|
+
expect(getByTestId('close-icon')).toBeInTheDocument();
|
|
737
|
+
expect(queryByTestId('check-icon')).not.toBeInTheDocument();
|
|
738
|
+
});
|
|
739
|
+
it('should render close icon for any value other than "correct"', function () {
|
|
740
|
+
var _renderComponent58 = renderComponent({
|
|
741
|
+
correctness: {
|
|
742
|
+
value: 'partial',
|
|
743
|
+
label: 'Test'
|
|
744
|
+
}
|
|
745
|
+
}),
|
|
746
|
+
getByTestId = _renderComponent58.getByTestId;
|
|
747
|
+
expect(getByTestId('close-icon')).toBeInTheDocument();
|
|
748
|
+
});
|
|
749
|
+
it('should handle empty value string', function () {
|
|
750
|
+
var _renderComponent59 = renderComponent({
|
|
751
|
+
correctness: {
|
|
752
|
+
value: '',
|
|
753
|
+
label: 'Test'
|
|
754
|
+
}
|
|
755
|
+
}),
|
|
756
|
+
getByTestId = _renderComponent59.getByTestId;
|
|
757
|
+
expect(getByTestId('close-icon')).toBeInTheDocument();
|
|
758
|
+
});
|
|
759
|
+
});
|
|
760
|
+
describe('edge cases', function () {
|
|
761
|
+
it('should handle correctness with empty label', function () {
|
|
762
|
+
var _renderComponent60 = renderComponent({
|
|
763
|
+
correctness: {
|
|
764
|
+
value: 'correct',
|
|
765
|
+
label: ''
|
|
766
|
+
}
|
|
767
|
+
}),
|
|
768
|
+
getByTestId = _renderComponent60.getByTestId;
|
|
769
|
+
var icon = getByTestId('check-icon');
|
|
770
|
+
expect(icon).toHaveAttribute('title', '');
|
|
771
|
+
});
|
|
772
|
+
it('should handle correctness with undefined label', function () {
|
|
773
|
+
var _renderComponent61 = renderComponent({
|
|
774
|
+
correctness: {
|
|
775
|
+
value: 'correct',
|
|
776
|
+
label: undefined
|
|
777
|
+
}
|
|
778
|
+
}),
|
|
779
|
+
getByTestId = _renderComponent61.getByTestId;
|
|
780
|
+
expect(getByTestId('check-icon')).toBeInTheDocument();
|
|
781
|
+
});
|
|
782
|
+
it('should handle correctness with null value', function () {
|
|
783
|
+
var _renderComponent62 = renderComponent({
|
|
784
|
+
correctness: {
|
|
785
|
+
value: null,
|
|
786
|
+
label: 'Test'
|
|
787
|
+
}
|
|
788
|
+
}),
|
|
789
|
+
queryByTestId = _renderComponent62.queryByTestId;
|
|
790
|
+
expect(queryByTestId('close-icon')).toBeInTheDocument();
|
|
791
|
+
});
|
|
792
|
+
it('should require both correctness and interactive to render', function () {
|
|
793
|
+
var _renderComponent63 = renderComponent({
|
|
794
|
+
correctness: {
|
|
795
|
+
value: 'correct',
|
|
796
|
+
label: 'Test'
|
|
797
|
+
},
|
|
798
|
+
interactive: false
|
|
799
|
+
}),
|
|
800
|
+
query1 = _renderComponent63.queryByTestId;
|
|
801
|
+
expect(query1('check-icon')).not.toBeInTheDocument();
|
|
802
|
+
var _renderComponent64 = renderComponent({
|
|
803
|
+
correctness: null,
|
|
804
|
+
interactive: true
|
|
805
|
+
}),
|
|
806
|
+
query2 = _renderComponent64.queryByTestId;
|
|
807
|
+
expect(query2('check-icon')).not.toBeInTheDocument();
|
|
808
|
+
});
|
|
809
|
+
it('should handle special characters in label', function () {
|
|
810
|
+
var _renderComponent65 = renderComponent({
|
|
811
|
+
correctness: {
|
|
812
|
+
value: 'correct',
|
|
813
|
+
label: 'Test <>&"'
|
|
814
|
+
}
|
|
815
|
+
}),
|
|
816
|
+
getByTestId = _renderComponent65.getByTestId;
|
|
817
|
+
var icon = getByTestId('check-icon');
|
|
818
|
+
expect(icon).toHaveAttribute('title', 'Test <>&"');
|
|
819
|
+
});
|
|
820
|
+
it('should handle unicode characters in label', function () {
|
|
821
|
+
var _renderComponent66 = renderComponent({
|
|
822
|
+
correctness: {
|
|
823
|
+
value: 'correct',
|
|
824
|
+
label: 'Test 你好 🎉'
|
|
825
|
+
}
|
|
826
|
+
}),
|
|
827
|
+
getByTestId = _renderComponent66.getByTestId;
|
|
828
|
+
var icon = getByTestId('check-icon');
|
|
829
|
+
expect(icon).toHaveAttribute('title', 'Test 你好 🎉');
|
|
830
|
+
});
|
|
831
|
+
it('should handle very long labels', function () {
|
|
832
|
+
var longLabel = 'This is a very long label that might cause layout issues in the UI';
|
|
833
|
+
var _renderComponent67 = renderComponent({
|
|
834
|
+
correctness: {
|
|
835
|
+
value: 'correct',
|
|
836
|
+
label: longLabel
|
|
837
|
+
}
|
|
838
|
+
}),
|
|
839
|
+
getByTestId = _renderComponent67.getByTestId;
|
|
840
|
+
var icon = getByTestId('check-icon');
|
|
841
|
+
expect(icon).toHaveAttribute('title', longLabel);
|
|
842
|
+
});
|
|
843
|
+
});
|
|
844
|
+
describe('component consistency', function () {
|
|
845
|
+
it('should render same icon type consistently for same correctness value', function () {
|
|
846
|
+
var _renderComponent68 = renderComponent({
|
|
847
|
+
correctness: {
|
|
848
|
+
value: 'correct',
|
|
849
|
+
label: 'Test 1'
|
|
850
|
+
}
|
|
851
|
+
}),
|
|
852
|
+
getByTestId = _renderComponent68.getByTestId,
|
|
853
|
+
unmount = _renderComponent68.unmount;
|
|
854
|
+
expect(getByTestId('check-icon')).toBeInTheDocument();
|
|
855
|
+
unmount();
|
|
856
|
+
var _renderComponent69 = renderComponent({
|
|
857
|
+
correctness: {
|
|
858
|
+
value: 'correct',
|
|
859
|
+
label: 'Test 2'
|
|
860
|
+
}
|
|
861
|
+
}),
|
|
862
|
+
get2 = _renderComponent69.getByTestId;
|
|
863
|
+
expect(get2('check-icon')).toBeInTheDocument();
|
|
864
|
+
});
|
|
865
|
+
it('should render different icons for different correctness values', function () {
|
|
866
|
+
var _renderComponent70 = renderComponent({
|
|
867
|
+
correctness: {
|
|
868
|
+
value: 'correct',
|
|
869
|
+
label: 'Correct'
|
|
870
|
+
}
|
|
871
|
+
}),
|
|
872
|
+
getByTestId = _renderComponent70.getByTestId,
|
|
873
|
+
unmount = _renderComponent70.unmount;
|
|
874
|
+
expect(getByTestId('check-icon')).toBeInTheDocument();
|
|
875
|
+
unmount();
|
|
876
|
+
var _renderComponent71 = renderComponent({
|
|
877
|
+
correctness: {
|
|
878
|
+
value: 'incorrect',
|
|
879
|
+
label: 'Incorrect'
|
|
880
|
+
}
|
|
881
|
+
}),
|
|
882
|
+
get2 = _renderComponent71.getByTestId;
|
|
883
|
+
expect(get2('close-icon')).toBeInTheDocument();
|
|
884
|
+
});
|
|
885
|
+
});
|
|
886
|
+
});
|
|
887
|
+
//# sourceMappingURL=correctness-indicators.test.js.map
|