Apply prettier formatting

This commit is contained in:
Michael Weimann 2022-12-12 12:24:14 +01:00
parent 1cac306093
commit 526645c791
No known key found for this signature in database
GPG key ID: 53F535A266BB9584
1576 changed files with 65385 additions and 62478 deletions

View file

@ -18,30 +18,30 @@ import HistoryManager, { MAX_STEP_LENGTH } from "../../src/editor/history";
import EditorModel from "../../src/editor/model";
import DocumentPosition from "../../src/editor/position";
describe('editor/history', function() {
it('push, then undo', function() {
describe("editor/history", function () {
it("push, then undo", function () {
const history = new HistoryManager();
const parts = ["hello"];
const model = { serializeParts: () => parts.slice() } as unknown as EditorModel;
const caret1 = new DocumentPosition(0, 0);
const result1 = history.tryPush(model, caret1, 'insertText', {});
const result1 = history.tryPush(model, caret1, "insertText", {});
expect(result1).toEqual(true);
parts[0] = "hello world";
history.tryPush(model, new DocumentPosition(0, 0), 'insertText', {});
history.tryPush(model, new DocumentPosition(0, 0), "insertText", {});
expect(history.canUndo()).toEqual(true);
const undoState = history.undo(model);
expect(undoState.caret).toBe(caret1);
expect(undoState.parts).toEqual(["hello"]);
expect(history.canUndo()).toEqual(false);
});
it('push, undo, then redo', function() {
it("push, undo, then redo", function () {
const history = new HistoryManager();
const parts = ["hello"];
const model = { serializeParts: () => parts.slice() } as unknown as EditorModel;
history.tryPush(model, new DocumentPosition(0, 0), 'insertText', {});
history.tryPush(model, new DocumentPosition(0, 0), "insertText", {});
parts[0] = "hello world";
const caret2 = new DocumentPosition(0, 0);
history.tryPush(model, caret2, 'insertText', {});
history.tryPush(model, caret2, "insertText", {});
history.undo(model);
expect(history.canRedo()).toEqual(true);
const redoState = history.redo();
@ -50,7 +50,7 @@ describe('editor/history', function() {
expect(history.canRedo()).toEqual(false);
expect(history.canUndo()).toEqual(true);
});
it('push, undo, push, ensure you can`t redo', function() {
it("push, undo, push, ensure you can`t redo", function () {
const history = new HistoryManager();
const parts = ["hello"];
const model = { serializeParts: () => parts.slice() } as unknown as EditorModel;
@ -62,7 +62,7 @@ describe('editor/history', function() {
history.tryPush(model, new DocumentPosition(0, 0), "insertText", {});
expect(history.canRedo()).toEqual(false);
});
it('not every keystroke stores a history step', function() {
it("not every keystroke stores a history step", function () {
const history = new HistoryManager();
const parts = ["hello"];
const model = { serializeParts: () => parts.slice() } as unknown as EditorModel;
@ -80,7 +80,7 @@ describe('editor/history', function() {
expect(history.canUndo()).toEqual(false);
expect(keystrokeCount).toEqual(MAX_STEP_LENGTH + 1); // +1 before we type before checking
});
it('history step is added at word boundary', function() {
it("history step is added at word boundary", function () {
const history = new HistoryManager();
const model = { serializeParts: () => parts.slice() } as unknown as EditorModel;
const parts = ["h"];
@ -108,7 +108,7 @@ describe('editor/history', function() {
expect(undoResult.caret).toEqual(spaceCaret);
expect(undoResult.parts).toEqual(["hi "]);
});
it('keystroke that didn\'t add a step can undo', function() {
it("keystroke that didn't add a step can undo", function () {
const history = new HistoryManager();
const parts = ["hello"];
const model = { serializeParts: () => parts.slice() } as unknown as EditorModel;
@ -122,7 +122,7 @@ describe('editor/history', function() {
expect(undoState.caret).toEqual(firstCaret);
expect(undoState.parts).toEqual(["hello"]);
});
it('undo after keystroke that didn\'t add a step is able to redo', function() {
it("undo after keystroke that didn't add a step is able to redo", function () {
const history = new HistoryManager();
const parts = ["hello"];
const model = { serializeParts: () => parts.slice() } as unknown as EditorModel;
@ -137,12 +137,12 @@ describe('editor/history', function() {
expect(redoState.parts).toEqual(["helloo"]);
});
it('overwriting text always stores a step', function() {
it("overwriting text always stores a step", function () {
const history = new HistoryManager();
const parts = ["hello"];
const model = { serializeParts: () => parts.slice() } as unknown as EditorModel;
const firstCaret = new DocumentPosition(0, 0);
history.tryPush(model, firstCaret, 'insertText', {});
history.tryPush(model, firstCaret, "insertText", {});
const diff = { at: 1, added: "a", removed: "e" };
const secondCaret = new DocumentPosition(1, 1);
const result = history.tryPush(model, secondCaret, "insertText", diff);