@pie-element/hotspot 11.1.1 → 11.1.2-next.1
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/configure.js +2 -0
- package/controller.js +1 -0
- package/dist/author/DeleteWidget.d.ts +38 -0
- package/dist/author/DeleteWidget.js +46 -0
- package/dist/author/button.d.ts +31 -0
- package/dist/author/button.js +27 -0
- package/dist/author/buttons/circle.d.ts +18 -0
- package/dist/author/buttons/circle.js +25 -0
- package/dist/author/buttons/polygon.d.ts +18 -0
- package/dist/author/buttons/polygon.js +36 -0
- package/dist/author/buttons/rectangle.d.ts +18 -0
- package/dist/author/buttons/rectangle.js +36 -0
- package/dist/author/defaults.d.ts +157 -0
- package/dist/author/defaults.js +119 -0
- package/dist/author/hotspot-circle.d.ts +21 -0
- package/dist/author/hotspot-circle.js +124 -0
- package/dist/author/hotspot-container.d.ts +29 -0
- package/dist/author/hotspot-container.js +210 -0
- package/dist/author/hotspot-drawable.d.ts +31 -0
- package/dist/author/hotspot-drawable.js +312 -0
- package/dist/author/hotspot-palette.d.ts +14 -0
- package/dist/author/hotspot-palette.js +72 -0
- package/dist/author/hotspot-polygon.d.ts +38 -0
- package/dist/author/hotspot-polygon.js +200 -0
- package/dist/author/hotspot-rectangle.d.ts +20 -0
- package/dist/author/hotspot-rectangle.js +119 -0
- package/dist/author/icons.d.ts +9 -0
- package/dist/author/icons.js +4 -0
- package/dist/author/image-konva.d.ts +19 -0
- package/dist/author/image-konva.js +49 -0
- package/dist/author/index.d.ts +52 -0
- package/dist/author/index.js +143 -0
- package/dist/author/root.d.ts +15 -0
- package/dist/author/root.js +215 -0
- package/dist/author/shapes/circle.d.ts +18 -0
- package/dist/author/shapes/circle.js +47 -0
- package/dist/author/shapes/index.d.ts +12 -0
- package/dist/author/shapes/polygon.d.ts +19 -0
- package/dist/author/shapes/polygon.js +51 -0
- package/dist/author/shapes/rectagle.d.ts +18 -0
- package/dist/author/shapes/rectagle.js +57 -0
- package/dist/author/shapes/utils.d.ts +19 -0
- package/dist/author/shapes/utils.js +16 -0
- package/dist/author/upload-control.d.ts +29 -0
- package/dist/author/upload-control.js +28 -0
- package/dist/author/utils.d.ts +24 -0
- package/dist/author/utils.js +83 -0
- package/dist/browser/ReactKonva-Z9-1H-UZ.js +19329 -0
- package/dist/browser/ReactKonva-Z9-1H-UZ.js.map +1 -0
- package/dist/browser/author/index.js +41646 -0
- package/dist/browser/author/index.js.map +1 -0
- package/dist/browser/browser-CfnAFove.js +219 -0
- package/dist/browser/browser-CfnAFove.js.map +1 -0
- package/dist/browser/controller/index.js +198 -0
- package/dist/browser/controller/index.js.map +1 -0
- package/dist/browser/delivery/index.js +2460 -0
- package/dist/browser/delivery/index.js.map +1 -0
- package/dist/browser/dist-C78LDz6R.js +96 -0
- package/dist/browser/dist-C78LDz6R.js.map +1 -0
- package/dist/browser/hotspot.css +2 -0
- package/dist/controller/defaults.d.ts +35 -0
- package/dist/controller/defaults.js +29 -0
- package/dist/controller/index.d.ts +22 -0
- package/dist/controller/index.js +154 -0
- package/dist/controller/utils.d.ts +10 -0
- package/dist/controller/utils.js +12 -0
- package/dist/delivery/hotspot/circle.d.ts +19 -0
- package/dist/delivery/hotspot/circle.js +100 -0
- package/dist/delivery/hotspot/container.d.ts +16 -0
- package/dist/delivery/hotspot/container.js +150 -0
- package/dist/delivery/hotspot/icons.d.ts +10 -0
- package/dist/delivery/hotspot/icons.js +4 -0
- package/dist/delivery/hotspot/image-konva-tooltip.d.ts +19 -0
- package/dist/delivery/hotspot/image-konva-tooltip.js +66 -0
- package/dist/delivery/hotspot/index.d.ts +17 -0
- package/dist/delivery/hotspot/index.js +114 -0
- package/dist/delivery/hotspot/polygon.d.ts +21 -0
- package/dist/delivery/hotspot/polygon.js +108 -0
- package/dist/delivery/hotspot/rectangle.d.ts +19 -0
- package/dist/delivery/hotspot/rectangle.js +104 -0
- package/dist/delivery/index.d.ts +20 -0
- package/dist/delivery/index.js +107 -0
- package/dist/delivery/session-updater.d.ts +10 -0
- package/dist/delivery/session-updater.js +14 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.iife.d.ts +8 -0
- package/dist/index.iife.js +169 -0
- package/dist/index.js +2 -0
- package/dist/runtime-support.d.ts +12 -0
- package/dist/runtime-support.js +12 -0
- package/package.json +84 -18
- package/CHANGELOG.json +0 -997
- package/CHANGELOG.md +0 -2214
- package/LICENSE.md +0 -5
- package/README.md +0 -1
- package/configure/CHANGELOG.json +0 -682
- package/configure/CHANGELOG.md +0 -1951
- package/configure/lib/DeleteWidget.js +0 -64
- package/configure/lib/DeleteWidget.js.map +0 -1
- package/configure/lib/button.js +0 -42
- package/configure/lib/button.js.map +0 -1
- package/configure/lib/buttons/circle.js +0 -33
- package/configure/lib/buttons/circle.js.map +0 -1
- package/configure/lib/buttons/polygon.js +0 -39
- package/configure/lib/buttons/polygon.js.map +0 -1
- package/configure/lib/buttons/rectangle.js +0 -39
- package/configure/lib/buttons/rectangle.js.map +0 -1
- package/configure/lib/defaults.js +0 -155
- package/configure/lib/defaults.js.map +0 -1
- package/configure/lib/hotspot-circle.js +0 -192
- package/configure/lib/hotspot-circle.js.map +0 -1
- package/configure/lib/hotspot-container.js +0 -320
- package/configure/lib/hotspot-container.js.map +0 -1
- package/configure/lib/hotspot-drawable.js +0 -519
- package/configure/lib/hotspot-drawable.js.map +0 -1
- package/configure/lib/hotspot-palette.js +0 -107
- package/configure/lib/hotspot-palette.js.map +0 -1
- package/configure/lib/hotspot-polygon.js +0 -293
- package/configure/lib/hotspot-polygon.js.map +0 -1
- package/configure/lib/hotspot-rectangle.js +0 -190
- package/configure/lib/hotspot-rectangle.js.map +0 -1
- package/configure/lib/icons.js +0 -7
- package/configure/lib/icons.js.map +0 -1
- package/configure/lib/image-konva.js +0 -66
- package/configure/lib/image-konva.js.map +0 -1
- package/configure/lib/index.js +0 -194
- package/configure/lib/index.js.map +0 -1
- package/configure/lib/root.js +0 -330
- package/configure/lib/root.js.map +0 -1
- package/configure/lib/shapes/circle.js +0 -84
- package/configure/lib/shapes/circle.js.map +0 -1
- package/configure/lib/shapes/index.js +0 -50
- package/configure/lib/shapes/index.js.map +0 -1
- package/configure/lib/shapes/polygon.js +0 -82
- package/configure/lib/shapes/polygon.js.map +0 -1
- package/configure/lib/shapes/rectagle.js +0 -84
- package/configure/lib/shapes/rectagle.js.map +0 -1
- package/configure/lib/shapes/utils.js +0 -21
- package/configure/lib/shapes/utils.js.map +0 -1
- package/configure/lib/upload-control.js +0 -41
- package/configure/lib/upload-control.js.map +0 -1
- package/configure/lib/utils.js +0 -185
- package/configure/lib/utils.js.map +0 -1
- package/configure/package.json +0 -26
- package/configure/src/DeleteWidget.jsx +0 -51
- package/configure/src/__tests__/DeleteWidget.test.jsx +0 -366
- package/configure/src/__tests__/button.test.jsx +0 -198
- package/configure/src/__tests__/hotspot-circle.test.jsx +0 -259
- package/configure/src/__tests__/hotspot-container.test.js +0 -366
- package/configure/src/__tests__/hotspot-drawable.test.js +0 -271
- package/configure/src/__tests__/hotspot-palette.test.jsx +0 -71
- package/configure/src/__tests__/image-konva.test.jsx +0 -226
- package/configure/src/__tests__/index.test.js +0 -329
- package/configure/src/__tests__/root.test.js +0 -400
- package/configure/src/__tests__/utils.test.js +0 -241
- package/configure/src/button.jsx +0 -35
- package/configure/src/buttons/circle.jsx +0 -18
- package/configure/src/buttons/polygon.jsx +0 -29
- package/configure/src/buttons/rectangle.jsx +0 -29
- package/configure/src/defaults.js +0 -109
- package/configure/src/hotspot-circle.jsx +0 -183
- package/configure/src/hotspot-container.jsx +0 -330
- package/configure/src/hotspot-drawable.jsx +0 -527
- package/configure/src/hotspot-palette.jsx +0 -90
- package/configure/src/hotspot-polygon.jsx +0 -294
- package/configure/src/hotspot-rectangle.jsx +0 -169
- package/configure/src/icons.js +0 -5
- package/configure/src/image-konva.jsx +0 -63
- package/configure/src/index.js +0 -208
- package/configure/src/root.jsx +0 -346
- package/configure/src/shapes/circle.js +0 -81
- package/configure/src/shapes/index.js +0 -4
- package/configure/src/shapes/polygon.js +0 -81
- package/configure/src/shapes/rectagle.js +0 -82
- package/configure/src/shapes/utils.js +0 -16
- package/configure/src/upload-control.jsx +0 -33
- package/configure/src/utils.js +0 -210
- package/controller/CHANGELOG.json +0 -362
- package/controller/CHANGELOG.md +0 -1304
- package/controller/lib/defaults.js +0 -33
- package/controller/lib/defaults.js.map +0 -1
- package/controller/lib/index.js +0 -341
- package/controller/lib/index.js.map +0 -1
- package/controller/lib/utils.js +0 -32
- package/controller/lib/utils.js.map +0 -1
- package/controller/package.json +0 -18
- package/controller/src/__tests__/index.test.js +0 -419
- package/controller/src/__tests__/utils.test.js +0 -5
- package/controller/src/defaults.js +0 -19
- package/controller/src/index.js +0 -328
- package/controller/src/utils.js +0 -29
- package/docs/config-schema.json +0 -2023
- package/docs/config-schema.json.md +0 -1495
- package/docs/demo/config.js +0 -8
- package/docs/demo/generate.js +0 -118
- package/docs/demo/index.html +0 -1
- package/docs/demo/session.js +0 -11
- package/docs/pie-schema.json +0 -1204
- package/docs/pie-schema.json.md +0 -851
- package/lib/hotspot/circle.js +0 -156
- package/lib/hotspot/circle.js.map +0 -1
- package/lib/hotspot/container.js +0 -206
- package/lib/hotspot/container.js.map +0 -1
- package/lib/hotspot/icons.js +0 -8
- package/lib/hotspot/icons.js.map +0 -1
- package/lib/hotspot/image-konva-tooltip.js +0 -86
- package/lib/hotspot/image-konva-tooltip.js.map +0 -1
- package/lib/hotspot/index.js +0 -163
- package/lib/hotspot/index.js.map +0 -1
- package/lib/hotspot/polygon.js +0 -203
- package/lib/hotspot/polygon.js.map +0 -1
- package/lib/hotspot/rectangle.js +0 -175
- package/lib/hotspot/rectangle.js.map +0 -1
- package/lib/index.js +0 -213
- package/lib/index.js.map +0 -1
- package/lib/session-updater.js +0 -42
- package/lib/session-updater.js.map +0 -1
- package/src/__tests__/container.test.jsx +0 -58
- package/src/__tests__/index.test.js +0 -123
- package/src/__tests__/session-updater.test.jsx +0 -69
- package/src/hotspot/__tests__/circle.test.jsx +0 -464
- package/src/hotspot/__tests__/container.test.jsx +0 -546
- package/src/hotspot/__tests__/image-konva-tooltip.test.jsx +0 -510
- package/src/hotspot/__tests__/polygon.test.jsx +0 -502
- package/src/hotspot/__tests__/rectangle.test.jsx +0 -418
- package/src/hotspot/circle.jsx +0 -152
- package/src/hotspot/container.jsx +0 -217
- package/src/hotspot/icons.js +0 -7
- package/src/hotspot/image-konva-tooltip.jsx +0 -76
- package/src/hotspot/index.jsx +0 -165
- package/src/hotspot/polygon.jsx +0 -195
- package/src/hotspot/rectangle.jsx +0 -171
- package/src/index.js +0 -226
- package/src/session-updater.js +0 -29
|
@@ -1,464 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { render, fireEvent } from '@testing-library/react';
|
|
3
|
-
import Konva from 'konva';
|
|
4
|
-
import CircleComponent from '../circle';
|
|
5
|
-
|
|
6
|
-
Konva.isBrowser = false;
|
|
7
|
-
|
|
8
|
-
jest.mock('react-konva', () => {
|
|
9
|
-
const React = require('react');
|
|
10
|
-
return {
|
|
11
|
-
Circle: ({ onClick, onTap, onMouseEnter, onMouseLeave, ...props }) => {
|
|
12
|
-
const handleClick = (e) => {
|
|
13
|
-
if (onClick) onClick(e);
|
|
14
|
-
if (onTap) onTap(e);
|
|
15
|
-
};
|
|
16
|
-
return React.createElement('div', {
|
|
17
|
-
'data-testid': 'circle',
|
|
18
|
-
onClick: handleClick,
|
|
19
|
-
onMouseEnter,
|
|
20
|
-
onMouseLeave,
|
|
21
|
-
...props,
|
|
22
|
-
});
|
|
23
|
-
},
|
|
24
|
-
Rect: (props) => React.createElement('div', { 'data-testid': 'rect', ...props }),
|
|
25
|
-
Group: ({ children, ...props }) => React.createElement('div', { 'data-testid': 'group', ...props }, children),
|
|
26
|
-
};
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
jest.mock('../image-konva-tooltip', () => {
|
|
30
|
-
return function ImageComponent({ src, x, y, tooltip }) {
|
|
31
|
-
return <div data-testid="icon-image" data-src={src} data-x={x} data-y={y} data-tooltip={tooltip} />;
|
|
32
|
-
};
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
describe('CircleComponent', () => {
|
|
36
|
-
let defaultProps;
|
|
37
|
-
|
|
38
|
-
beforeEach(() => {
|
|
39
|
-
defaultProps = {
|
|
40
|
-
id: 'circle1',
|
|
41
|
-
x: 50,
|
|
42
|
-
y: 50,
|
|
43
|
-
radius: 30,
|
|
44
|
-
hotspotColor: '#FF0000',
|
|
45
|
-
selectedHotspotColor: '#00FF00',
|
|
46
|
-
outlineColor: '#0000FF',
|
|
47
|
-
hoverOutlineColor: '#FFFF00',
|
|
48
|
-
selected: false,
|
|
49
|
-
isCorrect: false,
|
|
50
|
-
isEvaluateMode: false,
|
|
51
|
-
disabled: false,
|
|
52
|
-
onClick: jest.fn(),
|
|
53
|
-
strokeWidth: 5,
|
|
54
|
-
scale: 1,
|
|
55
|
-
markAsCorrect: false,
|
|
56
|
-
showCorrectEnabled: false,
|
|
57
|
-
};
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
afterEach(() => {
|
|
61
|
-
document.body.style.cursor = 'default';
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
describe('rendering', () => {
|
|
65
|
-
it('should render without crashing', () => {
|
|
66
|
-
const { container } = render(<CircleComponent {...defaultProps} />);
|
|
67
|
-
expect(container).toBeTruthy();
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
it('should render with correct position and radius', () => {
|
|
71
|
-
const { getByTestId } = render(<CircleComponent {...defaultProps} />);
|
|
72
|
-
const circle = getByTestId('circle');
|
|
73
|
-
|
|
74
|
-
expect(circle).toHaveAttribute('x', '50');
|
|
75
|
-
expect(circle).toHaveAttribute('y', '50');
|
|
76
|
-
expect(circle).toHaveAttribute('radius', '30');
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
it('should render with hotspot color when not selected', () => {
|
|
80
|
-
const { getByTestId } = render(<CircleComponent {...defaultProps} />);
|
|
81
|
-
const circle = getByTestId('circle');
|
|
82
|
-
|
|
83
|
-
expect(circle).toHaveAttribute('fill', '#FF0000');
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
it('should render with selected color when selected', () => {
|
|
87
|
-
const { getByTestId } = render(<CircleComponent {...defaultProps} selected={true} />);
|
|
88
|
-
const circle = getByTestId('circle');
|
|
89
|
-
|
|
90
|
-
expect(circle).toHaveAttribute('fill', '#00FF00');
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
it('should apply scale transform', () => {
|
|
94
|
-
const { getByTestId } = render(<CircleComponent {...defaultProps} scale={2.0} />);
|
|
95
|
-
const group = getByTestId('group');
|
|
96
|
-
|
|
97
|
-
expect(group).toHaveAttribute('scaleX', '2');
|
|
98
|
-
expect(group).toHaveAttribute('scaleY', '2');
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
it('should render with default scale of 1', () => {
|
|
102
|
-
const { getByTestId } = render(<CircleComponent {...defaultProps} />);
|
|
103
|
-
const group = getByTestId('group');
|
|
104
|
-
|
|
105
|
-
expect(group).toHaveAttribute('scaleX', '1');
|
|
106
|
-
expect(group).toHaveAttribute('scaleY', '1');
|
|
107
|
-
});
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
describe('interactions', () => {
|
|
111
|
-
it('should call onClick when clicked', () => {
|
|
112
|
-
const onClick = jest.fn();
|
|
113
|
-
const { getByTestId } = render(<CircleComponent {...defaultProps} onClick={onClick} />);
|
|
114
|
-
const circle = getByTestId('circle');
|
|
115
|
-
|
|
116
|
-
fireEvent.click(circle);
|
|
117
|
-
|
|
118
|
-
expect(onClick).toHaveBeenCalledWith({
|
|
119
|
-
id: 'circle1',
|
|
120
|
-
selected: true,
|
|
121
|
-
selector: 'Mouse',
|
|
122
|
-
});
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
it('should toggle selection state on click', () => {
|
|
126
|
-
const onClick = jest.fn();
|
|
127
|
-
const { getByTestId, rerender } = render(<CircleComponent {...defaultProps} onClick={onClick} selected={false} />);
|
|
128
|
-
const circle = getByTestId('circle');
|
|
129
|
-
|
|
130
|
-
fireEvent.click(circle);
|
|
131
|
-
|
|
132
|
-
expect(onClick).toHaveBeenCalledWith({
|
|
133
|
-
id: 'circle1',
|
|
134
|
-
selected: true,
|
|
135
|
-
selector: 'Mouse',
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
rerender(<CircleComponent {...defaultProps} onClick={onClick} selected={true} />);
|
|
139
|
-
|
|
140
|
-
const circleAfter = getByTestId('circle');
|
|
141
|
-
fireEvent.click(circleAfter);
|
|
142
|
-
|
|
143
|
-
expect(onClick).toHaveBeenCalledWith({
|
|
144
|
-
id: 'circle1',
|
|
145
|
-
selected: false,
|
|
146
|
-
selector: 'Mouse',
|
|
147
|
-
});
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
it('should not call onClick when disabled', () => {
|
|
151
|
-
const onClick = jest.fn();
|
|
152
|
-
const { getByTestId } = render(<CircleComponent {...defaultProps} onClick={onClick} disabled={true} />);
|
|
153
|
-
const circle = getByTestId('circle');
|
|
154
|
-
|
|
155
|
-
fireEvent.click(circle);
|
|
156
|
-
|
|
157
|
-
expect(onClick).not.toHaveBeenCalled();
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
it('should change cursor to pointer on mouse enter when not disabled', () => {
|
|
161
|
-
const { getByTestId } = render(<CircleComponent {...defaultProps} />);
|
|
162
|
-
const circle = getByTestId('circle');
|
|
163
|
-
|
|
164
|
-
fireEvent.mouseEnter(circle);
|
|
165
|
-
|
|
166
|
-
expect(document.body.style.cursor).toBe('pointer');
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
it('should not change cursor when disabled', () => {
|
|
170
|
-
const { getByTestId } = render(<CircleComponent {...defaultProps} disabled={true} />);
|
|
171
|
-
const circle = getByTestId('circle');
|
|
172
|
-
|
|
173
|
-
fireEvent.mouseEnter(circle);
|
|
174
|
-
|
|
175
|
-
expect(document.body.style.cursor).toBe('default');
|
|
176
|
-
});
|
|
177
|
-
|
|
178
|
-
it('should reset cursor to default on mouse leave', () => {
|
|
179
|
-
const { getByTestId } = render(<CircleComponent {...defaultProps} />);
|
|
180
|
-
const circle = getByTestId('circle');
|
|
181
|
-
|
|
182
|
-
fireEvent.mouseEnter(circle);
|
|
183
|
-
fireEvent.mouseLeave(circle);
|
|
184
|
-
|
|
185
|
-
expect(document.body.style.cursor).toBe('default');
|
|
186
|
-
});
|
|
187
|
-
});
|
|
188
|
-
|
|
189
|
-
describe('hover styling', () => {
|
|
190
|
-
it('should show hover rect when hoverOutlineColor is provided', () => {
|
|
191
|
-
const { container, getByTestId } = render(<CircleComponent {...defaultProps} hoverOutlineColor="#FFFF00" />);
|
|
192
|
-
const circle = getByTestId('circle');
|
|
193
|
-
|
|
194
|
-
fireEvent.mouseEnter(circle);
|
|
195
|
-
|
|
196
|
-
const rects = container.querySelectorAll('[data-testid="rect"]');
|
|
197
|
-
expect(rects.length).toBeGreaterThan(0);
|
|
198
|
-
});
|
|
199
|
-
|
|
200
|
-
it('should render hover rect with correct dimensions based on radius', () => {
|
|
201
|
-
const { container, getByTestId } = render(
|
|
202
|
-
<CircleComponent
|
|
203
|
-
{...defaultProps}
|
|
204
|
-
x={50}
|
|
205
|
-
y={50}
|
|
206
|
-
radius={30}
|
|
207
|
-
hoverOutlineColor="#FFFF00"
|
|
208
|
-
/>
|
|
209
|
-
);
|
|
210
|
-
const circle = getByTestId('circle');
|
|
211
|
-
|
|
212
|
-
fireEvent.mouseEnter(circle);
|
|
213
|
-
|
|
214
|
-
const rect = container.querySelector('[data-testid="rect"]');
|
|
215
|
-
if (rect) {
|
|
216
|
-
// Rect should be positioned at (x - radius, y - radius) with width/height = radius * 2
|
|
217
|
-
expect(rect).toHaveAttribute('x', '20'); // 50 - 30
|
|
218
|
-
expect(rect).toHaveAttribute('y', '20'); // 50 - 30
|
|
219
|
-
expect(rect).toHaveAttribute('width', '60'); // 30 * 2
|
|
220
|
-
expect(rect).toHaveAttribute('height', '60'); // 30 * 2
|
|
221
|
-
}
|
|
222
|
-
});
|
|
223
|
-
|
|
224
|
-
it('should show transparent stroke when selected and hovering', () => {
|
|
225
|
-
const { container, getByTestId } = render(
|
|
226
|
-
<CircleComponent {...defaultProps} selected={true} hoverOutlineColor="#FFFF00" />
|
|
227
|
-
);
|
|
228
|
-
const circle = getByTestId('circle');
|
|
229
|
-
|
|
230
|
-
fireEvent.mouseEnter(circle);
|
|
231
|
-
|
|
232
|
-
const rect = container.querySelector('[data-testid="rect"]');
|
|
233
|
-
if (rect) {
|
|
234
|
-
expect(rect).toHaveAttribute('stroke', 'transparent');
|
|
235
|
-
}
|
|
236
|
-
});
|
|
237
|
-
});
|
|
238
|
-
|
|
239
|
-
describe('evaluate mode', () => {
|
|
240
|
-
it('should show correct icon when correctly selected in evaluate mode', () => {
|
|
241
|
-
const { getByTestId } = render(
|
|
242
|
-
<CircleComponent
|
|
243
|
-
{...defaultProps}
|
|
244
|
-
isEvaluateMode={true}
|
|
245
|
-
selected={true}
|
|
246
|
-
isCorrect={true}
|
|
247
|
-
showCorrectEnabled={false}
|
|
248
|
-
/>
|
|
249
|
-
);
|
|
250
|
-
|
|
251
|
-
const icon = getByTestId('icon-image');
|
|
252
|
-
expect(icon).toBeInTheDocument();
|
|
253
|
-
});
|
|
254
|
-
|
|
255
|
-
it('should show wrong icon when incorrectly selected in evaluate mode', () => {
|
|
256
|
-
const { getByTestId } = render(
|
|
257
|
-
<CircleComponent
|
|
258
|
-
{...defaultProps}
|
|
259
|
-
isEvaluateMode={true}
|
|
260
|
-
selected={true}
|
|
261
|
-
isCorrect={false}
|
|
262
|
-
showCorrectEnabled={false}
|
|
263
|
-
/>
|
|
264
|
-
);
|
|
265
|
-
|
|
266
|
-
const icon = getByTestId('icon-image');
|
|
267
|
-
expect(icon).toBeInTheDocument();
|
|
268
|
-
});
|
|
269
|
-
|
|
270
|
-
it('should show wrong icon when incorrectly not selected', () => {
|
|
271
|
-
const { getByTestId } = render(
|
|
272
|
-
<CircleComponent
|
|
273
|
-
{...defaultProps}
|
|
274
|
-
isEvaluateMode={true}
|
|
275
|
-
selected={false}
|
|
276
|
-
isCorrect={false}
|
|
277
|
-
showCorrectEnabled={false}
|
|
278
|
-
/>
|
|
279
|
-
);
|
|
280
|
-
|
|
281
|
-
const icon = getByTestId('icon-image');
|
|
282
|
-
expect(icon).toBeInTheDocument();
|
|
283
|
-
});
|
|
284
|
-
|
|
285
|
-
it('should not show icon when correctly not selected in evaluate mode', () => {
|
|
286
|
-
const { queryByTestId } = render(
|
|
287
|
-
<CircleComponent
|
|
288
|
-
{...defaultProps}
|
|
289
|
-
isEvaluateMode={true}
|
|
290
|
-
selected={false}
|
|
291
|
-
isCorrect={true}
|
|
292
|
-
showCorrectEnabled={false}
|
|
293
|
-
/>
|
|
294
|
-
);
|
|
295
|
-
|
|
296
|
-
const icon = queryByTestId('icon-image');
|
|
297
|
-
expect(icon).not.toBeInTheDocument();
|
|
298
|
-
});
|
|
299
|
-
|
|
300
|
-
it('should show correct icon for showCorrect mode when correctly selected', () => {
|
|
301
|
-
const { getByTestId } = render(
|
|
302
|
-
<CircleComponent
|
|
303
|
-
{...defaultProps}
|
|
304
|
-
isEvaluateMode={true}
|
|
305
|
-
selected={true}
|
|
306
|
-
isCorrect={true}
|
|
307
|
-
showCorrectEnabled={true}
|
|
308
|
-
/>
|
|
309
|
-
);
|
|
310
|
-
|
|
311
|
-
const icon = getByTestId('icon-image');
|
|
312
|
-
expect(icon).toBeInTheDocument();
|
|
313
|
-
});
|
|
314
|
-
|
|
315
|
-
it('should show correct icon for showCorrect mode when incorrectly not selected', () => {
|
|
316
|
-
const { getByTestId } = render(
|
|
317
|
-
<CircleComponent
|
|
318
|
-
{...defaultProps}
|
|
319
|
-
isEvaluateMode={true}
|
|
320
|
-
selected={false}
|
|
321
|
-
isCorrect={false}
|
|
322
|
-
showCorrectEnabled={true}
|
|
323
|
-
/>
|
|
324
|
-
);
|
|
325
|
-
|
|
326
|
-
const icon = getByTestId('icon-image');
|
|
327
|
-
expect(icon).toBeInTheDocument();
|
|
328
|
-
});
|
|
329
|
-
|
|
330
|
-
it('should not show icon in showCorrect mode when correctly not selected', () => {
|
|
331
|
-
const { queryByTestId } = render(
|
|
332
|
-
<CircleComponent
|
|
333
|
-
{...defaultProps}
|
|
334
|
-
isEvaluateMode={true}
|
|
335
|
-
selected={false}
|
|
336
|
-
isCorrect={true}
|
|
337
|
-
showCorrectEnabled={true}
|
|
338
|
-
/>
|
|
339
|
-
);
|
|
340
|
-
|
|
341
|
-
const icon = queryByTestId('icon-image');
|
|
342
|
-
expect(icon).not.toBeInTheDocument();
|
|
343
|
-
});
|
|
344
|
-
|
|
345
|
-
it('should not show icon in showCorrect mode when incorrectly selected', () => {
|
|
346
|
-
const { queryByTestId } = render(
|
|
347
|
-
<CircleComponent
|
|
348
|
-
{...defaultProps}
|
|
349
|
-
isEvaluateMode={true}
|
|
350
|
-
selected={true}
|
|
351
|
-
isCorrect={false}
|
|
352
|
-
showCorrectEnabled={true}
|
|
353
|
-
/>
|
|
354
|
-
);
|
|
355
|
-
|
|
356
|
-
const icon = queryByTestId('icon-image');
|
|
357
|
-
expect(icon).not.toBeInTheDocument();
|
|
358
|
-
});
|
|
359
|
-
|
|
360
|
-
it('should show green outline when markAsCorrect is true', () => {
|
|
361
|
-
const { getByTestId } = render(
|
|
362
|
-
<CircleComponent
|
|
363
|
-
{...defaultProps}
|
|
364
|
-
isEvaluateMode={true}
|
|
365
|
-
markAsCorrect={true}
|
|
366
|
-
/>
|
|
367
|
-
);
|
|
368
|
-
|
|
369
|
-
const circle = getByTestId('circle');
|
|
370
|
-
expect(circle).toHaveAttribute('stroke', 'green');
|
|
371
|
-
});
|
|
372
|
-
|
|
373
|
-
it('should show red outline when incorrect and not markAsCorrect', () => {
|
|
374
|
-
const { getByTestId } = render(
|
|
375
|
-
<CircleComponent
|
|
376
|
-
{...defaultProps}
|
|
377
|
-
isEvaluateMode={true}
|
|
378
|
-
isCorrect={false}
|
|
379
|
-
markAsCorrect={false}
|
|
380
|
-
/>
|
|
381
|
-
);
|
|
382
|
-
|
|
383
|
-
const circle = getByTestId('circle');
|
|
384
|
-
expect(circle).toHaveAttribute('stroke', 'red');
|
|
385
|
-
});
|
|
386
|
-
|
|
387
|
-
it('should display evaluate text in tooltip', () => {
|
|
388
|
-
const { getByTestId } = render(
|
|
389
|
-
<CircleComponent
|
|
390
|
-
{...defaultProps}
|
|
391
|
-
isEvaluateMode={true}
|
|
392
|
-
selected={true}
|
|
393
|
-
isCorrect={true}
|
|
394
|
-
evaluateText="Great job!"
|
|
395
|
-
showCorrectEnabled={false}
|
|
396
|
-
/>
|
|
397
|
-
);
|
|
398
|
-
|
|
399
|
-
const icon = getByTestId('icon-image');
|
|
400
|
-
expect(icon).toHaveAttribute('data-tooltip', 'Great job!');
|
|
401
|
-
});
|
|
402
|
-
});
|
|
403
|
-
|
|
404
|
-
describe('icon positioning', () => {
|
|
405
|
-
it('should position icon at center of circle minus offset', () => {
|
|
406
|
-
const { getByTestId } = render(
|
|
407
|
-
<CircleComponent
|
|
408
|
-
{...defaultProps}
|
|
409
|
-
x={100}
|
|
410
|
-
y={100}
|
|
411
|
-
radius={30}
|
|
412
|
-
isEvaluateMode={true}
|
|
413
|
-
selected={true}
|
|
414
|
-
isCorrect={true}
|
|
415
|
-
showCorrectEnabled={false}
|
|
416
|
-
/>
|
|
417
|
-
);
|
|
418
|
-
|
|
419
|
-
const icon = getByTestId('icon-image');
|
|
420
|
-
// Icon should be at x - 10, y - 10
|
|
421
|
-
expect(icon).toHaveAttribute('data-x', '90');
|
|
422
|
-
expect(icon).toHaveAttribute('data-y', '90');
|
|
423
|
-
});
|
|
424
|
-
});
|
|
425
|
-
|
|
426
|
-
describe('edge cases', () => {
|
|
427
|
-
it('should handle very small radius', () => {
|
|
428
|
-
const { getByTestId } = render(
|
|
429
|
-
<CircleComponent
|
|
430
|
-
{...defaultProps}
|
|
431
|
-
radius={5}
|
|
432
|
-
/>
|
|
433
|
-
);
|
|
434
|
-
|
|
435
|
-
const circle = getByTestId('circle');
|
|
436
|
-
expect(circle).toHaveAttribute('radius', '5');
|
|
437
|
-
});
|
|
438
|
-
|
|
439
|
-
it('should handle very large radius', () => {
|
|
440
|
-
const { getByTestId } = render(
|
|
441
|
-
<CircleComponent
|
|
442
|
-
{...defaultProps}
|
|
443
|
-
radius={200}
|
|
444
|
-
/>
|
|
445
|
-
);
|
|
446
|
-
|
|
447
|
-
const circle = getByTestId('circle');
|
|
448
|
-
expect(circle).toHaveAttribute('radius', '200');
|
|
449
|
-
});
|
|
450
|
-
|
|
451
|
-
it('should handle different scale values', () => {
|
|
452
|
-
const { getByTestId } = render(
|
|
453
|
-
<CircleComponent
|
|
454
|
-
{...defaultProps}
|
|
455
|
-
scale={0.5}
|
|
456
|
-
/>
|
|
457
|
-
);
|
|
458
|
-
|
|
459
|
-
const group = getByTestId('group');
|
|
460
|
-
expect(group).toHaveAttribute('scaleX', '0.5');
|
|
461
|
-
expect(group).toHaveAttribute('scaleY', '0.5');
|
|
462
|
-
});
|
|
463
|
-
});
|
|
464
|
-
});
|