markdown-it-import/tests/recursion.test.ts

18 lines
674 B
TypeScript
Raw Permalink Normal View History

2023-11-16 14:13:19 +00:00
import { describe, expect, test } from 'bun:test'
import { render } from './utils.ts'
describe('base', () => {
test('should not be able to import itself', async () => {
expect(() => render('self-reference.md')).toThrow(/cycles are not allowed, already parsed.*self-reference\.md/)
})
test('should not be able to import cycles', async () => {
expect(() => render('cycle-a.md')).toThrow(/cycles are not allowed, already parsed.*cycle-b\.md/)
expect(() => render('cycle-b.md')).toThrow(/cycles are not allowed, already parsed.*cycle-a\.md/)
})
test('import different files', async () => {
expect(await render('rec-a.md')).toMatchSnapshot()
})
})