@pie-lib/editable-html-tip-tap 2.1.2-next.3 → 2.1.2-next.31

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.
Files changed (273) hide show
  1. package/dist/components/CharacterPicker.d.ts +31 -0
  2. package/dist/components/CharacterPicker.js +131 -0
  3. package/dist/components/EditableHtml.d.ts +11 -0
  4. package/dist/components/EditableHtml.js +291 -0
  5. package/dist/components/MenuBar.d.ts +11 -0
  6. package/dist/components/MenuBar.js +462 -0
  7. package/dist/components/TiptapContainer.d.ts +11 -0
  8. package/dist/components/TiptapContainer.js +154 -0
  9. package/dist/components/characters/characterUtils.d.ts +35 -0
  10. package/dist/components/characters/characterUtils.js +465 -0
  11. package/dist/components/characters/custom-popper.d.ts +14 -0
  12. package/dist/components/characters/custom-popper.js +32 -0
  13. package/dist/components/common/done-button.d.ts +30 -0
  14. package/dist/components/common/done-button.js +26 -0
  15. package/dist/components/common/toolbar-buttons.d.ts +38 -0
  16. package/dist/components/common/toolbar-buttons.js +91 -0
  17. package/dist/components/icons/CssIcon.d.ts +11 -0
  18. package/dist/components/icons/CssIcon.js +14 -0
  19. package/dist/components/icons/RespArea.d.ts +26 -0
  20. package/dist/components/icons/RespArea.js +42 -0
  21. package/dist/components/icons/TableIcons.d.ts +14 -0
  22. package/dist/components/icons/TableIcons.js +32 -0
  23. package/dist/components/icons/TextAlign.d.ts +18 -0
  24. package/dist/components/icons/TextAlign.js +134 -0
  25. package/dist/components/image/AltDialog.d.ts +22 -0
  26. package/dist/components/image/AltDialog.js +61 -0
  27. package/dist/components/image/ImageToolbar.d.ts +24 -0
  28. package/dist/components/image/ImageToolbar.js +80 -0
  29. package/dist/components/image/InsertImageHandler.d.ts +32 -0
  30. package/dist/components/image/InsertImageHandler.js +53 -0
  31. package/dist/components/media/MediaDialog.d.ts +43 -0
  32. package/dist/components/media/MediaDialog.js +389 -0
  33. package/dist/components/media/MediaToolbar.d.ts +19 -0
  34. package/dist/components/media/MediaToolbar.js +41 -0
  35. package/dist/components/media/MediaWrapper.d.ts +19 -0
  36. package/dist/components/respArea/DragInTheBlank/DragInTheBlank.d.ts +23 -0
  37. package/dist/components/respArea/DragInTheBlank/DragInTheBlank.js +58 -0
  38. package/dist/components/respArea/DragInTheBlank/choice.d.ts +56 -0
  39. package/dist/components/respArea/DragInTheBlank/choice.js +156 -0
  40. package/dist/components/respArea/ExplicitConstructedResponse.d.ts +20 -0
  41. package/dist/components/respArea/ExplicitConstructedResponse.js +83 -0
  42. package/dist/components/respArea/InlineDropdown.d.ts +18 -0
  43. package/dist/components/respArea/InlineDropdown.js +119 -0
  44. package/dist/components/respArea/MathTemplated.d.ts +19 -0
  45. package/dist/components/respArea/MathTemplated.js +97 -0
  46. package/dist/components/respArea/ToolbarIcon.d.ts +14 -0
  47. package/dist/components/respArea/ToolbarIcon.js +17 -0
  48. package/dist/components/respArea/inlineDropdownUtils.d.ts +15 -0
  49. package/dist/components/respArea/inlineDropdownUtils.js +15 -0
  50. package/dist/constants.d.ts +13 -0
  51. package/dist/constants.js +4 -0
  52. package/dist/extensions/css.d.ts +11 -0
  53. package/dist/extensions/css.js +115 -0
  54. package/dist/extensions/custom-toolbar-wrapper.d.ts +11 -0
  55. package/dist/extensions/custom-toolbar-wrapper.js +61 -0
  56. package/dist/extensions/div-node.d.ts +10 -0
  57. package/dist/extensions/div-node.js +42 -0
  58. package/dist/extensions/ensure-empty-root-div.d.ts +14 -0
  59. package/dist/extensions/ensure-empty-root-div.js +24 -0
  60. package/dist/extensions/ensure-list-item-content-is-div.d.ts +15 -0
  61. package/dist/extensions/ensure-list-item-content-is-div.js +31 -0
  62. package/dist/extensions/extended-list-item.d.ts +13 -0
  63. package/dist/extensions/extended-list-item.js +5 -0
  64. package/dist/extensions/extended-table-cell.d.ts +10 -0
  65. package/dist/extensions/extended-table-cell.js +6 -0
  66. package/dist/extensions/extended-table.d.ts +17 -0
  67. package/dist/extensions/extended-table.js +34 -0
  68. package/dist/extensions/heading-paragraph.d.ts +17 -0
  69. package/dist/extensions/heading-paragraph.js +30 -0
  70. package/dist/extensions/image-component.d.ts +22 -0
  71. package/dist/extensions/image-component.js +220 -0
  72. package/dist/extensions/image.d.ts +10 -0
  73. package/dist/extensions/image.js +68 -0
  74. package/dist/extensions/index.d.ts +16 -0
  75. package/dist/extensions/index.js +64 -0
  76. package/dist/extensions/math.d.ts +15 -0
  77. package/dist/extensions/math.js +158 -0
  78. package/dist/extensions/media.d.ts +19 -0
  79. package/dist/extensions/media.js +149 -0
  80. package/dist/extensions/responseArea.d.ts +27 -0
  81. package/dist/extensions/responseArea.js +259 -0
  82. package/dist/index.d.ts +13 -0
  83. package/dist/index.js +7 -0
  84. package/dist/node_modules/.bun/clsx@2.1.1/node_modules/clsx/dist/clsx.js +16 -0
  85. package/dist/styles/editorContainerStyles.d.ts +134 -0
  86. package/dist/theme.d.ts +9 -0
  87. package/dist/utils/helper.d.ts +9 -0
  88. package/dist/utils/helper.js +27 -0
  89. package/dist/utils/size.d.ts +9 -0
  90. package/dist/utils/size.js +14 -0
  91. package/package.json +56 -40
  92. package/CHANGELOG.json +0 -32
  93. package/CHANGELOG.md +0 -2532
  94. package/LICENSE.md +0 -5
  95. package/lib/components/CharacterPicker.js +0 -195
  96. package/lib/components/CharacterPicker.js.map +0 -1
  97. package/lib/components/EditableHtml.js +0 -375
  98. package/lib/components/EditableHtml.js.map +0 -1
  99. package/lib/components/MenuBar.js +0 -693
  100. package/lib/components/MenuBar.js.map +0 -1
  101. package/lib/components/TiptapContainer.js +0 -234
  102. package/lib/components/TiptapContainer.js.map +0 -1
  103. package/lib/components/characters/characterUtils.js +0 -378
  104. package/lib/components/characters/characterUtils.js.map +0 -1
  105. package/lib/components/characters/custom-popper.js +0 -44
  106. package/lib/components/characters/custom-popper.js.map +0 -1
  107. package/lib/components/common/done-button.js +0 -34
  108. package/lib/components/common/done-button.js.map +0 -1
  109. package/lib/components/common/toolbar-buttons.js +0 -144
  110. package/lib/components/common/toolbar-buttons.js.map +0 -1
  111. package/lib/components/icons/CssIcon.js +0 -25
  112. package/lib/components/icons/CssIcon.js.map +0 -1
  113. package/lib/components/icons/RespArea.js +0 -72
  114. package/lib/components/icons/RespArea.js.map +0 -1
  115. package/lib/components/icons/TableIcons.js +0 -53
  116. package/lib/components/icons/TableIcons.js.map +0 -1
  117. package/lib/components/icons/TextAlign.js +0 -157
  118. package/lib/components/icons/TextAlign.js.map +0 -1
  119. package/lib/components/image/AltDialog.js +0 -98
  120. package/lib/components/image/AltDialog.js.map +0 -1
  121. package/lib/components/image/ImageToolbar.js +0 -137
  122. package/lib/components/image/ImageToolbar.js.map +0 -1
  123. package/lib/components/image/InsertImageHandler.js +0 -135
  124. package/lib/components/image/InsertImageHandler.js.map +0 -1
  125. package/lib/components/media/MediaDialog.js +0 -594
  126. package/lib/components/media/MediaDialog.js.map +0 -1
  127. package/lib/components/media/MediaToolbar.js +0 -74
  128. package/lib/components/media/MediaToolbar.js.map +0 -1
  129. package/lib/components/media/MediaWrapper.js +0 -67
  130. package/lib/components/media/MediaWrapper.js.map +0 -1
  131. package/lib/components/respArea/DragInTheBlank/DragInTheBlank.js +0 -84
  132. package/lib/components/respArea/DragInTheBlank/DragInTheBlank.js.map +0 -1
  133. package/lib/components/respArea/DragInTheBlank/choice.js +0 -250
  134. package/lib/components/respArea/DragInTheBlank/choice.js.map +0 -1
  135. package/lib/components/respArea/ExplicitConstructedResponse.js +0 -136
  136. package/lib/components/respArea/ExplicitConstructedResponse.js.map +0 -1
  137. package/lib/components/respArea/InlineDropdown.js +0 -165
  138. package/lib/components/respArea/InlineDropdown.js.map +0 -1
  139. package/lib/components/respArea/MathTemplated.js +0 -130
  140. package/lib/components/respArea/MathTemplated.js.map +0 -1
  141. package/lib/components/respArea/ToolbarIcon.js +0 -81
  142. package/lib/components/respArea/ToolbarIcon.js.map +0 -1
  143. package/lib/constants.js +0 -11
  144. package/lib/constants.js.map +0 -1
  145. package/lib/extensions/css.js +0 -217
  146. package/lib/extensions/css.js.map +0 -1
  147. package/lib/extensions/custom-toolbar-wrapper.js +0 -92
  148. package/lib/extensions/custom-toolbar-wrapper.js.map +0 -1
  149. package/lib/extensions/div-node.js +0 -83
  150. package/lib/extensions/div-node.js.map +0 -1
  151. package/lib/extensions/ensure-empty-root-div.js +0 -48
  152. package/lib/extensions/ensure-empty-root-div.js.map +0 -1
  153. package/lib/extensions/ensure-list-item-content-is-div.js +0 -64
  154. package/lib/extensions/ensure-list-item-content-is-div.js.map +0 -1
  155. package/lib/extensions/extended-list-item.js +0 -15
  156. package/lib/extensions/extended-list-item.js.map +0 -1
  157. package/lib/extensions/extended-table-cell.js +0 -22
  158. package/lib/extensions/extended-table-cell.js.map +0 -1
  159. package/lib/extensions/extended-table.js +0 -75
  160. package/lib/extensions/extended-table.js.map +0 -1
  161. package/lib/extensions/heading-paragraph.js +0 -61
  162. package/lib/extensions/heading-paragraph.js.map +0 -1
  163. package/lib/extensions/image-component.js +0 -348
  164. package/lib/extensions/image-component.js.map +0 -1
  165. package/lib/extensions/image.js +0 -134
  166. package/lib/extensions/image.js.map +0 -1
  167. package/lib/extensions/index.js +0 -46
  168. package/lib/extensions/index.js.map +0 -1
  169. package/lib/extensions/math.js +0 -343
  170. package/lib/extensions/math.js.map +0 -1
  171. package/lib/extensions/media.js +0 -243
  172. package/lib/extensions/media.js.map +0 -1
  173. package/lib/extensions/responseArea.js +0 -446
  174. package/lib/extensions/responseArea.js.map +0 -1
  175. package/lib/index.js +0 -30
  176. package/lib/index.js.map +0 -1
  177. package/lib/styles/editorContainerStyles.js +0 -137
  178. package/lib/styles/editorContainerStyles.js.map +0 -1
  179. package/lib/theme.js +0 -8
  180. package/lib/theme.js.map +0 -1
  181. package/lib/utils/helper.js +0 -73
  182. package/lib/utils/helper.js.map +0 -1
  183. package/lib/utils/size.js +0 -26
  184. package/lib/utils/size.js.map +0 -1
  185. package/src/__tests__/EditableHtml.test.jsx +0 -474
  186. package/src/__tests__/constants.test.js +0 -19
  187. package/src/__tests__/div-to-paragraph-conversion.test.jsx +0 -125
  188. package/src/__tests__/extensions.test.js +0 -208
  189. package/src/__tests__/index.test.jsx +0 -154
  190. package/src/__tests__/size-utils.test.js +0 -64
  191. package/src/__tests__/theme.test.js +0 -17
  192. package/src/components/CharacterPicker.jsx +0 -200
  193. package/src/components/EditableHtml.jsx +0 -438
  194. package/src/components/MenuBar.jsx +0 -549
  195. package/src/components/TiptapContainer.jsx +0 -219
  196. package/src/components/__tests__/AltDialog.test.jsx +0 -147
  197. package/src/components/__tests__/CharacterPicker.test.jsx +0 -219
  198. package/src/components/__tests__/CssIcon.test.jsx +0 -46
  199. package/src/components/__tests__/DragInTheBlank.test.jsx +0 -255
  200. package/src/components/__tests__/ExplicitConstructedResponse.test.jsx +0 -204
  201. package/src/components/__tests__/ImageToolbar.test.jsx +0 -128
  202. package/src/components/__tests__/InlineDropdown.test.jsx +0 -380
  203. package/src/components/__tests__/InsertImageHandler.test.js +0 -161
  204. package/src/components/__tests__/MediaDialog.test.jsx +0 -293
  205. package/src/components/__tests__/MediaToolbar.test.jsx +0 -74
  206. package/src/components/__tests__/MediaWrapper.test.jsx +0 -81
  207. package/src/components/__tests__/MenuBar.test.jsx +0 -249
  208. package/src/components/__tests__/RespArea.test.jsx +0 -122
  209. package/src/components/__tests__/TableIcons.test.jsx +0 -149
  210. package/src/components/__tests__/TextAlign.test.jsx +0 -167
  211. package/src/components/__tests__/TiptapContainer.test.jsx +0 -138
  212. package/src/components/__tests__/characterUtils.test.js +0 -166
  213. package/src/components/__tests__/choice.test.jsx +0 -171
  214. package/src/components/__tests__/custom-popper.test.jsx +0 -82
  215. package/src/components/__tests__/done-button.test.jsx +0 -54
  216. package/src/components/__tests__/toolbar-buttons.test.jsx +0 -234
  217. package/src/components/characters/characterUtils.js +0 -447
  218. package/src/components/characters/custom-popper.js +0 -38
  219. package/src/components/common/done-button.jsx +0 -27
  220. package/src/components/common/toolbar-buttons.jsx +0 -122
  221. package/src/components/icons/CssIcon.jsx +0 -15
  222. package/src/components/icons/RespArea.jsx +0 -71
  223. package/src/components/icons/TableIcons.jsx +0 -52
  224. package/src/components/icons/TextAlign.jsx +0 -114
  225. package/src/components/image/AltDialog.jsx +0 -82
  226. package/src/components/image/ImageToolbar.jsx +0 -99
  227. package/src/components/image/InsertImageHandler.js +0 -107
  228. package/src/components/media/MediaDialog.jsx +0 -596
  229. package/src/components/media/MediaToolbar.jsx +0 -49
  230. package/src/components/media/MediaWrapper.jsx +0 -39
  231. package/src/components/respArea/DragInTheBlank/DragInTheBlank.jsx +0 -76
  232. package/src/components/respArea/DragInTheBlank/choice.jsx +0 -256
  233. package/src/components/respArea/ExplicitConstructedResponse.jsx +0 -135
  234. package/src/components/respArea/InlineDropdown.jsx +0 -167
  235. package/src/components/respArea/MathTemplated.jsx +0 -124
  236. package/src/components/respArea/ToolbarIcon.jsx +0 -66
  237. package/src/components/respArea/__tests__/MathTemplated.test.jsx +0 -210
  238. package/src/constants.js +0 -5
  239. package/src/extensions/__tests__/css.test.js +0 -196
  240. package/src/extensions/__tests__/custom-toolbar-wrapper.test.jsx +0 -180
  241. package/src/extensions/__tests__/divNode.test.js +0 -87
  242. package/src/extensions/__tests__/ensure-empty-root-div.test.js +0 -57
  243. package/src/extensions/__tests__/ensure-list-item-content-is-div.test.js +0 -44
  244. package/src/extensions/__tests__/extended-list-item.test.js +0 -13
  245. package/src/extensions/__tests__/extended-table-cell.test.js +0 -22
  246. package/src/extensions/__tests__/extended-table.test.js +0 -183
  247. package/src/extensions/__tests__/image-component.test.jsx +0 -345
  248. package/src/extensions/__tests__/image.test.js +0 -237
  249. package/src/extensions/__tests__/math.test.js +0 -459
  250. package/src/extensions/__tests__/media-node-view.test.jsx +0 -298
  251. package/src/extensions/__tests__/media.test.js +0 -271
  252. package/src/extensions/__tests__/responseArea.test.js +0 -601
  253. package/src/extensions/css.js +0 -220
  254. package/src/extensions/custom-toolbar-wrapper.jsx +0 -78
  255. package/src/extensions/div-node.js +0 -86
  256. package/src/extensions/ensure-empty-root-div.js +0 -47
  257. package/src/extensions/ensure-list-item-content-is-div.js +0 -62
  258. package/src/extensions/extended-list-item.js +0 -10
  259. package/src/extensions/extended-table-cell.js +0 -19
  260. package/src/extensions/extended-table.js +0 -60
  261. package/src/extensions/heading-paragraph.js +0 -53
  262. package/src/extensions/image-component.jsx +0 -338
  263. package/src/extensions/image.js +0 -109
  264. package/src/extensions/index.js +0 -81
  265. package/src/extensions/math.js +0 -327
  266. package/src/extensions/media.js +0 -188
  267. package/src/extensions/responseArea.js +0 -401
  268. package/src/index.jsx +0 -5
  269. package/src/styles/editorContainerStyles.js +0 -145
  270. package/src/theme.js +0 -1
  271. package/src/utils/__tests__/helper.test.js +0 -126
  272. package/src/utils/helper.js +0 -69
  273. package/src/utils/size.js +0 -32
@@ -1,138 +0,0 @@
1
- import React from 'react';
2
- import { render } from '@testing-library/react';
3
- import TiptapContainer from '../TiptapContainer';
4
-
5
- jest.mock('../MenuBar', () => ({
6
- __esModule: true,
7
- default: ({ editor, toolbarOpts }) => <div data-testid="styled-menu-bar">MenuBar for editor</div>,
8
- }));
9
-
10
- describe('TiptapContainer', () => {
11
- const mockEditor = {
12
- commands: {
13
- focus: jest.fn(),
14
- },
15
- };
16
-
17
- const defaultProps = {
18
- editor: mockEditor,
19
- disabled: false,
20
- children: <div data-testid="editor-content">Editor content</div>,
21
- activePlugins: ['bold', 'italic'],
22
- toolbarOpts: {},
23
- responseAreaProps: {},
24
- };
25
-
26
- beforeEach(() => {
27
- jest.clearAllMocks();
28
- });
29
-
30
- it('renders without crashing', () => {
31
- const { container } = render(<TiptapContainer {...defaultProps} />);
32
- expect(container).toBeInTheDocument();
33
- });
34
-
35
- it('renders children', () => {
36
- const { getByTestId } = render(<TiptapContainer {...defaultProps} />);
37
- expect(getByTestId('editor-content')).toBeInTheDocument();
38
- });
39
-
40
- it('renders MenuBar when editor is provided', () => {
41
- const { getByTestId } = render(<TiptapContainer {...defaultProps} />);
42
- expect(getByTestId('styled-menu-bar')).toBeInTheDocument();
43
- });
44
-
45
- it('does not render MenuBar when editor is not provided', () => {
46
- const { queryByTestId } = render(<TiptapContainer {...defaultProps} editor={null} />);
47
- expect(queryByTestId('styled-menu-bar')).not.toBeInTheDocument();
48
- });
49
-
50
- it('applies noBorder style when toolbarOpts.noBorder is true', () => {
51
- const { container } = render(<TiptapContainer {...defaultProps} toolbarOpts={{ noBorder: true }} />);
52
- const root = container.firstChild;
53
- expect(root).toHaveStyle({ border: 'none' });
54
- });
55
-
56
- it('applies error style when toolbarOpts.error is true', () => {
57
- const { container } = render(<TiptapContainer {...defaultProps} toolbarOpts={{ error: true }} />);
58
- expect(container.firstChild).toBeInTheDocument();
59
- });
60
-
61
- it('applies noPadding style when toolbarOpts.noPadding is true', () => {
62
- const { container } = render(<TiptapContainer {...defaultProps} toolbarOpts={{ noPadding: true }} />);
63
- const children = container.querySelector('div > div > div');
64
- expect(children).toHaveStyle({ padding: '0' });
65
- });
66
-
67
- it('disables scrollbar when disableScrollbar is true', () => {
68
- const { container } = render(<TiptapContainer {...defaultProps} disableScrollbar={true} />);
69
- expect(container).toBeInTheDocument();
70
- });
71
-
72
- it('applies width from props', () => {
73
- const { container } = render(<TiptapContainer {...defaultProps} width={500} />);
74
- const root = container.firstChild;
75
- expect(root).toHaveStyle({ width: '500px' });
76
- });
77
-
78
- it('applies minWidth from props', () => {
79
- const { container } = render(<TiptapContainer {...defaultProps} minWidth={300} />);
80
- const root = container.firstChild;
81
- expect(root).toHaveStyle({ minWidth: '300px' });
82
- });
83
-
84
- it('applies maxWidth from props', () => {
85
- const { container } = render(<TiptapContainer {...defaultProps} maxWidth={800} />);
86
- const root = container.firstChild;
87
- expect(root).toHaveStyle({ maxWidth: '800px' });
88
- });
89
-
90
- it('applies height from props', () => {
91
- const { container } = render(<TiptapContainer {...defaultProps} height={400} />);
92
- const root = container.firstChild;
93
- expect(root).toBeInTheDocument();
94
- });
95
-
96
- it('applies minHeight from props', () => {
97
- const { container } = render(<TiptapContainer {...defaultProps} minHeight={200} />);
98
- const root = container.firstChild;
99
- expect(root).toBeInTheDocument();
100
- });
101
-
102
- it('applies maxHeight from props', () => {
103
- const { container } = render(<TiptapContainer {...defaultProps} maxHeight={600} />);
104
- const root = container.firstChild;
105
- expect(root).toBeInTheDocument();
106
- });
107
-
108
- it('focuses editor on mount when autoFocus is true', () => {
109
- jest.useFakeTimers();
110
- const { container } = render(<TiptapContainer {...defaultProps} autoFocus={true} />);
111
- jest.runAllTimers();
112
- // Just verify the component rendered with autoFocus
113
- expect(container).toBeInTheDocument();
114
- jest.useRealTimers();
115
- });
116
-
117
- it('does not focus editor when autoFocus is false', () => {
118
- render(<TiptapContainer {...defaultProps} autoFocus={false} />);
119
- expect(mockEditor.commands.focus).not.toHaveBeenCalled();
120
- });
121
-
122
- it('passes className to root element', () => {
123
- const { container } = render(<TiptapContainer {...defaultProps} className="custom-class" />);
124
- expect(container.firstChild).toHaveClass('custom-class');
125
- });
126
-
127
- it('handles width as string with units', () => {
128
- const { container } = render(<TiptapContainer {...defaultProps} width="50%" />);
129
- // Width is applied via styled component, just verify it rendered
130
- expect(container).toBeInTheDocument();
131
- });
132
-
133
- it('passes onChange to MenuBar', () => {
134
- const onChange = jest.fn();
135
- const { getByTestId } = render(<TiptapContainer {...defaultProps} onChange={onChange} />);
136
- expect(getByTestId('styled-menu-bar')).toBeInTheDocument();
137
- });
138
- });
@@ -1,166 +0,0 @@
1
- import { spanishConfig, specialConfig } from '../characters/characterUtils';
2
-
3
- describe('characterUtils', () => {
4
- describe('spanishConfig', () => {
5
- it('exports spanishConfig object', () => {
6
- expect(spanishConfig).toBeDefined();
7
- expect(typeof spanishConfig).toBe('object');
8
- });
9
-
10
- it('has characters array', () => {
11
- expect(spanishConfig).toHaveProperty('characters');
12
- expect(Array.isArray(spanishConfig.characters)).toBe(true);
13
- });
14
-
15
- it('has correct character structure', () => {
16
- expect(spanishConfig.characters.length).toBeGreaterThan(0);
17
- spanishConfig.characters.forEach((row) => {
18
- expect(Array.isArray(row)).toBe(true);
19
- });
20
- });
21
-
22
- it('includes Spanish characters', () => {
23
- const allChars = spanishConfig.characters.flat();
24
- expect(allChars).toContain('á');
25
- expect(allChars).toContain('é');
26
- expect(allChars).toContain('í');
27
- expect(allChars).toContain('ó');
28
- expect(allChars).toContain('ú');
29
- expect(allChars).toContain('ñ');
30
- expect(allChars).toContain('Ñ');
31
- });
32
-
33
- it('includes accented uppercase letters', () => {
34
- const allChars = spanishConfig.characters.flat();
35
- expect(allChars).toContain('Á');
36
- expect(allChars).toContain('É');
37
- expect(allChars).toContain('Í');
38
- expect(allChars).toContain('Ó');
39
- expect(allChars).toContain('Ú');
40
- });
41
-
42
- it('includes special punctuation', () => {
43
- const allChars = spanishConfig.characters.flat();
44
- expect(allChars).toContain('¿');
45
- expect(allChars).toContain('¡');
46
- expect(allChars).toContain('«');
47
- expect(allChars).toContain('»');
48
- });
49
- });
50
-
51
- describe('specialConfig', () => {
52
- it('exports specialConfig object', () => {
53
- expect(specialConfig).toBeDefined();
54
- expect(typeof specialConfig).toBe('object');
55
- });
56
-
57
- it('has hasPreview property set to true', () => {
58
- expect(specialConfig).toHaveProperty('hasPreview', true);
59
- });
60
-
61
- it('has characters array', () => {
62
- expect(specialConfig).toHaveProperty('characters');
63
- expect(Array.isArray(specialConfig.characters)).toBe(true);
64
- });
65
-
66
- it('has correct character structure with metadata', () => {
67
- expect(specialConfig.characters.length).toBeGreaterThan(0);
68
- specialConfig.characters.forEach((row) => {
69
- expect(Array.isArray(row)).toBe(true);
70
- row.forEach((char) => {
71
- expect(char).toHaveProperty('unicode');
72
- expect(char).toHaveProperty('description');
73
- expect(char).toHaveProperty('write');
74
- expect(char).toHaveProperty('label');
75
- });
76
- });
77
- });
78
-
79
- it('includes currency symbols', () => {
80
- const allChars = specialConfig.characters.flat();
81
- const euroChar = allChars.find((c) => c.write === '€');
82
- expect(euroChar).toBeDefined();
83
- expect(euroChar.unicode).toBe('U+20AC');
84
- expect(euroChar.description).toBe('EURO SIGN');
85
-
86
- const centChar = allChars.find((c) => c.write === '¢');
87
- expect(centChar).toBeDefined();
88
-
89
- const poundChar = allChars.find((c) => c.write === '£');
90
- expect(poundChar).toBeDefined();
91
-
92
- const yenChar = allChars.find((c) => c.write === '¥');
93
- expect(yenChar).toBeDefined();
94
- });
95
-
96
- it('includes accented characters', () => {
97
- const allChars = specialConfig.characters.flat();
98
- const chars = ['á', 'é', 'í', 'ó', 'ú', 'ñ'];
99
- chars.forEach((char) => {
100
- const found = allChars.find((c) => c.write === char);
101
- expect(found).toBeDefined();
102
- });
103
- });
104
-
105
- it('includes space characters', () => {
106
- const allChars = specialConfig.characters.flat();
107
- const descriptions = allChars.map((c) => c.description);
108
- expect(descriptions).toContain('NO-BREAK SPACE');
109
- expect(descriptions).toContain('HAIR SPACE');
110
- expect(descriptions).toContain('THIN SPACE');
111
- expect(descriptions).toContain('EM SPACE');
112
- });
113
-
114
- it('includes diacritics', () => {
115
- const allChars = specialConfig.characters.flat();
116
- const acuteAccent = allChars.find((c) => c.description === 'ACUTE ACCENT');
117
- expect(acuteAccent).toBeDefined();
118
-
119
- const circumflex = allChars.find((c) => c.description === 'CIRCUMFLEX ACCENT');
120
- expect(circumflex).toBeDefined();
121
-
122
- const grave = allChars.find((c) => c.description === 'GRAVE ACCENT');
123
- expect(grave).toBeDefined();
124
-
125
- const diaeresis = allChars.find((c) => c.description === 'DIAERESIS');
126
- expect(diaeresis).toBeDefined();
127
- });
128
-
129
- it('includes punctuation marks', () => {
130
- const allChars = specialConfig.characters.flat();
131
- const descriptions = allChars.map((c) => c.description);
132
- expect(descriptions).toContain('INVERTED QUESTION MARK');
133
- expect(descriptions).toContain('INVERTED EXCLAMATION MARK');
134
- expect(descriptions).toContain('SECTION SIGN');
135
- expect(descriptions).toContain('BULLET');
136
- expect(descriptions).toContain('HORIZONTAL ELLIPSIS');
137
- });
138
-
139
- it('includes quotation marks', () => {
140
- const allChars = specialConfig.characters.flat();
141
- const leftQuote = allChars.find((c) => c.description === 'LEFT-POINTING DOUBLE ANGLE QUOTATION MARK');
142
- expect(leftQuote).toBeDefined();
143
-
144
- const rightQuote = allChars.find((c) => c.description === 'RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK');
145
- expect(rightQuote).toBeDefined();
146
- });
147
-
148
- it('includes dashes', () => {
149
- const allChars = specialConfig.characters.flat();
150
- const enDash = allChars.find((c) => c.description === 'EN DASH');
151
- expect(enDash).toBeDefined();
152
-
153
- const emDash = allChars.find((c) => c.description === 'EM DASH');
154
- expect(emDash).toBeDefined();
155
-
156
- const minus = allChars.find((c) => c.description === 'MINUS SIGN');
157
- expect(minus).toBeDefined();
158
- });
159
-
160
- it('some characters have extraProps', () => {
161
- const allChars = specialConfig.characters.flat();
162
- const charsWithExtraProps = allChars.filter((c) => c.extraProps);
163
- expect(charsWithExtraProps.length).toBeGreaterThan(0);
164
- });
165
- });
166
- });
@@ -1,171 +0,0 @@
1
- import React from 'react';
2
- import { fireEvent, render } from '@testing-library/react';
3
- import { BlankContent } from '../respArea/DragInTheBlank/choice';
4
-
5
- jest.mock('@pie-lib/math-rendering', () => ({
6
- renderMath: jest.fn(),
7
- }));
8
-
9
- jest.mock('@dnd-kit/core', () => ({
10
- useDraggable: () => ({
11
- attributes: {},
12
- listeners: {},
13
- setNodeRef: jest.fn(),
14
- isDragging: false,
15
- }),
16
- useDroppable: () => ({
17
- setNodeRef: jest.fn(),
18
- isOver: false,
19
- active: null,
20
- }),
21
- }));
22
-
23
- describe('BlankContent', () => {
24
- const mockN = {
25
- index: '0',
26
- };
27
-
28
- const mockValue = {
29
- value: 'Test Value',
30
- };
31
-
32
- const defaultProps = {
33
- n: mockN,
34
- value: mockValue,
35
- isDragging: false,
36
- isOver: false,
37
- dragItem: null,
38
- };
39
-
40
- beforeEach(() => {
41
- jest.clearAllMocks();
42
- });
43
-
44
- it('renders without crashing', () => {
45
- const { container } = render(<BlankContent {...defaultProps} />);
46
- expect(container).toBeInTheDocument();
47
- });
48
-
49
- it('displays value text', () => {
50
- const { container } = render(<BlankContent {...defaultProps} />);
51
- const contentDiv = container.querySelector('div[data-key]');
52
- expect(contentDiv).toBeInTheDocument();
53
- });
54
-
55
- it('displays nbsp when value is empty', () => {
56
- const emptyValue = { value: '' };
57
- const { container } = render(<BlankContent {...defaultProps} value={emptyValue} />);
58
- expect(container).toBeInTheDocument();
59
- });
60
-
61
- it('shows grip icon when value is present', () => {
62
- const { container } = render(<BlankContent {...defaultProps} />);
63
- const gripIcon = container.querySelector('svg');
64
- expect(gripIcon).toBeInTheDocument();
65
- });
66
-
67
- it('does not show grip icon when value is nbsp', () => {
68
- const emptyValue = { value: '' };
69
- const { container } = render(<BlankContent {...defaultProps} value={emptyValue} />);
70
- // Grip should not be visible
71
- expect(container).toBeInTheDocument();
72
- });
73
-
74
- it('applies correct background when not preview', () => {
75
- const { container } = render(<BlankContent {...defaultProps} />);
76
- const contentDiv = container.querySelector('div[data-key]');
77
- expect(contentDiv).toHaveStyle({ background: 'rgb(255, 255, 255)' });
78
- });
79
-
80
- it('applies preview background when isOver', () => {
81
- const { container } = render(<BlankContent {...defaultProps} isOver={true} />);
82
- const contentDiv = container.querySelector('div[data-key]');
83
- expect(contentDiv).toHaveStyle({ border: '1px solid #d1d1d1' });
84
- });
85
-
86
- it('has correct minimum dimensions', () => {
87
- const { container } = render(<BlankContent {...defaultProps} />);
88
- const contentDiv = container.querySelector('div[data-key]');
89
- expect(contentDiv).toHaveStyle({ minWidth: '178px', minHeight: '36px' });
90
- });
91
-
92
- it('has inline-flex display', () => {
93
- const { container } = render(<BlankContent {...defaultProps} />);
94
- const contentDiv = container.querySelector('div[data-key]');
95
- expect(contentDiv).toHaveStyle({ display: 'inline-flex' });
96
- });
97
-
98
- it('has correct border radius', () => {
99
- const { container } = render(<BlankContent {...defaultProps} />);
100
- const contentDiv = container.querySelector('div[data-key]');
101
- expect(contentDiv).toHaveStyle({ borderRadius: '3px' });
102
- });
103
-
104
- it('has correct padding', () => {
105
- const { container } = render(<BlankContent {...defaultProps} />);
106
- const contentDiv = container.querySelector('div[data-key]');
107
- expect(contentDiv).toHaveStyle({ padding: '8px 8px 8px 35px' });
108
- });
109
-
110
- it('is not content editable', () => {
111
- const { container } = render(<BlankContent {...defaultProps} />);
112
- const contentDiv = container.querySelector('div[data-key]');
113
- expect(contentDiv).toHaveAttribute('contentEditable', 'false');
114
- });
115
-
116
- it('sets data-key attribute', () => {
117
- const { container } = render(<BlankContent {...defaultProps} />);
118
- const contentDiv = container.querySelector('div[data-key]');
119
- expect(contentDiv).toHaveAttribute('data-key', '0');
120
- });
121
-
122
- it('renders children', () => {
123
- const { getByText } = render(
124
- <BlankContent {...defaultProps}>
125
- <span>Child Content</span>
126
- </BlankContent>,
127
- );
128
- expect(getByText('Child Content')).toBeInTheDocument();
129
- });
130
-
131
- it('shows dragItem value when isOver', () => {
132
- const dragItem = { value: { value: 'Dragged Value' } };
133
- const { container } = render(<BlankContent {...defaultProps} isOver={true} dragItem={dragItem} />);
134
- expect(container).toBeInTheDocument();
135
- });
136
-
137
- it('shows nbsp when isDragging', () => {
138
- const { container } = render(<BlankContent {...defaultProps} isDragging={true} />);
139
- expect(container).toBeInTheDocument();
140
- });
141
-
142
- it('positions grip icon correctly', () => {
143
- const { container } = render(<BlankContent {...defaultProps} />);
144
- const gripContainer = container.querySelector('svg')?.parentElement;
145
- if (gripContainer) {
146
- expect(gripContainer).toHaveStyle({ position: 'absolute', top: '6px', left: '15px' });
147
- }
148
- });
149
-
150
- it('applies hover size when isOver', () => {
151
- const { container } = render(<BlankContent {...defaultProps} isOver={true} />);
152
- const contentDiv = container.querySelector('div[data-key]');
153
- expect(contentDiv).toBeInTheDocument();
154
- });
155
-
156
- it('handles click to add selected class', () => {
157
- const { container } = render(<BlankContent {...defaultProps} />);
158
- const contentDiv = container.querySelector('div[data-key]');
159
- fireEvent.click(contentDiv);
160
- expect(contentDiv).toHaveClass('selected');
161
- });
162
-
163
- it('handles click outside to remove selected class', () => {
164
- const { container } = render(<BlankContent {...defaultProps} />);
165
- const contentDiv = container.querySelector('div[data-key]');
166
- fireEvent.click(contentDiv);
167
- expect(contentDiv).toHaveClass('selected');
168
- fireEvent.click(document.body);
169
- expect(contentDiv).not.toHaveClass('selected');
170
- });
171
- });
@@ -1,82 +0,0 @@
1
- import React from 'react';
2
- import { render } from '@testing-library/react';
3
- import CustomPopper from '../characters/custom-popper';
4
-
5
- jest.mock('@mui/material/Popper', () => ({
6
- __esModule: true,
7
- default: ({ children, id, open, ...props }) =>
8
- open ? (
9
- <div id={id} data-testid="popper" {...props}>
10
- {children}
11
- </div>
12
- ) : null,
13
- }));
14
-
15
- describe('CustomPopper', () => {
16
- const mockAnchorEl = document.createElement('div');
17
-
18
- it('renders without crashing', () => {
19
- const { container } = render(<CustomPopper anchorEl={mockAnchorEl}>Content</CustomPopper>);
20
- expect(container).toBeInTheDocument();
21
- });
22
-
23
- it('renders children', () => {
24
- const { getByText } = render(<CustomPopper anchorEl={mockAnchorEl}>Test Content</CustomPopper>);
25
- expect(getByText('Test Content')).toBeInTheDocument();
26
- });
27
-
28
- it('is always open', () => {
29
- const { getByTestId } = render(<CustomPopper anchorEl={mockAnchorEl}>Content</CustomPopper>);
30
- expect(getByTestId('popper')).toBeInTheDocument();
31
- });
32
-
33
- it('has correct id', () => {
34
- const { container } = render(<CustomPopper anchorEl={mockAnchorEl}>Content</CustomPopper>);
35
- const popper = container.querySelector('#mouse-over-popover');
36
- expect(popper).toBeInTheDocument();
37
- });
38
-
39
- it('applies correct styling to typography', () => {
40
- const { getByText } = render(<CustomPopper anchorEl={mockAnchorEl}>Content</CustomPopper>);
41
- const typography = getByText('Content');
42
- expect(typography).toHaveStyle({ fontSize: '50px', textAlign: 'center' });
43
- });
44
-
45
- it('passes additional props to Popper', () => {
46
- const { container } = render(
47
- <CustomPopper anchorEl={mockAnchorEl} onClose={jest.fn()}>
48
- Content
49
- </CustomPopper>,
50
- );
51
- expect(container).toBeInTheDocument();
52
- });
53
-
54
- it('renders multiple children', () => {
55
- const { getByText } = render(
56
- <CustomPopper anchorEl={mockAnchorEl}>
57
- <div>First</div>
58
- <div>Second</div>
59
- </CustomPopper>,
60
- );
61
- expect(getByText('First')).toBeInTheDocument();
62
- expect(getByText('Second')).toBeInTheDocument();
63
- });
64
-
65
- it('has pointer-events disabled', () => {
66
- const { container } = render(<CustomPopper anchorEl={mockAnchorEl}>Content</CustomPopper>);
67
- // Styling is applied via styled component, just verify it rendered
68
- expect(container).toBeInTheDocument();
69
- });
70
-
71
- it('has high z-index', () => {
72
- const { container } = render(<CustomPopper anchorEl={mockAnchorEl}>Content</CustomPopper>);
73
- // Styling is applied via styled component, just verify it rendered
74
- expect(container).toBeInTheDocument();
75
- });
76
-
77
- it('has correct background color', () => {
78
- const { container } = render(<CustomPopper anchorEl={mockAnchorEl}>Content</CustomPopper>);
79
- // Styling is applied via styled component, just verify it rendered
80
- expect(container).toBeInTheDocument();
81
- });
82
- });
@@ -1,54 +0,0 @@
1
- import React from 'react';
2
- import { fireEvent, render } from '@testing-library/react';
3
- import { DoneButton, RawDoneButton } from '../common/done-button';
4
-
5
- describe('RawDoneButton', () => {
6
- it('renders without crashing', () => {
7
- const { container } = render(<RawDoneButton onClick={jest.fn()} />);
8
- expect(container).toBeInTheDocument();
9
- });
10
-
11
- it('renders with Check icon', () => {
12
- const { container } = render(<RawDoneButton onClick={jest.fn()} />);
13
- const button = container.querySelector('button');
14
- expect(button).toBeInTheDocument();
15
- });
16
-
17
- it('calls onClick when clicked', () => {
18
- const onClick = jest.fn();
19
- const { container } = render(<RawDoneButton onClick={onClick} />);
20
- const button = container.querySelector('button');
21
- fireEvent.click(button);
22
- expect(onClick).toHaveBeenCalled();
23
- });
24
-
25
- it('has aria-label "Done"', () => {
26
- const { container } = render(<RawDoneButton onClick={jest.fn()} />);
27
- const button = container.querySelector('button');
28
- expect(button).toHaveAttribute('aria-label', 'Done');
29
- });
30
-
31
- it('accepts doneButtonRef prop', () => {
32
- const doneButtonRef = jest.fn();
33
- const { container } = render(<RawDoneButton onClick={jest.fn()} doneButtonRef={doneButtonRef} />);
34
- // doneButtonRef is passed as buttonRef to IconButton, just verify it's accepted
35
- expect(container).toBeInTheDocument();
36
- });
37
-
38
- it('applies correct styling', () => {
39
- const { container } = render(<RawDoneButton onClick={jest.fn()} />);
40
- const button = container.querySelector('button');
41
- expect(button).toHaveClass('MuiIconButton-root');
42
- });
43
- });
44
-
45
- describe('DoneButton', () => {
46
- it('is the same as RawDoneButton', () => {
47
- expect(DoneButton).toBe(RawDoneButton);
48
- });
49
-
50
- it('renders correctly', () => {
51
- const { container } = render(<DoneButton onClick={jest.fn()} />);
52
- expect(container.querySelector('button')).toBeInTheDocument();
53
- });
54
- });