@pie-lib/mask-markup 3.0.13 → 3.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.
@@ -0,0 +1,293 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _typeof = require("@babel/runtime/helpers/typeof");
5
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
6
+ var React = _interopRequireWildcard(require("react"));
7
+ var _react2 = require("@testing-library/react");
8
+ var _blank = _interopRequireDefault(require("../blank"));
9
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
10
+ // Mock @dnd-kit hooks to avoid DndContext requirement
11
+ jest.mock('@dnd-kit/core', function () {
12
+ return {
13
+ useDraggable: jest.fn(function () {
14
+ return {
15
+ attributes: {},
16
+ listeners: {},
17
+ setNodeRef: jest.fn(),
18
+ transform: null,
19
+ isDragging: false
20
+ };
21
+ }),
22
+ useDroppable: jest.fn(function () {
23
+ return {
24
+ setNodeRef: jest.fn(),
25
+ isOver: false,
26
+ active: null
27
+ };
28
+ })
29
+ };
30
+ });
31
+ jest.mock('@dnd-kit/utilities', function () {
32
+ return {
33
+ CSS: {
34
+ Translate: {
35
+ toString: jest.fn(function () {
36
+ return 'translate3d(0, 0, 0)';
37
+ })
38
+ }
39
+ }
40
+ };
41
+ });
42
+ jest.mock('@pie-lib/math-rendering', function () {
43
+ return {
44
+ renderMath: jest.fn()
45
+ };
46
+ });
47
+
48
+ // Collect the CSS rules emotion/MUI injected into the document (jsdom uses insertRule).
49
+ var collectEmotionRules = function collectEmotionRules() {
50
+ var rules = [];
51
+ for (var _i = 0, _Array$from = Array.from(document.styleSheets); _i < _Array$from.length; _i++) {
52
+ var sheet = _Array$from[_i];
53
+ try {
54
+ for (var _i2 = 0, _Array$from2 = Array.from(sheet.cssRules); _i2 < _Array$from2.length; _i2++) {
55
+ var rule = _Array$from2[_i2];
56
+ rules.push(rule.cssText);
57
+ }
58
+ } catch (e) {
59
+ /* inaccessible stylesheet */
60
+ }
61
+ }
62
+ return rules;
63
+ };
64
+ describe('Blank', function () {
65
+ var _require = require('@pie-lib/math-rendering'),
66
+ renderMath = _require.renderMath;
67
+ var onChange = jest.fn();
68
+ var defaultProps = {
69
+ disabled: false,
70
+ choice: {
71
+ value: 'Cow'
72
+ },
73
+ isOver: false,
74
+ dragItem: {},
75
+ correct: false,
76
+ onChange: onChange
77
+ };
78
+ beforeEach(function () {
79
+ onChange.mockClear();
80
+ renderMath.mockClear();
81
+ });
82
+ describe('rendering', function () {
83
+ it('renders with default props', function () {
84
+ var _render = (0, _react2.render)(/*#__PURE__*/React.createElement(_blank["default"], defaultProps)),
85
+ container = _render.container;
86
+ expect(container.firstChild).toBeInTheDocument();
87
+ });
88
+ it('displays the value when provided', function () {
89
+ (0, _react2.render)(/*#__PURE__*/React.createElement(_blank["default"], defaultProps));
90
+ expect(_react2.screen.getByText('Cow')).toBeInTheDocument();
91
+ });
92
+ it('renders as disabled when disabled prop is true', function () {
93
+ (0, _react2.render)(/*#__PURE__*/React.createElement(_blank["default"], (0, _extends2["default"])({}, defaultProps, {
94
+ disabled: true
95
+ })));
96
+ // Check that delete button is not present when disabled
97
+ expect(_react2.screen.queryByRole('button', {
98
+ name: /delete/i
99
+ })).not.toBeInTheDocument();
100
+ });
101
+ it('renders with dragged item preview', function () {
102
+ (0, _react2.render)(/*#__PURE__*/React.createElement(_blank["default"], (0, _extends2["default"])({}, defaultProps, {
103
+ dragItem: {
104
+ choice: {
105
+ value: 'Dog'
106
+ }
107
+ }
108
+ })));
109
+ // Blank component should render
110
+ expect(_react2.screen.getByText('Cow')).toBeInTheDocument();
111
+ });
112
+ it('shows hover state when isOver is true', function () {
113
+ var _render2 = (0, _react2.render)(/*#__PURE__*/React.createElement(_blank["default"], (0, _extends2["default"])({}, defaultProps, {
114
+ dragItem: {
115
+ choice: {
116
+ value: 'Dog'
117
+ }
118
+ },
119
+ isOver: true
120
+ }))),
121
+ container = _render2.container;
122
+ // Component should have hover styling
123
+ expect(container.firstChild).toBeInTheDocument();
124
+ });
125
+ it('shows correct state when correct is true', function () {
126
+ var _render3 = (0, _react2.render)(/*#__PURE__*/React.createElement(_blank["default"], (0, _extends2["default"])({}, defaultProps, {
127
+ correct: true
128
+ }))),
129
+ container = _render3.container;
130
+ // Component should indicate correctness
131
+ expect(container.firstChild).toBeInTheDocument();
132
+ });
133
+ });
134
+ describe('delete functionality', function () {
135
+ it('does not show delete button when disabled', function () {
136
+ (0, _react2.render)(/*#__PURE__*/React.createElement(_blank["default"], (0, _extends2["default"])({}, defaultProps, {
137
+ disabled: true
138
+ })));
139
+ expect(_react2.screen.queryByRole('button', {
140
+ name: /delete/i
141
+ })).not.toBeInTheDocument();
142
+ });
143
+ it('does not show delete button when no value is set', function () {
144
+ (0, _react2.render)(/*#__PURE__*/React.createElement(_blank["default"], (0, _extends2["default"])({}, defaultProps, {
145
+ choice: undefined
146
+ })));
147
+ expect(_react2.screen.queryByRole('button', {
148
+ name: /delete/i
149
+ })).not.toBeInTheDocument();
150
+ });
151
+ it('shows delete button when value is present and not disabled', function () {
152
+ (0, _react2.render)(/*#__PURE__*/React.createElement(_blank["default"], defaultProps));
153
+ // If delete button is present, it should be clickable
154
+ var deleteButton = _react2.screen.queryByRole('button');
155
+ if (deleteButton) {
156
+ expect(deleteButton).toBeInTheDocument();
157
+ }
158
+ });
159
+ });
160
+ describe('dimensions', function () {
161
+ it('renders with custom dimensions when provided', function () {
162
+ var _render4 = (0, _react2.render)(/*#__PURE__*/React.createElement(_blank["default"], (0, _extends2["default"])({}, defaultProps, {
163
+ emptyResponseAreaHeight: 100,
164
+ emptyResponseAreaWidth: 200
165
+ }))),
166
+ container = _render4.container;
167
+ var element = container.firstChild;
168
+ expect(element).toBeInTheDocument();
169
+ });
170
+ it('renders with min dimensions by default', function () {
171
+ var _render5 = (0, _react2.render)(/*#__PURE__*/React.createElement(_blank["default"], defaultProps)),
172
+ container = _render5.container;
173
+ var element = container.firstChild;
174
+ expect(element).toBeInTheDocument();
175
+ // Component should have minimum dimensions applied
176
+ });
177
+ it('handles non-numeric dimension props gracefully', function () {
178
+ var _render6 = (0, _react2.render)(/*#__PURE__*/React.createElement(_blank["default"], (0, _extends2["default"])({}, defaultProps, {
179
+ emptyResponseAreaHeight: "non-numeric",
180
+ emptyResponseAreaWidth: "non-numeric"
181
+ }))),
182
+ container = _render6.container;
183
+ expect(container.firstChild).toBeInTheDocument();
184
+ });
185
+ it('computes chip dimensions based on content when no emptyResponseArea size is provided', function () {
186
+ jest.useFakeTimers();
187
+ // Mock getBoundingClientRect to simulate measured content size
188
+ var rectSpy = jest.spyOn(HTMLElement.prototype, 'getBoundingClientRect').mockReturnValue({
189
+ width: 100,
190
+ height: 20,
191
+ top: 0,
192
+ left: 0,
193
+ right: 100,
194
+ bottom: 20
195
+ });
196
+ var _render7 = (0, _react2.render)(/*#__PURE__*/React.createElement(_blank["default"], (0, _extends2["default"])({}, defaultProps, {
197
+ // Force measurement path that uses getMeasureNode / updateDimensions
198
+ emptyResponseAreaHeight: 0,
199
+ emptyResponseAreaWidth: 0
200
+ }))),
201
+ container = _render7.container;
202
+
203
+ // Let the internal timeout in handleElements / updateDimensions run
204
+ (0, _react2.act)(function () {
205
+ jest.runAllTimers();
206
+ });
207
+ var wrapper = container.firstChild; // StyledContent
208
+ var chip = wrapper && wrapper.firstChild; // StyledChip (rootRef)
209
+
210
+ // Width and height should include padding (24px) around measured content
211
+ expect(chip.style.width).toBe('129px');
212
+ expect(chip.style.height).toBe('49px');
213
+ rectSpy.mockRestore();
214
+ jest.useRealTimers();
215
+ });
216
+ });
217
+ describe('math rendering', function () {
218
+ it('calls renderMath on mount when choice has content', function () {
219
+ (0, _react2.render)(/*#__PURE__*/React.createElement(_blank["default"], defaultProps));
220
+ expect(renderMath).toHaveBeenCalled();
221
+ });
222
+ it('calls renderMath again when correct changes', function () {
223
+ var _render8 = (0, _react2.render)(/*#__PURE__*/React.createElement(_blank["default"], (0, _extends2["default"])({}, defaultProps, {
224
+ correct: false
225
+ }))),
226
+ rerender = _render8.rerender;
227
+ var callsAfterMount = renderMath.mock.calls.length;
228
+ expect(callsAfterMount).toBeGreaterThan(0);
229
+ rerender(/*#__PURE__*/React.createElement(_blank["default"], (0, _extends2["default"])({}, defaultProps, {
230
+ correct: true
231
+ })));
232
+ expect(renderMath.mock.calls.length).toBeGreaterThan(callsAfterMount);
233
+ });
234
+ it('does not call renderMath again when correct is unchanged', function () {
235
+ var _render9 = (0, _react2.render)(/*#__PURE__*/React.createElement(_blank["default"], (0, _extends2["default"])({}, defaultProps, {
236
+ correct: true
237
+ }))),
238
+ rerender = _render9.rerender;
239
+ var callsAfterMount = renderMath.mock.calls.length;
240
+ rerender(/*#__PURE__*/React.createElement(_blank["default"], (0, _extends2["default"])({}, defaultProps, {
241
+ correct: true
242
+ })));
243
+ expect(renderMath.mock.calls.length).toBe(callsAfterMount);
244
+ });
245
+ });
246
+ describe('fraction math styling', function () {
247
+ it('enlarges numerator/denominator digits adjacent to a fraction to 120%', function () {
248
+ (0, _react2.render)(/*#__PURE__*/React.createElement(_blank["default"], defaultProps));
249
+ var rule = collectEmotionRules().find(function (r) {
250
+ return r.includes('mjx-mn') && r.includes('mjx-mfrac');
251
+ });
252
+ expect(rule).toBeDefined();
253
+ expect(rule).toMatch(/mjx-mn:has\(~\s*mjx-mfrac\)/);
254
+ expect(rule).toMatch(/mjx-mfrac\s*~\s*mjx-mn/);
255
+ expect(rule).toMatch(/font-size:\s*120%\s*!important/i);
256
+ });
257
+ it('keeps the existing mjx-frac 120% rule', function () {
258
+ (0, _react2.render)(/*#__PURE__*/React.createElement(_blank["default"], defaultProps));
259
+ var rule = collectEmotionRules().find(function (r) {
260
+ return /(^|[^-])mjx-frac/.test(r) && !r.includes('mjx-mfrac');
261
+ });
262
+ expect(rule).toBeDefined();
263
+ expect(rule).toMatch(/font-size:\s*120%\s*!important/i);
264
+ });
265
+ });
266
+ describe('drag and drop', function () {
267
+ it('accepts drag item when not disabled', function () {
268
+ (0, _react2.render)(/*#__PURE__*/React.createElement(_blank["default"], (0, _extends2["default"])({}, defaultProps, {
269
+ isOver: true,
270
+ dragItem: {
271
+ choice: {
272
+ value: 'Dog'
273
+ }
274
+ }
275
+ })));
276
+ expect(_react2.screen.getByText('Cow')).toBeInTheDocument();
277
+ });
278
+ it('shows drag preview when dragging over', function () {
279
+ var _render0 = (0, _react2.render)(/*#__PURE__*/React.createElement(_blank["default"], (0, _extends2["default"])({}, defaultProps, {
280
+ isOver: true,
281
+ dragItem: {
282
+ choice: {
283
+ value: 'Dog'
284
+ }
285
+ }
286
+ }))),
287
+ container = _render0.container;
288
+ expect(container.firstChild).toBeInTheDocument();
289
+ // Should show visual feedback for drag over
290
+ });
291
+ });
292
+ });
293
+ //# sourceMappingURL=blank.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"blank.test.js","names":["React","_interopRequireWildcard","require","_react2","_blank","_interopRequireDefault","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","_typeof","has","get","set","_t","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","jest","mock","useDraggable","fn","attributes","listeners","setNodeRef","transform","isDragging","useDroppable","isOver","active","CSS","Translate","toString","renderMath","collectEmotionRules","rules","_i","_Array$from","Array","from","document","styleSheets","length","sheet","_i2","_Array$from2","cssRules","rule","push","cssText","describe","_require","onChange","defaultProps","disabled","choice","value","dragItem","correct","beforeEach","mockClear","it","_render","render","createElement","container","expect","firstChild","toBeInTheDocument","screen","getByText","_extends2","queryByRole","name","not","_render2","_render3","undefined","deleteButton","_render4","emptyResponseAreaHeight","emptyResponseAreaWidth","element","_render5","_render6","useFakeTimers","rectSpy","spyOn","HTMLElement","prototype","mockReturnValue","width","height","top","left","right","bottom","_render7","act","runAllTimers","wrapper","chip","style","toBe","mockRestore","useRealTimers","toHaveBeenCalled","_render8","rerender","callsAfterMount","calls","toBeGreaterThan","_render9","find","includes","toBeDefined","toMatch","test","_render0"],"sources":["../../../src/components/__tests__/blank.test.js"],"sourcesContent":["import * as React from 'react';\nimport { render, screen, act } from '@testing-library/react';\nimport Blank from '../blank';\n\n// Mock @dnd-kit hooks to avoid DndContext requirement\njest.mock('@dnd-kit/core', () => ({\n useDraggable: jest.fn(() => ({\n attributes: {},\n listeners: {},\n setNodeRef: jest.fn(),\n transform: null,\n isDragging: false,\n })),\n useDroppable: jest.fn(() => ({\n setNodeRef: jest.fn(),\n isOver: false,\n active: null,\n })),\n}));\n\njest.mock('@dnd-kit/utilities', () => ({\n CSS: {\n Translate: {\n toString: jest.fn(() => 'translate3d(0, 0, 0)'),\n },\n },\n}));\n\njest.mock('@pie-lib/math-rendering', () => ({\n renderMath: jest.fn(),\n}));\n\n// Collect the CSS rules emotion/MUI injected into the document (jsdom uses insertRule).\nconst collectEmotionRules = () => {\n const rules = [];\n for (const sheet of Array.from(document.styleSheets)) {\n try {\n for (const rule of Array.from(sheet.cssRules)) {\n rules.push(rule.cssText);\n }\n } catch (e) {\n /* inaccessible stylesheet */\n }\n }\n return rules;\n};\n\ndescribe('Blank', () => {\n const { renderMath } = require('@pie-lib/math-rendering');\n const onChange = jest.fn();\n const defaultProps = {\n disabled: false,\n choice: { value: 'Cow' },\n isOver: false,\n dragItem: {},\n correct: false,\n onChange,\n };\n\n beforeEach(() => {\n onChange.mockClear();\n renderMath.mockClear();\n });\n\n describe('rendering', () => {\n it('renders with default props', () => {\n const { container } = render(<Blank {...defaultProps} />);\n expect(container.firstChild).toBeInTheDocument();\n });\n\n it('displays the value when provided', () => {\n render(<Blank {...defaultProps} />);\n expect(screen.getByText('Cow')).toBeInTheDocument();\n });\n\n it('renders as disabled when disabled prop is true', () => {\n render(<Blank {...defaultProps} disabled={true} />);\n // Check that delete button is not present when disabled\n expect(screen.queryByRole('button', { name: /delete/i })).not.toBeInTheDocument();\n });\n\n it('renders with dragged item preview', () => {\n render(<Blank {...defaultProps} dragItem={{ choice: { value: 'Dog' } }} />);\n // Blank component should render\n expect(screen.getByText('Cow')).toBeInTheDocument();\n });\n\n it('shows hover state when isOver is true', () => {\n const { container } = render(<Blank {...defaultProps} dragItem={{ choice: { value: 'Dog' } }} isOver={true} />);\n // Component should have hover styling\n expect(container.firstChild).toBeInTheDocument();\n });\n\n it('shows correct state when correct is true', () => {\n const { container } = render(<Blank {...defaultProps} correct={true} />);\n // Component should indicate correctness\n expect(container.firstChild).toBeInTheDocument();\n });\n });\n\n describe('delete functionality', () => {\n it('does not show delete button when disabled', () => {\n render(<Blank {...defaultProps} disabled={true} />);\n expect(screen.queryByRole('button', { name: /delete/i })).not.toBeInTheDocument();\n });\n\n it('does not show delete button when no value is set', () => {\n render(<Blank {...defaultProps} choice={undefined} />);\n expect(screen.queryByRole('button', { name: /delete/i })).not.toBeInTheDocument();\n });\n\n it('shows delete button when value is present and not disabled', () => {\n render(<Blank {...defaultProps} />);\n // If delete button is present, it should be clickable\n const deleteButton = screen.queryByRole('button');\n if (deleteButton) {\n expect(deleteButton).toBeInTheDocument();\n }\n });\n });\n\n describe('dimensions', () => {\n it('renders with custom dimensions when provided', () => {\n const { container } = render(\n <Blank {...defaultProps} emptyResponseAreaHeight={100} emptyResponseAreaWidth={200} />,\n );\n const element = container.firstChild;\n expect(element).toBeInTheDocument();\n });\n\n it('renders with min dimensions by default', () => {\n const { container } = render(<Blank {...defaultProps} />);\n const element = container.firstChild;\n expect(element).toBeInTheDocument();\n // Component should have minimum dimensions applied\n });\n\n it('handles non-numeric dimension props gracefully', () => {\n const { container } = render(\n <Blank {...defaultProps} emptyResponseAreaHeight=\"non-numeric\" emptyResponseAreaWidth=\"non-numeric\" />,\n );\n expect(container.firstChild).toBeInTheDocument();\n });\n\n it('computes chip dimensions based on content when no emptyResponseArea size is provided', () => {\n jest.useFakeTimers();\n // Mock getBoundingClientRect to simulate measured content size\n const rectSpy = jest\n .spyOn(HTMLElement.prototype, 'getBoundingClientRect')\n .mockReturnValue({ width: 100, height: 20, top: 0, left: 0, right: 100, bottom: 20 });\n\n const { container } = render(\n <Blank\n {...defaultProps}\n // Force measurement path that uses getMeasureNode / updateDimensions\n emptyResponseAreaHeight={0}\n emptyResponseAreaWidth={0}\n />,\n );\n\n // Let the internal timeout in handleElements / updateDimensions run\n act(() => {\n jest.runAllTimers();\n });\n\n const wrapper = container.firstChild; // StyledContent\n const chip = wrapper && wrapper.firstChild; // StyledChip (rootRef)\n\n // Width and height should include padding (24px) around measured content\n expect(chip.style.width).toBe('129px');\n expect(chip.style.height).toBe('49px');\n\n rectSpy.mockRestore();\n jest.useRealTimers();\n });\n });\n\n describe('math rendering', () => {\n it('calls renderMath on mount when choice has content', () => {\n render(<Blank {...defaultProps} />);\n expect(renderMath).toHaveBeenCalled();\n });\n\n it('calls renderMath again when correct changes', () => {\n const { rerender } = render(<Blank {...defaultProps} correct={false} />);\n const callsAfterMount = renderMath.mock.calls.length;\n expect(callsAfterMount).toBeGreaterThan(0);\n\n rerender(<Blank {...defaultProps} correct={true} />);\n expect(renderMath.mock.calls.length).toBeGreaterThan(callsAfterMount);\n });\n\n it('does not call renderMath again when correct is unchanged', () => {\n const { rerender } = render(<Blank {...defaultProps} correct={true} />);\n const callsAfterMount = renderMath.mock.calls.length;\n\n rerender(<Blank {...defaultProps} correct={true} />);\n expect(renderMath.mock.calls.length).toBe(callsAfterMount);\n });\n });\n\n describe('fraction math styling', () => {\n it('enlarges numerator/denominator digits adjacent to a fraction to 120%', () => {\n render(<Blank {...defaultProps} />);\n const rule = collectEmotionRules().find((r) => r.includes('mjx-mn') && r.includes('mjx-mfrac'));\n expect(rule).toBeDefined();\n expect(rule).toMatch(/mjx-mn:has\\(~\\s*mjx-mfrac\\)/);\n expect(rule).toMatch(/mjx-mfrac\\s*~\\s*mjx-mn/);\n expect(rule).toMatch(/font-size:\\s*120%\\s*!important/i);\n });\n\n it('keeps the existing mjx-frac 120% rule', () => {\n render(<Blank {...defaultProps} />);\n const rule = collectEmotionRules().find((r) => /(^|[^-])mjx-frac/.test(r) && !r.includes('mjx-mfrac'));\n expect(rule).toBeDefined();\n expect(rule).toMatch(/font-size:\\s*120%\\s*!important/i);\n });\n });\n\n describe('drag and drop', () => {\n it('accepts drag item when not disabled', () => {\n render(<Blank {...defaultProps} isOver={true} dragItem={{ choice: { value: 'Dog' } }} />);\n expect(screen.getByText('Cow')).toBeInTheDocument();\n });\n\n it('shows drag preview when dragging over', () => {\n const { container } = render(<Blank {...defaultProps} isOver={true} dragItem={{ choice: { value: 'Dog' } }} />);\n expect(container.firstChild).toBeInTheDocument();\n // Should show visual feedback for drag over\n });\n });\n});\n"],"mappings":";;;;;AAAA,IAAAA,KAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAC,sBAAA,CAAAH,OAAA;AAA6B,SAAAD,wBAAAK,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAP,uBAAA,YAAAA,wBAAAK,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,mBAAAT,CAAA,iBAAAA,CAAA,gBAAAU,OAAA,CAAAV,CAAA,0BAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAA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AA2E,SAAA,iBAAKlB,YAAY;UAAEzB,MAAM,EAAE,IAAK;UAAC6B,QAAQ,EAAE;YAAEF,MAAM,EAAE;cAAEC,KAAK,EAAE;YAAM;UAAE;QAAE,EAAE,CAAC,CAAC;QAAvGS,SAAS,GAAAqD,QAAA,CAATrD,SAAS;MACjBC,MAAM,CAACD,SAAS,CAACE,UAAU,CAAC,CAACC,iBAAiB,CAAC,CAAC;MAChD;IACF,CAAC,CAAC;EACJ,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,132 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _typeof = require("@babel/runtime/helpers/typeof");
5
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
6
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
7
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
8
+ var React = _interopRequireWildcard(require("react"));
9
+ var _react2 = require("@testing-library/react");
10
+ var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
11
+ var _correctInput = _interopRequireDefault(require("../correct-input"));
12
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
13
+ describe('CorrectInput', function () {
14
+ var onChange = jest.fn();
15
+ var defaultProps = {
16
+ disabled: false,
17
+ correct: false,
18
+ variant: 'outlined',
19
+ value: 'Cow',
20
+ onChange: onChange
21
+ };
22
+ beforeEach(function () {
23
+ onChange.mockClear();
24
+ });
25
+ describe('rendering', function () {
26
+ it('renders input with default props', function () {
27
+ (0, _react2.render)(/*#__PURE__*/React.createElement(_correctInput["default"], defaultProps));
28
+ var input = _react2.screen.getByRole('textbox');
29
+ expect(input).toBeInTheDocument();
30
+ expect(input).toHaveValue('Cow');
31
+ });
32
+ it('renders as disabled when disabled prop is true', function () {
33
+ (0, _react2.render)(/*#__PURE__*/React.createElement(_correctInput["default"], (0, _extends2["default"])({}, defaultProps, {
34
+ disabled: true
35
+ })));
36
+ var input = _react2.screen.getByRole('textbox');
37
+ expect(input).toBeDisabled();
38
+ });
39
+ it('renders with correct state as false', function () {
40
+ var _render = (0, _react2.render)(/*#__PURE__*/React.createElement(_correctInput["default"], (0, _extends2["default"])({}, defaultProps, {
41
+ correct: false
42
+ }))),
43
+ container = _render.container;
44
+ var input = _react2.screen.getByRole('textbox');
45
+ expect(input).toBeInTheDocument();
46
+ });
47
+ it('renders with correct state as true', function () {
48
+ var _render2 = (0, _react2.render)(/*#__PURE__*/React.createElement(_correctInput["default"], (0, _extends2["default"])({}, defaultProps, {
49
+ correct: true
50
+ }))),
51
+ container = _render2.container;
52
+ var input = _react2.screen.getByRole('textbox');
53
+ expect(input).toBeInTheDocument();
54
+ // Should show visual indication of correctness
55
+ });
56
+ it('renders with outlined variant', function () {
57
+ (0, _react2.render)(/*#__PURE__*/React.createElement(_correctInput["default"], (0, _extends2["default"])({}, defaultProps, {
58
+ variant: "outlined"
59
+ })));
60
+ var input = _react2.screen.getByRole('textbox');
61
+ expect(input).toBeInTheDocument();
62
+ });
63
+ });
64
+ describe('user interactions', function () {
65
+ it('calls onChange when user types', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee() {
66
+ var user, input;
67
+ return _regenerator["default"].wrap(function (_context) {
68
+ while (1) switch (_context.prev = _context.next) {
69
+ case 0:
70
+ user = _userEvent["default"].setup();
71
+ (0, _react2.render)(/*#__PURE__*/React.createElement(_correctInput["default"], defaultProps));
72
+ input = _react2.screen.getByRole('textbox');
73
+ _context.next = 1;
74
+ return user.clear(input);
75
+ case 1:
76
+ _context.next = 2;
77
+ return user.type(input, '1');
78
+ case 2:
79
+ expect(onChange).toHaveBeenCalled();
80
+ case 3:
81
+ case "end":
82
+ return _context.stop();
83
+ }
84
+ }, _callee);
85
+ })));
86
+ it('calls onChange with event object', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee2() {
87
+ var user, input, lastCall;
88
+ return _regenerator["default"].wrap(function (_context2) {
89
+ while (1) switch (_context2.prev = _context2.next) {
90
+ case 0:
91
+ user = _userEvent["default"].setup();
92
+ (0, _react2.render)(/*#__PURE__*/React.createElement(_correctInput["default"], (0, _extends2["default"])({}, defaultProps, {
93
+ value: ""
94
+ })));
95
+ input = _react2.screen.getByRole('textbox');
96
+ _context2.next = 1;
97
+ return user.type(input, 'test');
98
+ case 1:
99
+ expect(onChange).toHaveBeenCalled();
100
+ // Check that onChange receives an event-like object
101
+ lastCall = onChange.mock.calls[onChange.mock.calls.length - 1][0];
102
+ expect(lastCall).toHaveProperty('target');
103
+ case 2:
104
+ case "end":
105
+ return _context2.stop();
106
+ }
107
+ }, _callee2);
108
+ })));
109
+ it('updates value when user changes input', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee3() {
110
+ var user, input;
111
+ return _regenerator["default"].wrap(function (_context3) {
112
+ while (1) switch (_context3.prev = _context3.next) {
113
+ case 0:
114
+ user = _userEvent["default"].setup();
115
+ (0, _react2.render)(/*#__PURE__*/React.createElement(_correctInput["default"], defaultProps));
116
+ input = _react2.screen.getByRole('textbox');
117
+ _context3.next = 1;
118
+ return user.clear(input);
119
+ case 1:
120
+ _context3.next = 2;
121
+ return user.type(input, 'Dog');
122
+ case 2:
123
+ expect(onChange).toHaveBeenCalled();
124
+ case 3:
125
+ case "end":
126
+ return _context3.stop();
127
+ }
128
+ }, _callee3);
129
+ })));
130
+ });
131
+ });
132
+ //# sourceMappingURL=correct-input.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"correct-input.test.js","names":["React","_interopRequireWildcard","require","_react2","_userEvent","_interopRequireDefault","_correctInput","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","_typeof","has","get","set","_t","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","describe","onChange","jest","fn","defaultProps","disabled","correct","variant","value","beforeEach","mockClear","it","render","createElement","input","screen","getByRole","expect","toBeInTheDocument","toHaveValue","_extends2","toBeDisabled","_render","container","_render2","_asyncToGenerator2","_regenerator","mark","_callee","user","wrap","_context","prev","next","userEvent","setup","clear","type","toHaveBeenCalled","stop","_callee2","lastCall","_context2","mock","calls","length","toHaveProperty","_callee3","_context3"],"sources":["../../../src/components/__tests__/correct-input.test.js"],"sourcesContent":["import * as React from 'react';\nimport { render, screen } from '@testing-library/react';\nimport userEvent from '@testing-library/user-event';\nimport CorrectInput from '../correct-input';\n\ndescribe('CorrectInput', () => {\n const onChange = jest.fn();\n const defaultProps = {\n disabled: false,\n correct: false,\n variant: 'outlined',\n value: 'Cow',\n onChange,\n };\n\n beforeEach(() => {\n onChange.mockClear();\n });\n\n describe('rendering', () => {\n it('renders input with default props', () => {\n render(<CorrectInput {...defaultProps} />);\n const input = screen.getByRole('textbox');\n expect(input).toBeInTheDocument();\n expect(input).toHaveValue('Cow');\n });\n\n it('renders as disabled when disabled prop is true', () => {\n render(<CorrectInput {...defaultProps} disabled={true} />);\n const input = screen.getByRole('textbox');\n expect(input).toBeDisabled();\n });\n\n it('renders with correct state as false', () => {\n const { container } = render(<CorrectInput {...defaultProps} correct={false} />);\n const input = screen.getByRole('textbox');\n expect(input).toBeInTheDocument();\n });\n\n it('renders with correct state as true', () => {\n const { container } = render(<CorrectInput {...defaultProps} correct={true} />);\n const input = screen.getByRole('textbox');\n expect(input).toBeInTheDocument();\n // Should show visual indication of correctness\n });\n\n it('renders with outlined variant', () => {\n render(<CorrectInput {...defaultProps} variant=\"outlined\" />);\n const input = screen.getByRole('textbox');\n expect(input).toBeInTheDocument();\n });\n });\n\n describe('user interactions', () => {\n it('calls onChange when user types', async () => {\n const user = userEvent.setup();\n render(<CorrectInput {...defaultProps} />);\n\n const input = screen.getByRole('textbox');\n await user.clear(input);\n await user.type(input, '1');\n\n expect(onChange).toHaveBeenCalled();\n });\n\n it('calls onChange with event object', async () => {\n const user = userEvent.setup();\n render(<CorrectInput {...defaultProps} value=\"\" />);\n\n const input = screen.getByRole('textbox');\n await user.type(input, 'test');\n\n expect(onChange).toHaveBeenCalled();\n // Check that onChange receives an event-like object\n const lastCall = onChange.mock.calls[onChange.mock.calls.length - 1][0];\n expect(lastCall).toHaveProperty('target');\n });\n\n it('updates value when user changes input', async () => {\n const user = userEvent.setup();\n render(<CorrectInput {...defaultProps} />);\n\n const input = screen.getByRole('textbox');\n await user.clear(input);\n await user.type(input, 'Dog');\n\n expect(onChange).toHaveBeenCalled();\n });\n });\n});\n"],"mappings":";;;;;;;AAAA,IAAAA,KAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,aAAA,GAAAD,sBAAA,CAAAH,OAAA;AAA4C,SAAAD,wBAAAM,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAR,uBAAA,YAAAA,wBAAAM,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,mBAAAT,CAAA,iBAAAA,CAAA,gBAAAU,OAAA,CAAAV,CAAA,0BAAAA,CAAA,SAAAQ,CAAA,MAAA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