Skip to content

Commit

Permalink
chore: resolve merge conflicts
Browse files Browse the repository at this point in the history
Co-Authored-By: Myles Scolnick <myles@marimo.io>
  • Loading branch information
devin-ai-integration[bot] and mscolnick committed Dec 21, 2024
2 parents 5963890 + 9a6154b commit a67c291
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 23 deletions.
12 changes: 9 additions & 3 deletions frontend/src/core/codemirror/dnd/__tests__/extension.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, it, expect, vi, beforeEach } from "vitest";
import { EditorView } from "@codemirror/view";
import type { EditorView } from "@codemirror/view";
import { dndBundle } from "../extension";
import { insertImage, insertTextFile } from "../../markdown/commands";

Expand Down Expand Up @@ -44,7 +44,10 @@ describe("dndBundle", () => {
handlers.drop(event, view);

expect(event.preventDefault).toHaveBeenCalled();
expect(insertTextFile).toHaveBeenCalledWith(view, event.dataTransfer?.files[0]);
expect(insertTextFile).toHaveBeenCalledWith(
view,
event.dataTransfer?.files[0],
);
});

it("handles image file drops", () => {
Expand All @@ -58,7 +61,10 @@ describe("dndBundle", () => {
handlers.drop(event, view);

expect(event.preventDefault).toHaveBeenCalled();
expect(insertImage).toHaveBeenCalledWith(view, event.dataTransfer?.files[0]);
expect(insertImage).toHaveBeenCalledWith(
view,
event.dataTransfer?.files[0],
);
});

it("handles plain text drops", () => {
Expand Down
25 changes: 13 additions & 12 deletions frontend/src/core/codemirror/editing/__tests__/commands.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, it, expect, vi, beforeEach } from "vitest";
import { EditorView } from "@codemirror/view";
import type { EditorView } from "@codemirror/view";
import { makeBulkCommand, foldAllBulk, unfoldAllBulk } from "../commands";
import { foldAll, unfoldAll } from "@codemirror/language";

Expand All @@ -12,19 +12,19 @@ describe("makeBulkCommand", () => {
it("should return false for empty array", () => {
const mockCommand = vi.fn().mockReturnValue(true);
const bulkCommand = makeBulkCommand(mockCommand);

const result = bulkCommand([]);

expect(result).toBe(false);
expect(mockCommand).not.toHaveBeenCalled();
});

it("should skip null targets", () => {
const mockCommand = vi.fn().mockReturnValue(true);
const bulkCommand = makeBulkCommand(mockCommand);

const result = bulkCommand([null, null]);

expect(result).toBe(false);
expect(mockCommand).not.toHaveBeenCalled();
});
Expand All @@ -34,25 +34,26 @@ describe("makeBulkCommand", () => {
const bulkCommand = makeBulkCommand(mockCommand);
const view1 = { dispatch: vi.fn() } as unknown as EditorView;
const view2 = { dispatch: vi.fn() } as unknown as EditorView;

const result = bulkCommand([view1, null, view2]);

expect(result).toBe(true);
expect(mockCommand).toHaveBeenCalledTimes(2);
expect(mockCommand).toHaveBeenCalledWith(view1);
expect(mockCommand).toHaveBeenCalledWith(view2);
});

it("should return true if any command returns true", () => {
const mockCommand = vi.fn()
const mockCommand = vi
.fn()
.mockReturnValueOnce(false)
.mockReturnValueOnce(true);
const bulkCommand = makeBulkCommand(mockCommand);
const view1 = { dispatch: vi.fn() } as unknown as EditorView;
const view2 = { dispatch: vi.fn() } as unknown as EditorView;

const result = bulkCommand([view1, view2]);

expect(result).toBe(true);
expect(mockCommand).toHaveBeenCalledTimes(2);
});
Expand All @@ -62,9 +63,9 @@ describe("makeBulkCommand", () => {
const bulkCommand = makeBulkCommand(mockCommand);
const view1 = { dispatch: vi.fn() } as unknown as EditorView;
const view2 = { dispatch: vi.fn() } as unknown as EditorView;

const result = bulkCommand([view1, view2]);

expect(result).toBe(false);
expect(mockCommand).toHaveBeenCalledTimes(2);
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
import { EditorView } from "@codemirror/view";
import { EditorState } from "@codemirror/state";
import { smartPlaceholderExtension, clickablePlaceholderExtension } from "../extensions";
import {
smartPlaceholderExtension,
clickablePlaceholderExtension,
} from "../extensions";

describe("smartPlaceholderExtension", () => {
const placeholderText = "Type something...";
Expand Down Expand Up @@ -71,14 +74,18 @@ describe("clickablePlaceholderExtension", () => {
});

// Get the placeholder element
const placeholder = view.dom.querySelector(".cm-placeholder") as HTMLElement;
const placeholder = view.dom.querySelector(
".cm-placeholder",
) as HTMLElement;
expect(placeholder).toBeTruthy();

// Check text content
expect(placeholder.textContent).toBe("Click here to continue");

// Find and check the clickable link
const link = placeholder.querySelector(".cm-clickable-placeholder") as HTMLElement;
const link = placeholder.querySelector(
".cm-clickable-placeholder",
) as HTMLElement;
expect(link).toBeTruthy();
expect(link.textContent).toBe("here");

Expand Down Expand Up @@ -110,15 +117,17 @@ describe("clickablePlaceholderExtension", () => {
});

// Get the link element
const link = view.dom.querySelector(".cm-clickable-placeholder") as HTMLElement;

const link = view.dom.querySelector(
".cm-clickable-placeholder",
) as HTMLElement;

// Create a mock event
const event = new MouseEvent("click");
const stopPropagation = vi.spyOn(event, "stopPropagation");

// Simulate click with the mock event
link.dispatchEvent(event);

expect(stopPropagation).toHaveBeenCalled();
expect(onClick).toHaveBeenCalled();

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/core/codemirror/theme/__tests__/light.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ describe("lightTheme", () => {
describe("syntax highlighting", () => {
const findStyle = (tag: Tag | readonly Tag[]) =>
config.styles.find((s) =>
Array.isArray(s.tag) ? s.tag.includes(tag as Tag) : s.tag === tag
Array.isArray(s.tag) ? s.tag.includes(tag as Tag) : s.tag === tag,
);

it("should style comments", () => {
Expand Down

0 comments on commit a67c291

Please sign in to comment.