chore: Move to Typescript (#2783)
This PR moves the entire project to Typescript. Due to the ~1000 ignores this will lead to a messy codebase for a while, but the churn is worth it – all of those ignore comments are places that were never type-safe previously. closes #1282
This commit is contained in:
23
shared/utils/parseTitle.test.ts
Normal file
23
shared/utils/parseTitle.test.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
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);
|
||||
});
|
||||
Reference in New Issue
Block a user