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

Commit

Permalink
added more test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
yaya-usman committed Apr 14, 2022
1 parent dc3ca11 commit b0ecfd3
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions test/editor/operations-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,37 @@ describe('editor/operations: formatting operations', () => {
formatRangeAsCode(range);
expect(model.serializeParts()).toEqual([{ "text": "````hell```o`w`o``rld````", "type": "plain" }]);
});

it('untoggles correctly if its already formatted', () => {
const renderer = createRenderer();
const pc = createPartCreator();
const model = new EditorModel([
pc.plain("```hello``world```"),
], pc, renderer);

const range = model.startRange(model.positionForOffset(0, false),
model.getPositionAtEnd()); // hello``world
expect(range.parts[0].text.includes("`")).toBeTruthy();
expect(longestBacktickSequence(range.parts[0].text)).toBe(3);
expect(model.serializeParts()).toEqual([{ "text": "```hello``world```", "type": "plain" }]);
formatRangeAsCode(range);
expect(model.serializeParts()).toEqual([{ "text": "hello``world", "type": "plain" }]);
});
it('untoggles correctly it contains varying length of backticks between text', () => {
const renderer = createRenderer();
const pc = createPartCreator();
const model = new EditorModel([
pc.plain("````hell```o`w`o``rld````"),
], pc, renderer);

const range = model.startRange(model.positionForOffset(0, false),
model.getPositionAtEnd()); // hell```o`w`o``rld
expect(range.parts[0].text.includes("`")).toBeTruthy();
expect(longestBacktickSequence(range.parts[0].text)).toBe(4);
expect(model.serializeParts()).toEqual([{ "text": "````hell```o`w`o``rld````", "type": "plain" }]);
formatRangeAsCode(range);
expect(model.serializeParts()).toEqual([{ "text": "hell```o`w`o``rld", "type": "plain" }]);
});
});

it('works for parts of words', () => {
Expand Down

0 comments on commit b0ecfd3

Please sign in to comment.