-
-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for plus sign as a list marker
- Loading branch information
Showing
3 changed files
with
85 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import { ListUtils } from "../list_utils"; | ||
|
||
interface EditorMockParams { | ||
text: string; | ||
cursor: { line: number; ch: number }; | ||
} | ||
|
||
function makeEditor(params: EditorMockParams) { | ||
let text = params.text; | ||
let cursor = { ...params.cursor }; | ||
|
||
const editor = { | ||
getCursor: () => cursor, | ||
getLine: (l: number) => text.split("\n")[l], | ||
lastLine: () => text.split("\n").length - 1, | ||
lineCount: () => text.split("\n").length, | ||
isFolded: (l: number) => false, | ||
}; | ||
|
||
return editor; | ||
} | ||
|
||
function makeListUtils() { | ||
const logger: any = { | ||
bind: jest.fn().mockReturnValue(jest.fn()), | ||
}; | ||
const obsidianUtils: any = { | ||
getObsidianTabsSettigns: jest | ||
.fn() | ||
.mockReturnValue({ useTab: true, tabSize: 4 }), | ||
}; | ||
|
||
const listUtils = new ListUtils(logger, obsidianUtils); | ||
|
||
return listUtils; | ||
} | ||
|
||
test("parse list with dash bullet", () => { | ||
const listUtils = makeListUtils(); | ||
const editor = makeEditor({ | ||
text: "- qwe", | ||
cursor: { line: 0, ch: 0 }, | ||
}); | ||
|
||
const list = listUtils.parseList(editor as any); | ||
|
||
expect(list).toBeDefined(); | ||
expect(list.print()).toBe(`- qwe`); | ||
}); | ||
|
||
test("parse list with asterisk bullet", () => { | ||
const listUtils = makeListUtils(); | ||
const editor = makeEditor({ | ||
text: "* qwe", | ||
cursor: { line: 0, ch: 0 }, | ||
}); | ||
|
||
const list = listUtils.parseList(editor as any); | ||
|
||
expect(list).toBeDefined(); | ||
expect(list.print()).toBe(`* qwe`); | ||
}); | ||
|
||
test("parse list with plus bullet", () => { | ||
const listUtils = makeListUtils(); | ||
const editor = makeEditor({ | ||
text: "+ qwe", | ||
cursor: { line: 0, ch: 0 }, | ||
}); | ||
|
||
const list = listUtils.parseList(editor as any); | ||
|
||
expect(list).toBeDefined(); | ||
expect(list.print()).toBe(`+ qwe`); | ||
}); |
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