@capillarytech/creatives-library 8.0.208 → 8.0.210
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/assets/Android.png +0 -0
- package/assets/iOS.png +0 -0
- package/package.json +16 -2
- package/v2Components/HtmlEditor/HTMLEditor.js +508 -0
- package/v2Components/HtmlEditor/__tests__/HTMLEditor.test.js +1809 -0
- package/v2Components/HtmlEditor/__tests__/index.lazy.test.js +532 -0
- package/v2Components/HtmlEditor/_htmlEditor.scss +304 -0
- package/v2Components/HtmlEditor/_index.lazy.scss +26 -0
- package/v2Components/HtmlEditor/components/CodeEditorPane/_codeEditorPane.scss +376 -0
- package/v2Components/HtmlEditor/components/CodeEditorPane/index.js +331 -0
- package/v2Components/HtmlEditor/components/DeviceToggle/__tests__/index.test.js +314 -0
- package/v2Components/HtmlEditor/components/DeviceToggle/_deviceToggle.scss +244 -0
- package/v2Components/HtmlEditor/components/DeviceToggle/index.js +111 -0
- package/v2Components/HtmlEditor/components/EditorToolbar/PreviewModeGroup.js +72 -0
- package/v2Components/HtmlEditor/components/EditorToolbar/__tests__/PreviewModeGroup.test.js +1594 -0
- package/v2Components/HtmlEditor/components/EditorToolbar/_editorToolbar.scss +113 -0
- package/v2Components/HtmlEditor/components/EditorToolbar/_previewModeGroup.scss +82 -0
- package/v2Components/HtmlEditor/components/EditorToolbar/index.js +115 -0
- package/v2Components/HtmlEditor/components/FullscreenModal/_fullscreenModal.scss +57 -0
- package/v2Components/HtmlEditor/components/InAppPreviewPane/ContentOverlay.js +90 -0
- package/v2Components/HtmlEditor/components/InAppPreviewPane/DeviceFrame.js +60 -0
- package/v2Components/HtmlEditor/components/InAppPreviewPane/LayoutSelector.js +58 -0
- package/v2Components/HtmlEditor/components/InAppPreviewPane/__tests__/ContentOverlay.test.js +403 -0
- package/v2Components/HtmlEditor/components/InAppPreviewPane/__tests__/DeviceFrame.test.js +424 -0
- package/v2Components/HtmlEditor/components/InAppPreviewPane/__tests__/LayoutSelector.test.js +248 -0
- package/v2Components/HtmlEditor/components/InAppPreviewPane/_inAppPreviewPane.scss +253 -0
- package/v2Components/HtmlEditor/components/InAppPreviewPane/constants.js +104 -0
- package/v2Components/HtmlEditor/components/InAppPreviewPane/index.js +179 -0
- package/v2Components/HtmlEditor/components/PreviewPane/_previewPane.scss +220 -0
- package/v2Components/HtmlEditor/components/PreviewPane/index.js +229 -0
- package/v2Components/HtmlEditor/components/SplitContainer/SplitContainer.js +276 -0
- package/v2Components/HtmlEditor/components/SplitContainer/__tests__/SplitContainer.test.js +295 -0
- package/v2Components/HtmlEditor/components/SplitContainer/_splitContainer.scss +257 -0
- package/v2Components/HtmlEditor/components/SplitContainer/index.js +7 -0
- package/v2Components/HtmlEditor/components/ValidationErrorDisplay/__tests__/index.test.js +152 -0
- package/v2Components/HtmlEditor/components/ValidationErrorDisplay/_validationErrorDisplay.scss +31 -0
- package/v2Components/HtmlEditor/components/ValidationErrorDisplay/index.js +70 -0
- package/v2Components/HtmlEditor/components/ValidationPanel/__tests__/index.test.js +98 -0
- package/v2Components/HtmlEditor/components/ValidationPanel/_validationPanel.scss +311 -0
- package/v2Components/HtmlEditor/components/ValidationPanel/index.js +297 -0
- package/v2Components/HtmlEditor/components/ValidationPanel/messages.js +57 -0
- package/v2Components/HtmlEditor/components/common/EditorContext.js +84 -0
- package/v2Components/HtmlEditor/components/common/__tests__/EditorContext.test.js +660 -0
- package/v2Components/HtmlEditor/constants.js +241 -0
- package/v2Components/HtmlEditor/hooks/__tests__/useEditorContent.test.js +450 -0
- package/v2Components/HtmlEditor/hooks/__tests__/useInAppContent.test.js +785 -0
- package/v2Components/HtmlEditor/hooks/__tests__/useLayoutState.test.js +580 -0
- package/v2Components/HtmlEditor/hooks/__tests__/useValidation.enhanced.test.js +768 -0
- package/v2Components/HtmlEditor/hooks/__tests__/useValidation.test.js +590 -0
- package/v2Components/HtmlEditor/hooks/useEditorContent.js +274 -0
- package/v2Components/HtmlEditor/hooks/useInAppContent.js +407 -0
- package/v2Components/HtmlEditor/hooks/useLayoutState.js +247 -0
- package/v2Components/HtmlEditor/hooks/useValidation.js +325 -0
- package/v2Components/HtmlEditor/index.js +29 -0
- package/v2Components/HtmlEditor/index.lazy.js +114 -0
- package/v2Components/HtmlEditor/messages.js +389 -0
- package/v2Components/HtmlEditor/utils/__tests__/contentSanitizer.test.js +741 -0
- package/v2Components/HtmlEditor/utils/__tests__/htmlValidator.enhanced.test.js +1042 -0
- package/v2Components/HtmlEditor/utils/__tests__/liquidTemplateSupport.test.js +515 -0
- package/v2Components/HtmlEditor/utils/__tests__/properSyntaxHighlighting.test.js +473 -0
- package/v2Components/HtmlEditor/utils/__tests__/simplePerformance.test.js +1109 -0
- package/v2Components/HtmlEditor/utils/__tests__/validationAdapter.test.js +240 -0
- package/v2Components/HtmlEditor/utils/contentSanitizer.js +433 -0
- package/v2Components/HtmlEditor/utils/htmlValidator.js +508 -0
- package/v2Components/HtmlEditor/utils/liquidTemplateSupport.js +524 -0
- package/v2Components/HtmlEditor/utils/properSyntaxHighlighting.js +163 -0
- package/v2Components/HtmlEditor/utils/simplePerformance.js +145 -0
- package/v2Components/HtmlEditor/utils/validationAdapter.js +130 -0
- package/v2Containers/EmailWrapper/components/HTMLEditorTesting.js +200 -0
- package/v2Containers/EmailWrapper/components/__tests__/HTMLEditorTesting.test.js +545 -0
- package/v2Containers/EmailWrapper/index.js +8 -1
- package/v2Containers/Rcs/index.js +2 -0
- package/v2Containers/Templates/constants.js +8 -0
- package/v2Containers/Templates/index.js +56 -28
- package/v2Containers/Templates/tests/__snapshots__/index.test.js.snap +5 -14
- package/v2Containers/Whatsapp/index.js +1 -0
|
@@ -0,0 +1,473 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* properSyntaxHighlighting Tests
|
|
3
|
+
*
|
|
4
|
+
* Comprehensive tests for CodeMirror 6 syntax highlighting configuration
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
comprehensiveVSCodeTheme,
|
|
9
|
+
cleanEditorTheme,
|
|
10
|
+
createRobustExtensions
|
|
11
|
+
} from '../properSyntaxHighlighting';
|
|
12
|
+
|
|
13
|
+
describe('properSyntaxHighlighting', () => {
|
|
14
|
+
describe('comprehensiveVSCodeTheme', () => {
|
|
15
|
+
it('is defined and has expected structure', () => {
|
|
16
|
+
expect(comprehensiveVSCodeTheme).toBeDefined();
|
|
17
|
+
expect(typeof comprehensiveVSCodeTheme).toBe('object');
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('is a HighlightStyle instance', () => {
|
|
21
|
+
expect(comprehensiveVSCodeTheme).toBeTruthy();
|
|
22
|
+
// HighlightStyle instances are objects created by HighlightStyle.define()
|
|
23
|
+
expect(typeof comprehensiveVSCodeTheme).toBe('object');
|
|
24
|
+
expect(comprehensiveVSCodeTheme).not.toBeNull();
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('can be used as an extension', () => {
|
|
28
|
+
// Should not throw when used
|
|
29
|
+
expect(() => {
|
|
30
|
+
const theme = comprehensiveVSCodeTheme;
|
|
31
|
+
expect(theme).toBeTruthy();
|
|
32
|
+
}).not.toThrow();
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('maintains consistent reference', () => {
|
|
36
|
+
const theme1 = comprehensiveVSCodeTheme;
|
|
37
|
+
const theme2 = comprehensiveVSCodeTheme;
|
|
38
|
+
expect(theme1).toBe(theme2);
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
describe('cleanEditorTheme', () => {
|
|
43
|
+
it('is defined and has expected structure', () => {
|
|
44
|
+
expect(cleanEditorTheme).toBeDefined();
|
|
45
|
+
expect(typeof cleanEditorTheme).toBe('object');
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it('is an EditorView theme instance', () => {
|
|
49
|
+
expect(cleanEditorTheme).toBeTruthy();
|
|
50
|
+
// EditorView themes are objects created by EditorView.theme()
|
|
51
|
+
expect(typeof cleanEditorTheme).toBe('object');
|
|
52
|
+
expect(cleanEditorTheme).not.toBeNull();
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it('can be used as an extension', () => {
|
|
56
|
+
// Should not throw when used
|
|
57
|
+
expect(() => {
|
|
58
|
+
const theme = cleanEditorTheme;
|
|
59
|
+
expect(theme).toBeTruthy();
|
|
60
|
+
}).not.toThrow();
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it('maintains consistent reference', () => {
|
|
64
|
+
const theme1 = cleanEditorTheme;
|
|
65
|
+
const theme2 = cleanEditorTheme;
|
|
66
|
+
expect(theme1).toBe(theme2);
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
describe('createRobustExtensions', () => {
|
|
71
|
+
it('returns an array of extensions', () => {
|
|
72
|
+
const extensions = createRobustExtensions();
|
|
73
|
+
|
|
74
|
+
expect(Array.isArray(extensions)).toBe(true);
|
|
75
|
+
expect(extensions.length).toBe(3);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it('returns extensions with proper structure', () => {
|
|
79
|
+
const extensions = createRobustExtensions();
|
|
80
|
+
|
|
81
|
+
// Each extension should be an object or function
|
|
82
|
+
extensions.forEach((ext, index) => {
|
|
83
|
+
expect(ext).toBeDefined();
|
|
84
|
+
expect(['object', 'function'].includes(typeof ext)).toBe(true);
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it('includes HTML language support as first extension', () => {
|
|
89
|
+
const extensions = createRobustExtensions();
|
|
90
|
+
|
|
91
|
+
// First extension should be HTML language support
|
|
92
|
+
expect(extensions[0]).toBeDefined();
|
|
93
|
+
expect(typeof extensions[0]).toBe('object');
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it('includes syntax highlighting as second extension', () => {
|
|
97
|
+
const extensions = createRobustExtensions();
|
|
98
|
+
|
|
99
|
+
// Second extension should be syntax highlighting
|
|
100
|
+
expect(extensions[1]).toBeDefined();
|
|
101
|
+
expect(typeof extensions[1]).toBe('object');
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
it('includes editor theme as third extension', () => {
|
|
105
|
+
const extensions = createRobustExtensions();
|
|
106
|
+
|
|
107
|
+
// Third extension should be the editor theme
|
|
108
|
+
expect(extensions[2]).toBeDefined();
|
|
109
|
+
expect(extensions[2]).toBe(cleanEditorTheme);
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
it('returns consistent results on multiple calls', () => {
|
|
113
|
+
const extensions1 = createRobustExtensions();
|
|
114
|
+
const extensions2 = createRobustExtensions();
|
|
115
|
+
|
|
116
|
+
expect(extensions1.length).toBe(extensions2.length);
|
|
117
|
+
expect(extensions1[2]).toBe(extensions2[2]); // Theme should be the same reference
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
it('does not throw errors during creation', () => {
|
|
121
|
+
expect(() => {
|
|
122
|
+
createRobustExtensions();
|
|
123
|
+
}).not.toThrow();
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
it('creates valid extensions for CodeMirror', () => {
|
|
127
|
+
const extensions = createRobustExtensions();
|
|
128
|
+
|
|
129
|
+
// All extensions should be valid CodeMirror extensions
|
|
130
|
+
extensions.forEach(ext => {
|
|
131
|
+
expect(ext).toBeTruthy();
|
|
132
|
+
// CodeMirror extensions are typically objects or functions
|
|
133
|
+
expect(['object', 'function'].includes(typeof ext)).toBe(true);
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
describe('Default Export', () => {
|
|
139
|
+
it('exports all main components', () => {
|
|
140
|
+
const defaultExport = require('../properSyntaxHighlighting').default;
|
|
141
|
+
|
|
142
|
+
expect(defaultExport).toBeDefined();
|
|
143
|
+
expect(typeof defaultExport).toBe('object');
|
|
144
|
+
expect(defaultExport).toHaveProperty('comprehensiveVSCodeTheme');
|
|
145
|
+
expect(defaultExport).toHaveProperty('cleanEditorTheme');
|
|
146
|
+
expect(defaultExport).toHaveProperty('createRobustExtensions');
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
it('default export contains correct references', () => {
|
|
150
|
+
const defaultExport = require('../properSyntaxHighlighting').default;
|
|
151
|
+
|
|
152
|
+
expect(defaultExport.comprehensiveVSCodeTheme).toBe(comprehensiveVSCodeTheme);
|
|
153
|
+
expect(defaultExport.cleanEditorTheme).toBe(cleanEditorTheme);
|
|
154
|
+
expect(defaultExport.createRobustExtensions).toBe(createRobustExtensions);
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
it('provides consistent interface', () => {
|
|
158
|
+
const defaultExport = require('../properSyntaxHighlighting').default;
|
|
159
|
+
|
|
160
|
+
// Should be able to use all exported functions
|
|
161
|
+
expect(() => {
|
|
162
|
+
const theme = defaultExport.comprehensiveVSCodeTheme;
|
|
163
|
+
const editorTheme = defaultExport.cleanEditorTheme;
|
|
164
|
+
const extensions = defaultExport.createRobustExtensions();
|
|
165
|
+
|
|
166
|
+
expect(theme).toBeTruthy();
|
|
167
|
+
expect(editorTheme).toBeTruthy();
|
|
168
|
+
expect(extensions).toBeTruthy();
|
|
169
|
+
}).not.toThrow();
|
|
170
|
+
});
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
describe('Integration and Compatibility', () => {
|
|
174
|
+
it('handles CodeMirror dependencies without errors', () => {
|
|
175
|
+
// Should not throw when creating extensions
|
|
176
|
+
expect(() => {
|
|
177
|
+
const extensions = createRobustExtensions();
|
|
178
|
+
expect(extensions).toBeTruthy();
|
|
179
|
+
}).not.toThrow();
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
it('provides theme objects that can be used together', () => {
|
|
183
|
+
const extensions = createRobustExtensions();
|
|
184
|
+
|
|
185
|
+
// Should contain both themes
|
|
186
|
+
expect(extensions).toContain(cleanEditorTheme);
|
|
187
|
+
|
|
188
|
+
// Should be able to access syntax theme
|
|
189
|
+
expect(comprehensiveVSCodeTheme).toBeTruthy();
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
it('maintains extension compatibility', () => {
|
|
193
|
+
const extensions = createRobustExtensions();
|
|
194
|
+
|
|
195
|
+
// All extensions should be compatible with CodeMirror
|
|
196
|
+
extensions.forEach(ext => {
|
|
197
|
+
expect(ext).toBeTruthy();
|
|
198
|
+
expect(['object', 'function'].includes(typeof ext)).toBe(true);
|
|
199
|
+
});
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
it('provides complete syntax highlighting solution', () => {
|
|
203
|
+
const extensions = createRobustExtensions();
|
|
204
|
+
|
|
205
|
+
// Should have exactly 3 extensions: language, highlighting, theme
|
|
206
|
+
expect(extensions.length).toBe(3);
|
|
207
|
+
|
|
208
|
+
// Each should be a valid extension
|
|
209
|
+
extensions.forEach(ext => {
|
|
210
|
+
expect(ext).toBeTruthy();
|
|
211
|
+
});
|
|
212
|
+
});
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
describe('Performance and Memory', () => {
|
|
216
|
+
it('creates extensions reliably without throwing', () => {
|
|
217
|
+
const results = [];
|
|
218
|
+
|
|
219
|
+
// Call createRobustExtensions 50 times and collect results
|
|
220
|
+
for (let i = 0; i < 50; i++) {
|
|
221
|
+
expect(() => {
|
|
222
|
+
const extensions = createRobustExtensions();
|
|
223
|
+
results.push(extensions);
|
|
224
|
+
}).not.toThrow();
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
// Verify all calls returned values of expected shape
|
|
228
|
+
results.forEach((extensions, index) => {
|
|
229
|
+
expect(extensions).toBeDefined();
|
|
230
|
+
expect(Array.isArray(extensions)).toBe(true);
|
|
231
|
+
expect(extensions.length).toBeGreaterThan(0);
|
|
232
|
+
|
|
233
|
+
// Each extension should be a valid CodeMirror extension
|
|
234
|
+
extensions.forEach(ext => {
|
|
235
|
+
expect(ext).toBeTruthy();
|
|
236
|
+
// Extensions can be functions, objects, or other valid CodeMirror extension types
|
|
237
|
+
expect(typeof ext === 'function' || typeof ext === 'object').toBe(true);
|
|
238
|
+
});
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
// Verify structural consistency - all results should have same length and types
|
|
242
|
+
const firstResult = results[0];
|
|
243
|
+
results.forEach((result, index) => {
|
|
244
|
+
expect(result.length).toBe(firstResult.length);
|
|
245
|
+
|
|
246
|
+
// Verify each extension at the same index has the same type and basic structure
|
|
247
|
+
result.forEach((ext, extIndex) => {
|
|
248
|
+
const firstExt = firstResult[extIndex];
|
|
249
|
+
expect(typeof ext).toBe(typeof firstExt);
|
|
250
|
+
|
|
251
|
+
// If it's an object, check it has similar keys (for memoization check)
|
|
252
|
+
if (typeof ext === 'object' && ext !== null && typeof firstExt === 'object' && firstExt !== null) {
|
|
253
|
+
expect(Object.keys(ext).sort()).toEqual(Object.keys(firstExt).sort());
|
|
254
|
+
}
|
|
255
|
+
});
|
|
256
|
+
});
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
it('maintains object references efficiently', () => {
|
|
260
|
+
const theme1 = comprehensiveVSCodeTheme;
|
|
261
|
+
const theme2 = comprehensiveVSCodeTheme;
|
|
262
|
+
const editorTheme1 = cleanEditorTheme;
|
|
263
|
+
const editorTheme2 = cleanEditorTheme;
|
|
264
|
+
|
|
265
|
+
// Should be the same objects (not recreated)
|
|
266
|
+
expect(theme1).toBe(theme2);
|
|
267
|
+
expect(editorTheme1).toBe(editorTheme2);
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
it('handles repeated extension creation', () => {
|
|
271
|
+
// Should not accumulate memory or cause issues
|
|
272
|
+
const results = [];
|
|
273
|
+
|
|
274
|
+
for (let i = 0; i < 10; i++) {
|
|
275
|
+
results.push(createRobustExtensions());
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
// All should be valid
|
|
279
|
+
results.forEach(extensions => {
|
|
280
|
+
expect(extensions.length).toBe(3);
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
// Theme references should be consistent
|
|
284
|
+
results.forEach(extensions => {
|
|
285
|
+
expect(extensions[2]).toBe(cleanEditorTheme);
|
|
286
|
+
});
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
it('does not leak memory with theme creation', () => {
|
|
290
|
+
// Create themes multiple times
|
|
291
|
+
const themes = [];
|
|
292
|
+
for (let i = 0; i < 20; i++) {
|
|
293
|
+
themes.push(comprehensiveVSCodeTheme);
|
|
294
|
+
themes.push(cleanEditorTheme);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
// All references should be the same (no new objects created)
|
|
298
|
+
themes.forEach((theme, index) => {
|
|
299
|
+
if (index % 2 === 0) {
|
|
300
|
+
expect(theme).toBe(comprehensiveVSCodeTheme);
|
|
301
|
+
} else {
|
|
302
|
+
expect(theme).toBe(cleanEditorTheme);
|
|
303
|
+
}
|
|
304
|
+
});
|
|
305
|
+
});
|
|
306
|
+
});
|
|
307
|
+
|
|
308
|
+
describe('Error Handling and Edge Cases', () => {
|
|
309
|
+
it('handles module import gracefully', () => {
|
|
310
|
+
// Should not throw during import
|
|
311
|
+
expect(() => {
|
|
312
|
+
const module = require('../properSyntaxHighlighting');
|
|
313
|
+
expect(module).toBeTruthy();
|
|
314
|
+
}).not.toThrow();
|
|
315
|
+
});
|
|
316
|
+
|
|
317
|
+
it('provides fallback behavior', () => {
|
|
318
|
+
// All exports should be defined even if dependencies fail
|
|
319
|
+
expect(comprehensiveVSCodeTheme).toBeDefined();
|
|
320
|
+
expect(cleanEditorTheme).toBeDefined();
|
|
321
|
+
expect(createRobustExtensions).toBeDefined();
|
|
322
|
+
});
|
|
323
|
+
|
|
324
|
+
it('handles extension creation edge cases', () => {
|
|
325
|
+
// Should work even with rapid successive calls
|
|
326
|
+
const results = [];
|
|
327
|
+
|
|
328
|
+
for (let i = 0; i < 5; i++) {
|
|
329
|
+
results.push(createRobustExtensions());
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
results.forEach(extensions => {
|
|
333
|
+
expect(Array.isArray(extensions)).toBe(true);
|
|
334
|
+
expect(extensions.length).toBe(3);
|
|
335
|
+
});
|
|
336
|
+
});
|
|
337
|
+
|
|
338
|
+
it('maintains stability across different usage patterns', () => {
|
|
339
|
+
// Mixed usage patterns
|
|
340
|
+
const theme = comprehensiveVSCodeTheme;
|
|
341
|
+
const editorTheme = cleanEditorTheme;
|
|
342
|
+
const extensions1 = createRobustExtensions();
|
|
343
|
+
const extensions2 = createRobustExtensions();
|
|
344
|
+
|
|
345
|
+
expect(theme).toBeTruthy();
|
|
346
|
+
expect(editorTheme).toBeTruthy();
|
|
347
|
+
expect(extensions1).toBeTruthy();
|
|
348
|
+
expect(extensions2).toBeTruthy();
|
|
349
|
+
|
|
350
|
+
// Should maintain consistency
|
|
351
|
+
expect(extensions1[2]).toBe(extensions2[2]);
|
|
352
|
+
});
|
|
353
|
+
|
|
354
|
+
it('handles concurrent access', () => {
|
|
355
|
+
// Simulate concurrent access
|
|
356
|
+
const promises = [];
|
|
357
|
+
|
|
358
|
+
for (let i = 0; i < 10; i++) {
|
|
359
|
+
promises.push(Promise.resolve(createRobustExtensions()));
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
return Promise.all(promises).then(results => {
|
|
363
|
+
results.forEach(extensions => {
|
|
364
|
+
expect(extensions.length).toBe(3);
|
|
365
|
+
});
|
|
366
|
+
});
|
|
367
|
+
});
|
|
368
|
+
});
|
|
369
|
+
|
|
370
|
+
describe('API Consistency', () => {
|
|
371
|
+
it('provides stable API interface', () => {
|
|
372
|
+
// Named exports
|
|
373
|
+
expect(typeof comprehensiveVSCodeTheme).toBe('object');
|
|
374
|
+
expect(typeof cleanEditorTheme).toBe('object');
|
|
375
|
+
expect(typeof createRobustExtensions).toBe('function');
|
|
376
|
+
|
|
377
|
+
// Default export
|
|
378
|
+
const defaultExport = require('../properSyntaxHighlighting').default;
|
|
379
|
+
expect(typeof defaultExport).toBe('object');
|
|
380
|
+
expect(typeof defaultExport.createRobustExtensions).toBe('function');
|
|
381
|
+
});
|
|
382
|
+
|
|
383
|
+
it('maintains backward compatibility', () => {
|
|
384
|
+
// Should support both import styles
|
|
385
|
+
const namedImports = {
|
|
386
|
+
comprehensiveVSCodeTheme,
|
|
387
|
+
cleanEditorTheme,
|
|
388
|
+
createRobustExtensions
|
|
389
|
+
};
|
|
390
|
+
|
|
391
|
+
const defaultImport = require('../properSyntaxHighlighting').default;
|
|
392
|
+
|
|
393
|
+
expect(namedImports.comprehensiveVSCodeTheme).toBe(defaultImport.comprehensiveVSCodeTheme);
|
|
394
|
+
expect(namedImports.cleanEditorTheme).toBe(defaultImport.cleanEditorTheme);
|
|
395
|
+
expect(namedImports.createRobustExtensions).toBe(defaultImport.createRobustExtensions);
|
|
396
|
+
});
|
|
397
|
+
|
|
398
|
+
it('provides complete functionality', () => {
|
|
399
|
+
// Should provide everything needed for CodeMirror setup
|
|
400
|
+
const extensions = createRobustExtensions();
|
|
401
|
+
|
|
402
|
+
expect(extensions.length).toBe(3);
|
|
403
|
+
expect(comprehensiveVSCodeTheme).toBeTruthy();
|
|
404
|
+
expect(cleanEditorTheme).toBeTruthy();
|
|
405
|
+
|
|
406
|
+
// Should be usable together
|
|
407
|
+
expect(() => {
|
|
408
|
+
const combined = [
|
|
409
|
+
...extensions,
|
|
410
|
+
comprehensiveVSCodeTheme,
|
|
411
|
+
cleanEditorTheme
|
|
412
|
+
];
|
|
413
|
+
expect(combined.length).toBeGreaterThan(3);
|
|
414
|
+
}).not.toThrow();
|
|
415
|
+
});
|
|
416
|
+
});
|
|
417
|
+
|
|
418
|
+
describe('Real-world Usage Scenarios', () => {
|
|
419
|
+
it('supports typical CodeMirror editor setup', () => {
|
|
420
|
+
// Typical usage pattern
|
|
421
|
+
const extensions = createRobustExtensions();
|
|
422
|
+
|
|
423
|
+
expect(extensions).toBeDefined();
|
|
424
|
+
expect(extensions.length).toBe(3);
|
|
425
|
+
|
|
426
|
+
// Should be able to use in editor configuration
|
|
427
|
+
const editorConfig = {
|
|
428
|
+
extensions: extensions,
|
|
429
|
+
theme: cleanEditorTheme
|
|
430
|
+
};
|
|
431
|
+
|
|
432
|
+
expect(editorConfig.extensions).toBe(extensions);
|
|
433
|
+
expect(editorConfig.theme).toBe(cleanEditorTheme);
|
|
434
|
+
});
|
|
435
|
+
|
|
436
|
+
it('supports theme customization scenarios', () => {
|
|
437
|
+
// Should be able to access both themes
|
|
438
|
+
const syntaxTheme = comprehensiveVSCodeTheme;
|
|
439
|
+
const editorTheme = cleanEditorTheme;
|
|
440
|
+
|
|
441
|
+
expect(syntaxTheme).toBeTruthy();
|
|
442
|
+
expect(editorTheme).toBeTruthy();
|
|
443
|
+
|
|
444
|
+
// Should be different objects
|
|
445
|
+
expect(syntaxTheme).not.toBe(editorTheme);
|
|
446
|
+
});
|
|
447
|
+
|
|
448
|
+
it('supports extension composition', () => {
|
|
449
|
+
const baseExtensions = createRobustExtensions();
|
|
450
|
+
|
|
451
|
+
// Should be able to add more extensions
|
|
452
|
+
const customExtensions = [
|
|
453
|
+
...baseExtensions,
|
|
454
|
+
// Could add more extensions here
|
|
455
|
+
];
|
|
456
|
+
|
|
457
|
+
expect(customExtensions.length).toBeGreaterThanOrEqual(3);
|
|
458
|
+
expect(customExtensions.slice(0, 3)).toEqual(baseExtensions);
|
|
459
|
+
});
|
|
460
|
+
|
|
461
|
+
it('supports multiple editor instances', () => {
|
|
462
|
+
// Should work for multiple editors
|
|
463
|
+
const editor1Extensions = createRobustExtensions();
|
|
464
|
+
const editor2Extensions = createRobustExtensions();
|
|
465
|
+
|
|
466
|
+
expect(editor1Extensions).toBeTruthy();
|
|
467
|
+
expect(editor2Extensions).toBeTruthy();
|
|
468
|
+
|
|
469
|
+
// Should have same structure
|
|
470
|
+
expect(editor1Extensions.length).toBe(editor2Extensions.length);
|
|
471
|
+
});
|
|
472
|
+
});
|
|
473
|
+
});
|