diff --git a/src/module.ts b/src/module.ts index 01c912894..4592db07d 100644 --- a/src/module.ts +++ b/src/module.ts @@ -396,7 +396,7 @@ export default defineNuxtModule({ enforce: 'pre', transform (code) { if (code.includes('ContentSlot')) { - code = code.replace(/]*)(:use=['"](\$slots.)?([a-zA-Z0-9_-]*)['"])/g, '/g, '') code = code.replace(/ { + const transform = (code: string) => { + if (code.includes('ContentSlot')) { + code = code.replace(/]*)(:use=['"](\$slots.)?([a-zA-Z0-9_-]*)['"])/g, '/g, '') + code = code.replace(/ { + expect(transform('')?.code).toBe('') + expect(transform('')?.code).toBe('') + expect(transform('')?.code).toBe('') + expect(transform('')?.code).toBe('') + + expect(transform('')?.code).toBe('') + expect(transform('')?.code).toBe('') + expect(transform('')?.code).toBe('') + + expect(transform('')?.code).toBe('') + expect(transform('')?.code).toBe('') + expect(transform('')?.code).toBe('') + expect(transform('')?.code).toBe('') + + expect(transform('')?.code).toBe('') + expect(transform('')?.code).toBe('') + expect(transform('')?.code).toBe('') + }) + + test('With Slot', () => { + expect(transform('')?.code).toBe('') + expect(transform('')?.code).toBe('') + expect(transform('')?.code).toBe('') + expect(transform('')?.code).toBe('') + + expect(transform('')?.code).toBe('') + expect(transform('')?.code).toBe('') + expect(transform('')?.code).toBe('') + + const slotContent = '\n
Foo
\n' + expect(transform(`${slotContent}
`)?.code).toBe(`${slotContent}
`) + expect(transform(`${slotContent}
`)?.code).toBe(`${slotContent}
`) + expect(transform(`${slotContent}
`)?.code).toBe(`${slotContent}
`) + expect(transform(`${slotContent}
`)?.code).toBe(`${slotContent}
`) + + expect(transform(`${slotContent}
`)?.code).toBe(`${slotContent}
`) + expect(transform(`${slotContent}
`)?.code).toBe(`${slotContent}
`) + expect(transform(`${slotContent}
`)?.code).toBe(`${slotContent}`) + }) +})