|
1 |
| -const { expect } = require('expect'); |
2 |
| - |
3 |
| -describe('prefix-share-filter', () => { |
4 |
| - let warnings; |
5 |
| - let oldWarn; |
6 |
| - |
7 |
| - beforeEach(() => { |
8 |
| - warnings = []; |
9 |
| - oldWarn = console.warn; |
10 |
| - console.warn = (warning) => { |
11 |
| - warnings.push(warning); |
12 |
| - }; |
13 |
| - }); |
14 |
| - |
15 |
| - afterEach(() => { |
16 |
| - console.warn = oldWarn; |
17 |
| - }); |
18 |
| - |
19 |
| - it('should share modules matching the filter pattern', async () => { |
20 |
| - const moduleA = await import('prefix/deep/module-a'); |
21 |
| - expect(moduleA.default).toBe('module-a'); |
22 |
| - |
23 |
| - // This should be shared due to filter pattern |
24 |
| - const container = __webpack_require__.S['default']; |
25 |
| - expect(container).toBeDefined(); |
26 |
| - expect(container['prefix/deep/module-a']).toBeDefined(); |
27 |
| - }); |
| 1 | +let warnings; |
| 2 | +let oldWarn; |
| 3 | + |
| 4 | +beforeEach(() => { |
| 5 | + warnings = []; |
| 6 | + oldWarn = console.warn; |
| 7 | + console.warn = (warning) => { |
| 8 | + warnings.push(warning); |
| 9 | + }; |
| 10 | +}); |
28 | 11 |
|
29 |
| - it('should not share modules not matching the filter pattern', async () => { |
30 |
| - const moduleB = await import('prefix/shallow-module'); |
31 |
| - expect(moduleB.default).toBe('shallow-module'); |
| 12 | +afterEach(() => { |
| 13 | + console.warn = oldWarn; |
| 14 | +}); |
32 | 15 |
|
33 |
| - // This should not be shared due to filter pattern |
34 |
| - const container = __webpack_require__.S['default']; |
35 |
| - expect(container['prefix/shallow-module']).toBeUndefined(); |
36 |
| - }); |
| 16 | +it('should share modules NOT matching the filter', async () => { |
| 17 | + const moduleA = await import('prefix/a'); |
| 18 | + expect(moduleA.default).toBe('a'); |
37 | 19 |
|
38 |
| - it('should properly handle nested deep modules', async () => { |
39 |
| - const moduleC = await import('prefix/deep/nested/module-c'); |
40 |
| - expect(moduleC.default).toBe('module-c'); |
| 20 | + // This should not be shared due to filter pattern |
| 21 | + const container = __webpack_share_scopes__['test-scope']; |
| 22 | + console.log(container); |
41 | 23 |
|
42 |
| - const container = __webpack_require__.S['default']; |
43 |
| - expect(container['prefix/deep/nested/module-c']).toBeDefined(); |
44 |
| - }); |
| 24 | + expect(container).toBeDefined(); |
| 25 | + expect(container['prefix/a']).toBeDefined(); |
| 26 | +}); |
45 | 27 |
|
46 |
| - it('should maintain module integrity when sharing', async () => { |
47 |
| - const moduleA1 = await import('prefix/deep/module-a'); |
48 |
| - const moduleA2 = await import('prefix/deep/module-a'); |
| 28 | +it('should not share modules in deep directory', async () => { |
| 29 | + const moduleB = await import('prefix/deep/b'); |
| 30 | + expect(moduleB.default).toBe('b'); |
49 | 31 |
|
50 |
| - // Should be the same instance due to sharing |
51 |
| - expect(moduleA1).toBe(moduleA2); |
52 |
| - }); |
| 32 | + // This should not be shared due to filter pattern |
| 33 | + const container = __webpack_require__.S['test-scope']; |
| 34 | + expect(container['prefix/deep/b']).toBeUndefined(); |
53 | 35 | });
|
0 commit comments