Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 2e1533c

Browse files
committed
escaping backticks on formatting test-update
1 parent 46771de commit 2e1533c

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

test/editor/operations-test.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import {
2323
formatRange,
2424
} from "../../src/editor/operations";
2525
import { Formatting } from "../../src/components/views/rooms/MessageComposerFormatBar";
26+
import { longestBacktickSequence } from '../../src/editor/deserialize';
2627

2728
const SERIALIZED_NEWLINE = { "text": "\n", "type": "newline" };
2829

@@ -44,6 +45,23 @@ describe('editor/operations: formatting operations', () => {
4445
expect(model.serializeParts()).toEqual([{ "text": "hello _world_!", "type": "plain" }]);
4546
});
4647

48+
it('works for escaping backticks in between texts', () => {
49+
const renderer = createRenderer();
50+
const pc = createPartCreator();
51+
const model = new EditorModel([
52+
pc.plain("hello ` world!"),
53+
], pc, renderer);
54+
55+
const range = model.startRange(model.positionForOffset(0, false),
56+
model.positionForOffset(13, false)); // hello ` world
57+
58+
expect(range.parts[0].text.trim().includes("`")).toBeTruthy();
59+
expect(longestBacktickSequence(range.parts[0].text.trim())).toBe(1);
60+
expect(model.serializeParts()).toEqual([{ "text": "hello ` world!", "type": "plain" }]);
61+
toggleInlineFormat(range, "`".repeat(longestBacktickSequence(range.parts[0].text.trim()) + 1));
62+
expect(model.serializeParts()).toEqual([{ "text": "``hello ` world``!", "type": "plain" }]);
63+
});
64+
4765
it('works for parts of words', () => {
4866
const renderer = createRenderer();
4967
const pc = createPartCreator();

0 commit comments

Comments
 (0)