MarkdownToolbar: Bold: Add more tests

This commit is contained in:
Vishesh Handa
2020-08-14 21:21:08 +02:00
parent c6d5ebc0b2
commit 440ee96639
2 changed files with 22 additions and 0 deletions

View File

@ -110,6 +110,8 @@ TextEditingValue modifyCurrentWord(
var wordStartPos = text.lastIndexOf(' ', cursorPos == 0 ? 0 : cursorPos - 1);
if (wordStartPos == -1) {
wordStartPos = 0;
} else {
wordStartPos += 1;
}
var wordEndPos = text.indexOf(' ', cursorPos);

View File

@ -146,4 +146,24 @@ void main() {
char: '**',
);
});
test("Surrounds the middle word", () {
_testWord(
before: 'Hello Hydra Person',
beforeOffset: 8,
after: 'Hello **Hydra** Person',
afterOffset: 13,
char: '**',
);
});
test("Removes the middle word", () {
_testWord(
before: 'Hello **Hydra** Person',
beforeOffset: 9,
after: 'Hello Hydra Person',
afterOffset: 11,
char: '**',
);
});
}