Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #662 from outline/issue-660
Updated parseTitle to remove escape characters
- Loading branch information
Showing
3 changed files
with
34 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* 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); | ||
}); |