Skip to content

Commit 543117c

Browse files
committed
Add preload
1 parent c23f215 commit 543117c

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

packages/next-plugin/src/__tests__/preload.test.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,4 +307,31 @@ describe('preload', () => {
307307
true,
308308
)
309309
})
310+
311+
it('should return early when nested is true and include packages exist', () => {
312+
vi.mocked(findTopPackageRoot).mockReturnValue('/repo')
313+
vi.mocked(hasLocalPackage).mockReturnValue(true)
314+
// Return empty array so no recursive calls happen, but include.length > 0 check passes
315+
vi.mocked(globSync).mockReturnValue([])
316+
vi.mocked(getPackageName).mockReturnValue('pkg-a')
317+
318+
// Call with nested = true (7th parameter)
319+
preload(
320+
/node_modules/,
321+
'@devup-ui/react',
322+
false,
323+
'/output/css',
324+
['pkg-a'],
325+
'/some/path',
326+
true,
327+
)
328+
329+
// When nested is true, it should return early after processing includes
330+
// and not write the final devup-ui.css file
331+
expect(writeFileSync).not.toHaveBeenCalledWith(
332+
expect.stringContaining('devup-ui.css'),
333+
expect.any(String),
334+
'utf-8',
335+
)
336+
})
310337
})

0 commit comments

Comments
 (0)