@useavalon/avalon 0.1.5 → 0.1.6
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/package.json +31 -58
- package/src/build/README.md +0 -310
- package/src/client/tests/css-hmr-handler.test.ts +0 -360
- package/src/client/tests/framework-adapter.test.ts +0 -519
- package/src/client/tests/hmr-coordinator.test.ts +0 -176
- package/src/client/tests/hydration-option-parsing.test.ts +0 -107
- package/src/client/tests/lit-adapter.test.ts +0 -427
- package/src/client/tests/preact-adapter.test.ts +0 -353
- package/src/client/tests/qwik-adapter.test.ts +0 -343
- package/src/client/tests/react-adapter.test.ts +0 -317
- package/src/client/tests/solid-adapter.test.ts +0 -396
- package/src/client/tests/svelte-adapter.test.ts +0 -387
- package/src/client/tests/vue-adapter.test.ts +0 -407
- package/src/components/tests/component-analyzer.test.ts +0 -96
- package/src/components/tests/component-detection.test.ts +0 -347
- package/src/components/tests/persistent-islands.test.ts +0 -398
- package/src/core/components/tests/enhanced-framework-detector.test.ts +0 -577
- package/src/core/components/tests/framework-registry.test.ts +0 -465
- package/src/core/integrations/README.md +0 -282
- package/src/core/layout/tests/enhanced-layout-resolver.test.ts +0 -477
- package/src/core/layout/tests/layout-cache-optimization.test.ts +0 -149
- package/src/core/layout/tests/layout-composer.test.ts +0 -486
- package/src/core/layout/tests/layout-data-loader.test.ts +0 -443
- package/src/core/layout/tests/layout-discovery.test.ts +0 -253
- package/src/core/layout/tests/layout-matcher.test.ts +0 -480
- package/src/core/modules/tests/framework-module-resolver.test.ts +0 -263
- package/src/core/modules/tests/module-resolution-integration.test.ts +0 -117
- package/src/islands/discovery/tests/island-discovery.test.ts +0 -881
- package/src/middleware/__tests__/discovery.test.ts +0 -107
- package/src/types/tests/layout-types.test.ts +0 -197
- package/src/vite-plugin/tests/image-optimization.test.ts +0 -54
|
@@ -1,465 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Framework Registry Tests
|
|
3
|
-
*
|
|
4
|
-
* Test suite for the framework registry and configuration system,
|
|
5
|
-
* including validation, management, and configuration operations.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { describe, it, expect } from 'vitest';
|
|
9
|
-
import { FrameworkRegistry, createFrameworkConfig, defaultFrameworkRegistry } from '../framework-registry.ts';
|
|
10
|
-
import type { FrameworkConfig } from '../enhanced-framework-detector.ts';
|
|
11
|
-
|
|
12
|
-
describe('FrameworkRegistry - Basic Operations', () => {
|
|
13
|
-
it('should initialize with default frameworks', () => {
|
|
14
|
-
const registry = new FrameworkRegistry();
|
|
15
|
-
const frameworks = registry.getAllFrameworks();
|
|
16
|
-
|
|
17
|
-
expect(frameworks.has('preact')).toBeTruthy();
|
|
18
|
-
expect(frameworks.has('solid')).toBeTruthy();
|
|
19
|
-
expect(frameworks.has('vue')).toBeTruthy();
|
|
20
|
-
expect(frameworks.has('svelte')).toBeTruthy();
|
|
21
|
-
expect(frameworks.has('react')).toBeTruthy();
|
|
22
|
-
expect(frameworks.has('lit')).toBeTruthy();
|
|
23
|
-
expect(frameworks.has('qwik')).toBeTruthy();
|
|
24
|
-
expect(frameworks.size).toEqual(7);
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
it('should get framework by name', () => {
|
|
28
|
-
const registry = new FrameworkRegistry();
|
|
29
|
-
const preactConfig = registry.getFramework('preact');
|
|
30
|
-
|
|
31
|
-
expect(preactConfig).toBeDefined();
|
|
32
|
-
expect(preactConfig!.name).toEqual('preact');
|
|
33
|
-
expect(preactConfig!.fileExtensions.includes('.tsx')).toBeTruthy();
|
|
34
|
-
expect(preactConfig!.jsxImportSources.includes('preact')).toBeTruthy();
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
it('should return undefined for non-existent framework', () => {
|
|
38
|
-
const registry = new FrameworkRegistry();
|
|
39
|
-
const config = registry.getFramework('nonexistent');
|
|
40
|
-
|
|
41
|
-
expect(config).toEqual(undefined);
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
describe('FrameworkRegistry - Framework Registration', () => {
|
|
46
|
-
it('should register valid custom framework', () => {
|
|
47
|
-
const registry = new FrameworkRegistry();
|
|
48
|
-
const customConfig: FrameworkConfig = {
|
|
49
|
-
name: 'custom',
|
|
50
|
-
fileExtensions: ['.custom'],
|
|
51
|
-
jsxImportSources: ['custom-framework'],
|
|
52
|
-
ssrModules: ['custom-framework/server'],
|
|
53
|
-
hydrationModules: ['custom-framework/client'],
|
|
54
|
-
detectionPatterns: {
|
|
55
|
-
imports: [/^custom-framework$/],
|
|
56
|
-
content: [/\bcustomHook\b/],
|
|
57
|
-
jsxPragmas: ['@jsxImportSource custom-framework'],
|
|
58
|
-
},
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
const result = registry.registerFramework('custom', customConfig);
|
|
62
|
-
|
|
63
|
-
expect(result.isValid).toEqual(true);
|
|
64
|
-
expect(result.errors.length).toEqual(0);
|
|
65
|
-
|
|
66
|
-
const registered = registry.getFramework('custom');
|
|
67
|
-
expect(registered).toBeDefined();
|
|
68
|
-
expect(registered!.name).toEqual('custom');
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
it('should reject invalid framework configuration', () => {
|
|
72
|
-
const registry = new FrameworkRegistry();
|
|
73
|
-
const invalidConfig: FrameworkConfig = {
|
|
74
|
-
name: '',
|
|
75
|
-
fileExtensions: [],
|
|
76
|
-
jsxImportSources: [],
|
|
77
|
-
ssrModules: [],
|
|
78
|
-
hydrationModules: [],
|
|
79
|
-
detectionPatterns: {
|
|
80
|
-
imports: [],
|
|
81
|
-
content: [],
|
|
82
|
-
jsxPragmas: [],
|
|
83
|
-
},
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
const result = registry.registerFramework('invalid', invalidConfig);
|
|
87
|
-
|
|
88
|
-
expect(result.isValid).toEqual(false);
|
|
89
|
-
expect(result.errors.length > 0).toBeTruthy();
|
|
90
|
-
expect(result.errors.some(e => e.includes('name is required'))).toBeTruthy();
|
|
91
|
-
expect(result.errors.some(e => e.includes('file extension is required'))).toBeTruthy();
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
it('should prevent custom frameworks when disabled', () => {
|
|
95
|
-
const registry = new FrameworkRegistry({ allowCustomFrameworks: false });
|
|
96
|
-
const customConfig: FrameworkConfig = {
|
|
97
|
-
name: 'custom',
|
|
98
|
-
fileExtensions: ['.custom'],
|
|
99
|
-
jsxImportSources: ['custom-framework'],
|
|
100
|
-
ssrModules: ['custom-framework/server'],
|
|
101
|
-
hydrationModules: ['custom-framework/client'],
|
|
102
|
-
detectionPatterns: {
|
|
103
|
-
imports: [/^custom-framework$/],
|
|
104
|
-
content: [/\bcustomHook\b/],
|
|
105
|
-
jsxPragmas: ['@jsxImportSource custom-framework'],
|
|
106
|
-
},
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
const result = registry.registerFramework('custom', customConfig);
|
|
110
|
-
|
|
111
|
-
expect(result.isValid).toEqual(false);
|
|
112
|
-
expect(result.errors.some(e => e.includes('Custom framework'))).toBeTruthy();
|
|
113
|
-
});
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
describe('FrameworkRegistry - Framework Updates', () => {
|
|
117
|
-
it('should update existing framework', () => {
|
|
118
|
-
const registry = new FrameworkRegistry();
|
|
119
|
-
|
|
120
|
-
const result = registry.updateFramework('preact', {
|
|
121
|
-
fileExtensions: ['.tsx', '.jsx', '.preact'],
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
expect(result.isValid).toEqual(true);
|
|
125
|
-
|
|
126
|
-
const updated = registry.getFramework('preact');
|
|
127
|
-
expect(updated).toBeDefined();
|
|
128
|
-
expect(updated!.fileExtensions.includes('.preact')).toBeTruthy();
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
it('should reject update for non-existent framework', () => {
|
|
132
|
-
const registry = new FrameworkRegistry();
|
|
133
|
-
|
|
134
|
-
const result = registry.updateFramework('nonexistent', {
|
|
135
|
-
fileExtensions: ['.test'],
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
expect(result.isValid).toEqual(false);
|
|
139
|
-
expect(result.errors.some(e => e.includes('not found'))).toBeTruthy();
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
it('should validate updates', () => {
|
|
143
|
-
const registry = new FrameworkRegistry();
|
|
144
|
-
|
|
145
|
-
const result = registry.updateFramework('preact', {
|
|
146
|
-
fileExtensions: [], // Invalid - empty extensions
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
expect(result.isValid).toEqual(false);
|
|
150
|
-
expect(result.errors.some(e => e.includes('file extension is required'))).toBeTruthy();
|
|
151
|
-
});
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
describe('FrameworkRegistry - Framework Removal', () => {
|
|
155
|
-
it('should remove custom frameworks', () => {
|
|
156
|
-
const registry = new FrameworkRegistry();
|
|
157
|
-
|
|
158
|
-
// First register a custom framework
|
|
159
|
-
const customConfig: FrameworkConfig = {
|
|
160
|
-
name: 'custom',
|
|
161
|
-
fileExtensions: ['.custom'],
|
|
162
|
-
jsxImportSources: ['custom-framework'],
|
|
163
|
-
ssrModules: ['custom-framework/server'],
|
|
164
|
-
hydrationModules: ['custom-framework/client'],
|
|
165
|
-
detectionPatterns: {
|
|
166
|
-
imports: [/^custom-framework$/],
|
|
167
|
-
content: [/\bcustomHook\b/],
|
|
168
|
-
jsxPragmas: ['@jsxImportSource custom-framework'],
|
|
169
|
-
},
|
|
170
|
-
};
|
|
171
|
-
|
|
172
|
-
registry.registerFramework('custom', customConfig);
|
|
173
|
-
|
|
174
|
-
// Then remove it
|
|
175
|
-
const removed = registry.unregisterFramework('custom');
|
|
176
|
-
|
|
177
|
-
expect(removed).toEqual(true);
|
|
178
|
-
expect(registry.getFramework('custom')).toEqual(undefined);
|
|
179
|
-
});
|
|
180
|
-
|
|
181
|
-
it('should not remove default frameworks', () => {
|
|
182
|
-
const registry = new FrameworkRegistry();
|
|
183
|
-
|
|
184
|
-
const removed = registry.unregisterFramework('preact');
|
|
185
|
-
|
|
186
|
-
expect(removed).toEqual(false);
|
|
187
|
-
expect(registry.getFramework('preact')).toBeDefined();
|
|
188
|
-
});
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
describe('FrameworkRegistry - Validation', () => {
|
|
192
|
-
it('should validate framework configuration completeness', () => {
|
|
193
|
-
const registry = new FrameworkRegistry();
|
|
194
|
-
|
|
195
|
-
const validConfig: FrameworkConfig = {
|
|
196
|
-
name: 'test',
|
|
197
|
-
fileExtensions: ['.test'],
|
|
198
|
-
jsxImportSources: ['test-framework'],
|
|
199
|
-
ssrModules: ['test-framework/server'],
|
|
200
|
-
hydrationModules: ['test-framework/client'],
|
|
201
|
-
detectionPatterns: {
|
|
202
|
-
imports: [/^test-framework$/],
|
|
203
|
-
content: [/\btestHook\b/],
|
|
204
|
-
jsxPragmas: ['@jsxImportSource test-framework'],
|
|
205
|
-
},
|
|
206
|
-
};
|
|
207
|
-
|
|
208
|
-
const result = registry.validateFrameworkConfig(validConfig);
|
|
209
|
-
|
|
210
|
-
expect(result.isValid).toEqual(true);
|
|
211
|
-
expect(result.errors.length).toEqual(0);
|
|
212
|
-
});
|
|
213
|
-
|
|
214
|
-
it('should detect missing required fields', () => {
|
|
215
|
-
const registry = new FrameworkRegistry();
|
|
216
|
-
|
|
217
|
-
const incompleteConfig = {
|
|
218
|
-
name: 'test',
|
|
219
|
-
fileExtensions: ['.test'],
|
|
220
|
-
// Missing required fields
|
|
221
|
-
} as FrameworkConfig;
|
|
222
|
-
|
|
223
|
-
const result = registry.validateFrameworkConfig(incompleteConfig);
|
|
224
|
-
|
|
225
|
-
expect(result.isValid).toEqual(false);
|
|
226
|
-
expect(result.errors.length > 0).toBeTruthy();
|
|
227
|
-
});
|
|
228
|
-
|
|
229
|
-
it('should validate file extension format', () => {
|
|
230
|
-
const registry = new FrameworkRegistry();
|
|
231
|
-
|
|
232
|
-
const invalidConfig: FrameworkConfig = {
|
|
233
|
-
name: 'test',
|
|
234
|
-
fileExtensions: ['tsx', 'jsx'], // Missing dots
|
|
235
|
-
jsxImportSources: ['test-framework'],
|
|
236
|
-
ssrModules: ['test-framework/server'],
|
|
237
|
-
hydrationModules: ['test-framework/client'],
|
|
238
|
-
detectionPatterns: {
|
|
239
|
-
imports: [/^test-framework$/],
|
|
240
|
-
content: [/\btestHook\b/],
|
|
241
|
-
jsxPragmas: ['@jsxImportSource test-framework'],
|
|
242
|
-
},
|
|
243
|
-
};
|
|
244
|
-
|
|
245
|
-
const result = registry.validateFrameworkConfig(invalidConfig);
|
|
246
|
-
|
|
247
|
-
expect(result.isValid).toEqual(false);
|
|
248
|
-
expect(result.errors.some(e => e.includes('must start with a dot'))).toBeTruthy();
|
|
249
|
-
});
|
|
250
|
-
|
|
251
|
-
it('should warn about potential conflicts', () => {
|
|
252
|
-
const registry = new FrameworkRegistry();
|
|
253
|
-
|
|
254
|
-
// Register a framework that conflicts with existing ones
|
|
255
|
-
const conflictingConfig: FrameworkConfig = {
|
|
256
|
-
name: 'conflicting',
|
|
257
|
-
fileExtensions: ['.tsx'], // Conflicts with preact/solid
|
|
258
|
-
jsxImportSources: ['preact'], // Conflicts with preact
|
|
259
|
-
ssrModules: ['conflicting/server'],
|
|
260
|
-
hydrationModules: ['conflicting/client'],
|
|
261
|
-
detectionPatterns: {
|
|
262
|
-
imports: [/^conflicting$/],
|
|
263
|
-
content: [/\bconflictingHook\b/],
|
|
264
|
-
jsxPragmas: ['@jsxImportSource conflicting'],
|
|
265
|
-
},
|
|
266
|
-
};
|
|
267
|
-
|
|
268
|
-
const result = registry.validateFrameworkConfig(conflictingConfig);
|
|
269
|
-
|
|
270
|
-
// Should be valid but with warnings
|
|
271
|
-
expect(result.isValid).toEqual(true);
|
|
272
|
-
expect(result.warnings.length > 0).toBeTruthy();
|
|
273
|
-
expect(result.warnings.some(w => w.includes('overlap'))).toBeTruthy();
|
|
274
|
-
});
|
|
275
|
-
});
|
|
276
|
-
|
|
277
|
-
describe('FrameworkRegistry - Query Operations', () => {
|
|
278
|
-
it('should get frameworks by extension', () => {
|
|
279
|
-
const registry = new FrameworkRegistry();
|
|
280
|
-
|
|
281
|
-
const tsxFrameworks = registry.getFrameworksByExtension('.tsx');
|
|
282
|
-
|
|
283
|
-
expect(tsxFrameworks.includes('preact')).toBeTruthy();
|
|
284
|
-
expect(tsxFrameworks.includes('solid')).toBeTruthy();
|
|
285
|
-
expect(!tsxFrameworks.includes('vue')).toBeTruthy();
|
|
286
|
-
expect(!tsxFrameworks.includes('svelte')).toBeTruthy();
|
|
287
|
-
});
|
|
288
|
-
|
|
289
|
-
it('should get frameworks by JSX import source', () => {
|
|
290
|
-
const registry = new FrameworkRegistry();
|
|
291
|
-
|
|
292
|
-
const preactFrameworks = registry.getFrameworksByJSXImportSource('preact');
|
|
293
|
-
const solidFrameworks = registry.getFrameworksByJSXImportSource('solid-js');
|
|
294
|
-
|
|
295
|
-
expect(preactFrameworks).toEqual(['preact']);
|
|
296
|
-
expect(solidFrameworks).toEqual(['solid']);
|
|
297
|
-
});
|
|
298
|
-
|
|
299
|
-
it('should return empty array for unknown extension', () => {
|
|
300
|
-
const registry = new FrameworkRegistry();
|
|
301
|
-
|
|
302
|
-
const unknownFrameworks = registry.getFrameworksByExtension('.unknown');
|
|
303
|
-
|
|
304
|
-
expect(unknownFrameworks).toEqual([]);
|
|
305
|
-
});
|
|
306
|
-
});
|
|
307
|
-
|
|
308
|
-
describe('FrameworkRegistry - Configuration Management', () => {
|
|
309
|
-
it('should export configuration', () => {
|
|
310
|
-
const registry = new FrameworkRegistry();
|
|
311
|
-
|
|
312
|
-
const config = registry.exportConfig();
|
|
313
|
-
|
|
314
|
-
expect(config.preact).toBeDefined();
|
|
315
|
-
expect(config.solid).toBeDefined();
|
|
316
|
-
expect(config.vue).toBeDefined();
|
|
317
|
-
expect(config.svelte).toBeDefined();
|
|
318
|
-
expect(config.react).toBeDefined();
|
|
319
|
-
expect(config.lit).toBeDefined();
|
|
320
|
-
expect(config.qwik).toBeDefined();
|
|
321
|
-
expect(Object.keys(config).length).toEqual(7);
|
|
322
|
-
});
|
|
323
|
-
|
|
324
|
-
it('should import configuration', () => {
|
|
325
|
-
const registry = new FrameworkRegistry();
|
|
326
|
-
|
|
327
|
-
const customConfig = {
|
|
328
|
-
custom1: createFrameworkConfig('custom1', {
|
|
329
|
-
fileExtensions: ['.c1'],
|
|
330
|
-
ssrModules: ['custom1/server'],
|
|
331
|
-
hydrationModules: ['custom1/client'],
|
|
332
|
-
importPatterns: [/^custom1$/],
|
|
333
|
-
}),
|
|
334
|
-
custom2: createFrameworkConfig('custom2', {
|
|
335
|
-
fileExtensions: ['.c2'],
|
|
336
|
-
ssrModules: ['custom2/server'],
|
|
337
|
-
hydrationModules: ['custom2/client'],
|
|
338
|
-
importPatterns: [/^custom2$/],
|
|
339
|
-
}),
|
|
340
|
-
};
|
|
341
|
-
|
|
342
|
-
const results = registry.importConfig(customConfig);
|
|
343
|
-
|
|
344
|
-
expect(results.length).toEqual(2);
|
|
345
|
-
expect(results.every(r => r.isValid)).toBeTruthy();
|
|
346
|
-
|
|
347
|
-
expect(registry.getFramework('custom1')).toBeDefined();
|
|
348
|
-
expect(registry.getFramework('custom2')).toBeDefined();
|
|
349
|
-
});
|
|
350
|
-
|
|
351
|
-
it('should reset to defaults', () => {
|
|
352
|
-
const registry = new FrameworkRegistry();
|
|
353
|
-
|
|
354
|
-
// Add custom framework
|
|
355
|
-
const customConfig = createFrameworkConfig('custom', {
|
|
356
|
-
fileExtensions: ['.custom'],
|
|
357
|
-
ssrModules: ['custom/server'],
|
|
358
|
-
hydrationModules: ['custom/client'],
|
|
359
|
-
importPatterns: [/^custom$/],
|
|
360
|
-
});
|
|
361
|
-
|
|
362
|
-
registry.registerFramework('custom', customConfig);
|
|
363
|
-
expect(registry.getAllFrameworks().size).toEqual(8);
|
|
364
|
-
|
|
365
|
-
// Reset
|
|
366
|
-
registry.reset();
|
|
367
|
-
expect(registry.getAllFrameworks().size).toEqual(7);
|
|
368
|
-
expect(registry.getFramework('custom')).toEqual(undefined);
|
|
369
|
-
});
|
|
370
|
-
});
|
|
371
|
-
|
|
372
|
-
describe('FrameworkRegistry - Statistics', () => {
|
|
373
|
-
it('should provide accurate statistics', () => {
|
|
374
|
-
const registry = new FrameworkRegistry();
|
|
375
|
-
|
|
376
|
-
const stats = registry.getStats();
|
|
377
|
-
|
|
378
|
-
expect(stats.totalFrameworks).toEqual(7);
|
|
379
|
-
expect(stats.defaultFrameworks).toEqual(7);
|
|
380
|
-
expect(stats.customFrameworks).toEqual(0);
|
|
381
|
-
expect(stats.supportedExtensions.includes('.tsx')).toBeTruthy();
|
|
382
|
-
expect(stats.supportedExtensions.includes('.vue')).toBeTruthy();
|
|
383
|
-
expect(stats.supportedExtensions.includes('.svelte')).toBeTruthy();
|
|
384
|
-
});
|
|
385
|
-
|
|
386
|
-
it('should update statistics after adding custom frameworks', () => {
|
|
387
|
-
const registry = new FrameworkRegistry();
|
|
388
|
-
|
|
389
|
-
const customConfig = createFrameworkConfig('custom', {
|
|
390
|
-
fileExtensions: ['.custom'],
|
|
391
|
-
ssrModules: ['custom/server'],
|
|
392
|
-
hydrationModules: ['custom/client'],
|
|
393
|
-
importPatterns: [/^custom$/],
|
|
394
|
-
});
|
|
395
|
-
|
|
396
|
-
registry.registerFramework('custom', customConfig);
|
|
397
|
-
|
|
398
|
-
const stats = registry.getStats();
|
|
399
|
-
|
|
400
|
-
expect(stats.totalFrameworks).toEqual(8);
|
|
401
|
-
expect(stats.defaultFrameworks).toEqual(7);
|
|
402
|
-
expect(stats.customFrameworks).toEqual(1);
|
|
403
|
-
expect(stats.supportedExtensions.includes('.custom')).toBeTruthy();
|
|
404
|
-
});
|
|
405
|
-
});
|
|
406
|
-
|
|
407
|
-
describe('FrameworkRegistry - createFrameworkConfig Utility', () => {
|
|
408
|
-
it('should create valid framework configuration', () => {
|
|
409
|
-
const config = createFrameworkConfig('test', {
|
|
410
|
-
fileExtensions: ['.test'],
|
|
411
|
-
ssrModules: ['test/server'],
|
|
412
|
-
hydrationModules: ['test/client'],
|
|
413
|
-
importPatterns: [/^test$/, 'test-framework'],
|
|
414
|
-
contentPatterns: [/\btestHook\b/, 'testFunction'],
|
|
415
|
-
jsxPragmas: ['@jsxImportSource test'],
|
|
416
|
-
});
|
|
417
|
-
|
|
418
|
-
expect(config.name).toEqual('test');
|
|
419
|
-
expect(config.fileExtensions).toEqual(['.test']);
|
|
420
|
-
expect(config.ssrModules).toEqual(['test/server']);
|
|
421
|
-
expect(config.hydrationModules).toEqual(['test/client']);
|
|
422
|
-
expect(config.detectionPatterns.imports.length).toEqual(2);
|
|
423
|
-
expect(config.detectionPatterns.content.length).toEqual(2);
|
|
424
|
-
expect(config.detectionPatterns.jsxPragmas).toEqual(['@jsxImportSource test']);
|
|
425
|
-
});
|
|
426
|
-
|
|
427
|
-
it('should handle optional parameters', () => {
|
|
428
|
-
const config = createFrameworkConfig('minimal', {
|
|
429
|
-
fileExtensions: ['.min'],
|
|
430
|
-
ssrModules: ['minimal/server'],
|
|
431
|
-
hydrationModules: ['minimal/client'],
|
|
432
|
-
importPatterns: [/^minimal$/],
|
|
433
|
-
});
|
|
434
|
-
|
|
435
|
-
expect(config.jsxImportSources).toEqual([]);
|
|
436
|
-
expect(config.detectionPatterns.content).toEqual([]);
|
|
437
|
-
expect(config.detectionPatterns.jsxPragmas).toEqual([]);
|
|
438
|
-
});
|
|
439
|
-
});
|
|
440
|
-
|
|
441
|
-
describe('FrameworkRegistry - Default Registry Instance', () => {
|
|
442
|
-
it('should provide working default instance', () => {
|
|
443
|
-
const preactConfig = defaultFrameworkRegistry.getFramework('preact');
|
|
444
|
-
|
|
445
|
-
expect(preactConfig).toBeDefined();
|
|
446
|
-
expect(preactConfig!.name).toEqual('preact');
|
|
447
|
-
});
|
|
448
|
-
|
|
449
|
-
it('should allow modifications to default instance', () => {
|
|
450
|
-
const customConfig = createFrameworkConfig('test-default', {
|
|
451
|
-
fileExtensions: ['.test-default'],
|
|
452
|
-
ssrModules: ['test-default/server'],
|
|
453
|
-
hydrationModules: ['test-default/client'],
|
|
454
|
-
importPatterns: [/^test-default$/],
|
|
455
|
-
});
|
|
456
|
-
|
|
457
|
-
const result = defaultFrameworkRegistry.registerFramework('test-default', customConfig);
|
|
458
|
-
|
|
459
|
-
expect(result.isValid).toEqual(true);
|
|
460
|
-
expect(defaultFrameworkRegistry.getFramework('test-default')).toBeDefined();
|
|
461
|
-
|
|
462
|
-
// Clean up
|
|
463
|
-
defaultFrameworkRegistry.unregisterFramework('test-default');
|
|
464
|
-
});
|
|
465
|
-
});
|