This repository has been archived on 2022-08-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
outline/shared/utils/getHeadingsForText.test.js
2020-04-06 09:01:03 -07:00

24 lines
643 B
JavaScript

/* eslint-disable flowtype/require-valid-file-annotation */
import getHeadingsForText from './getHeadingsForText';
it('should return an array of document headings', () => {
const response = getHeadingsForText(`
# Header
## Subheading
`);
expect(response.length).toBe(2);
expect(response[0].level).toBe(1);
expect(response[0].title).toBe('Header');
expect(response[1].level).toBe(2);
expect(response[1].title).toBe('Subheading');
});
it('should unescape special characters', () => {
const response = getHeadingsForText(`# Header <\\>`);
expect(response.length).toBe(1);
expect(response[0].title).toBe('Header <>');
});