|
| 1 | +import { describe, expect, it } from 'vitest'; |
| 2 | +import { createRolldownCompilerPlugin } from './compiler-plugin.js'; |
| 3 | + |
| 4 | +const pluginOptions = { |
| 5 | + tsconfig: 'tsconfig.spec.json', |
| 6 | + sourcemap: false, |
| 7 | + incremental: false, |
| 8 | +}; |
| 9 | + |
| 10 | +describe('createRolldownCompilerPlugin', () => { |
| 11 | + it('skips the dependency transform in test mode', () => { |
| 12 | + const plugin = createRolldownCompilerPlugin(pluginOptions, true, true); |
| 13 | + |
| 14 | + expect(plugin.load).toBeUndefined(); |
| 15 | + }); |
| 16 | + |
| 17 | + it('keeps the dependency transform outside test mode', () => { |
| 18 | + const plugin = createRolldownCompilerPlugin(pluginOptions, false, true); |
| 19 | + |
| 20 | + expect(plugin.load).toBeDefined(); |
| 21 | + }); |
| 22 | + |
| 23 | + it('closes the JavaScript transformer when the build ends', async () => { |
| 24 | + const plugin = createRolldownCompilerPlugin(pluginOptions, false, true); |
| 25 | + |
| 26 | + expect(plugin.buildEnd).toBeDefined(); |
| 27 | + await expect( |
| 28 | + (plugin.buildEnd as unknown as () => Promise<void>)(), |
| 29 | + ).resolves.toBeUndefined(); |
| 30 | + }); |
| 31 | + |
| 32 | + it('keeps the transformer open when closeTransformer is false', () => { |
| 33 | + const plugin = createRolldownCompilerPlugin(pluginOptions, false, false); |
| 34 | + |
| 35 | + expect(plugin.buildEnd).toBeUndefined(); |
| 36 | + }); |
| 37 | +}); |
0 commit comments