Skip to content

Commit 95d0e12

Browse files
Merge branch 'pr8-unified-api' into pr9-implementation
2 parents 1155b70 + 8e354d2 commit 95d0e12

File tree

6 files changed

+46
-42
lines changed

6 files changed

+46
-42
lines changed

packages/enhanced/jest.config.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ export default {
3636
testMatch: [
3737
'<rootDir>/test/*.basictest.js',
3838
'<rootDir>/test/unit/**/*.test.ts',
39-
'<rootDir>/test/compiler-unit/**/*.test.ts',
4039
],
4140
silent: true,
4241
verbose: false,

packages/enhanced/test/unit/container/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ export function createWebpackMock() {
421421
} else if (typeof str === 'string') {
422422
return ` ${str}`;
423423
} else {
424-
console.log('Template.indent received:', str);
424+
// Unexpected type for indentation, return as-is
425425
return str;
426426
}
427427
}),

packages/enhanced/test/unit/sharing/ConsumeSharedModule.test.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -490,10 +490,9 @@ describe('ConsumeSharedModule', () => {
490490

491491
// We can't directly test the serialization in a fully functional way without proper webpack setup
492492
// Just verify the serialize method exists and can be called
493+
expect(typeof module.serialize).toBe('function');
493494
expect(() => {
494-
if (typeof module.serialize === 'function') {
495-
module.serialize(context as any);
496-
}
495+
module.serialize(context as any);
497496
}).not.toThrow();
498497
});
499498

@@ -514,10 +513,9 @@ describe('ConsumeSharedModule', () => {
514513
);
515514

516515
// Just verify the serialize method exists and can be called
516+
expect(typeof module.serialize).toBe('function');
517517
expect(() => {
518-
if (typeof module.serialize === 'function') {
519-
module.serialize(context as any);
520-
}
518+
module.serialize(context as any);
521519
}).not.toThrow();
522520
});
523521
});

packages/enhanced/test/unit/sharing/ConsumeSharedRuntimeModule.test.ts

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,13 @@ describe('ConsumeSharedRuntimeModule', () => {
126126
// Call generate and verify it doesn't throw
127127
// Note: We're not verifying the exact output because it depends on complex internal state
128128
// that's difficult to mock completely, but we can verify it runs without errors
129+
let result;
129130
expect(() => {
130-
const result = module.generate();
131-
// The result might be null or a string
132-
expect(result === null || typeof result === 'string').toBeTruthy();
131+
result = module.generate();
133132
}).not.toThrow();
133+
134+
// The result might be null or a string
135+
expect(result === null || typeof result === 'string').toBeTruthy();
134136
});
135137

136138
it('should generate code with array shareScope', () => {
@@ -152,11 +154,13 @@ describe('ConsumeSharedRuntimeModule', () => {
152154
module.chunkGraph = mockCompilation.chunkGraph as any;
153155

154156
// Call generate and verify it doesn't throw
157+
let result;
155158
expect(() => {
156-
const result = module.generate();
157-
// The result might be null or a string
158-
expect(result === null || typeof result === 'string').toBeTruthy();
159+
result = module.generate();
159160
}).not.toThrow();
161+
162+
// The result might be null or a string
163+
expect(result === null || typeof result === 'string').toBeTruthy();
160164
});
161165

162166
// For the tests with modules, we'll simplify and just verify that the method
@@ -192,11 +196,13 @@ describe('ConsumeSharedRuntimeModule', () => {
192196
module.chunkGraph = mockCompilation.chunkGraph as any;
193197

194198
// Call generate and verify it doesn't throw
199+
let result;
195200
expect(() => {
196-
const result = module.generate();
197-
// The result might be null or a string
198-
expect(result === null || typeof result === 'string').toBeTruthy();
201+
result = module.generate();
199202
}).not.toThrow();
203+
204+
// The result might be null or a string
205+
expect(result === null || typeof result === 'string').toBeTruthy();
200206
});
201207

202208
it('should generate code with modules and array shareScope', () => {
@@ -230,11 +236,13 @@ describe('ConsumeSharedRuntimeModule', () => {
230236
module.chunkGraph = mockCompilation.chunkGraph as any;
231237

232238
// Call generate and verify it doesn't throw
239+
let result;
233240
expect(() => {
234-
const result = module.generate();
235-
// The result might be null or a string
236-
expect(result === null || typeof result === 'string').toBeTruthy();
241+
result = module.generate();
237242
}).not.toThrow();
243+
244+
// The result might be null or a string
245+
expect(result === null || typeof result === 'string').toBeTruthy();
238246
});
239247

240248
it('should handle initialConsumes correctly', () => {
@@ -268,11 +276,13 @@ describe('ConsumeSharedRuntimeModule', () => {
268276
module.chunkGraph = mockCompilation.chunkGraph as any;
269277

270278
// Call generate and verify it doesn't throw
279+
let result;
271280
expect(() => {
272-
const result = module.generate();
273-
// The result might be null or a string
274-
expect(result === null || typeof result === 'string').toBeTruthy();
281+
result = module.generate();
275282
}).not.toThrow();
283+
284+
// The result might be null or a string
285+
expect(result === null || typeof result === 'string').toBeTruthy();
276286
});
277287

278288
it('should handle multiple share scopes in a module', () => {
@@ -306,11 +316,13 @@ describe('ConsumeSharedRuntimeModule', () => {
306316
module.chunkGraph = mockCompilation.chunkGraph as any;
307317

308318
// Call generate and verify it doesn't throw
319+
let result;
309320
expect(() => {
310-
const result = module.generate();
311-
// The result might be null or a string
312-
expect(result === null || typeof result === 'string').toBeTruthy();
321+
result = module.generate();
313322
}).not.toThrow();
323+
324+
// The result might be null or a string
325+
expect(result === null || typeof result === 'string').toBeTruthy();
314326
});
315327
});
316328
});

packages/enhanced/test/unit/sharing/ProvideSharedModule.test.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -395,10 +395,9 @@ describe('ProvideSharedModule', () => {
395395
};
396396

397397
// Just verify the serialize method can be called without error
398+
expect(typeof module.serialize).toBe('function');
398399
expect(() => {
399-
if (typeof module.serialize === 'function') {
400-
module.serialize(context);
401-
}
400+
module.serialize(context);
402401
}).not.toThrow();
403402
});
404403

@@ -432,10 +431,9 @@ describe('ProvideSharedModule', () => {
432431
};
433432

434433
// Just verify the serialize method can be called without error
434+
expect(typeof module.serialize).toBe('function');
435435
expect(() => {
436-
if (typeof module.serialize === 'function') {
437-
module.serialize(context);
438-
}
436+
module.serialize(context);
439437
}).not.toThrow();
440438
});
441439

@@ -470,10 +468,9 @@ describe('ProvideSharedModule', () => {
470468
};
471469

472470
// Just verify the serialize method can be called without error
471+
expect(typeof module.serialize).toBe('function');
473472
expect(() => {
474-
if (typeof module.serialize === 'function') {
475-
module.serialize(context);
476-
}
473+
module.serialize(context);
477474
}).not.toThrow();
478475
});
479476
});

packages/enhanced/test/unit/sharing/ProvideSharedPlugin.test.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ describe('ProvideSharedPlugin', () => {
477477
(err, result) => {
478478
// Handle callback with proper implementation
479479
if (err) {
480-
console.error('Error in addInclude:', err);
480+
throw err; // Re-throw error for proper test failure
481481
}
482482
},
483483
);
@@ -995,10 +995,9 @@ describe('ProvideSharedPlugin', () => {
995995
};
996996

997997
// Should handle gracefully without throwing
998+
expect(mockNormalModuleFactory.moduleCallback).toBeDefined();
998999
expect(() => {
999-
if (mockNormalModuleFactory.moduleCallback) {
1000-
mockNormalModuleFactory.moduleCallback({}, moduleData, resolveData);
1001-
}
1000+
mockNormalModuleFactory.moduleCallback({}, moduleData, resolveData);
10021001
}).not.toThrow();
10031002
});
10041003

@@ -1056,10 +1055,9 @@ describe('ProvideSharedPlugin', () => {
10561055
};
10571056

10581057
// Should handle missing resource gracefully
1058+
expect(mockNormalModuleFactory.moduleCallback).toBeDefined();
10591059
expect(() => {
1060-
if (mockNormalModuleFactory.moduleCallback) {
1061-
mockNormalModuleFactory.moduleCallback({}, moduleData, resolveData);
1062-
}
1060+
mockNormalModuleFactory.moduleCallback({}, moduleData, resolveData);
10631061
}).not.toThrow();
10641062
});
10651063
});

0 commit comments

Comments
 (0)