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/parseTitle.test.js
Tom Moor 0adb8814dd 💚
2018-06-03 22:25:40 -04:00

29 lines
958 B
JavaScript

/* eslint-disable flowtype/require-valid-file-annotation */
import parseTitle from './parseTitle';
it('should trim the title', () => {
expect(parseTitle(`# Lots of space `).title).toBe('Lots of space');
});
it('should extract first title', () => {
expect(parseTitle(`# Title one\n# Title two`).title).toBe('Title one');
});
it('should remove escape characters', () => {
expect(parseTitle(`# Thing \\- one`).title).toBe('Thing - one');
expect(parseTitle(`# \\[wip\\] Title`).title).toBe('[wip] Title');
expect(parseTitle(`# \\> Title`).title).toBe('> Title');
});
it('should parse emoji if first character', () => {
const parsed = parseTitle(`# 😀 Title`);
expect(parsed.title).toBe('😀 Title');
expect(parsed.emoji).toBe('😀');
});
it('should not parse emoji if not first character', () => {
const parsed = parseTitle(`# Title 🌈`);
expect(parsed.title).toBe('Title 🌈');
expect(parsed.emoji).toBe(undefined);
});