var testPackage = require('../../helpers/test-package'); var Dgeni = require('dgeni'); const plugin = require('./autolink-headings'); describe('autolink-headings postprocessor', () => { let processor; beforeEach(() => { const dgeni = new Dgeni([testPackage('angular-base-package')]); const injector = dgeni.configureInjector(); processor = injector.get('postProcessHtml'); processor.docTypes = ['a']; processor.plugins = [plugin]; }); it('should add anchors to headings', () => { const originalContent = `

Heading 1

Heading with bold

Heading with encoded chars &

`; const processedContent = `

Heading 1

Heading with bold

Heading with encoded chars &

`; const docs = [{docType: 'a', renderedContent: originalContent}]; processor.$process(docs); expect(docs[0].renderedContent).toBe(processedContent); }); it('should ignore headings with the `no-anchor` class', () => { const originalContent = `

Heading 1

Heading with bold

Heading with encoded chars &

`; const processedContent = `

Heading 1

Heading with bold

Heading with encoded chars &

`; const docs = [{docType: 'a', renderedContent: originalContent}]; processor.$process(docs); expect(docs[0].renderedContent).toBe(processedContent); }); });