Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
christian-byrne committed Dec 25, 2024
1 parent 7018481 commit 6a6837f
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions test/LGraphCanvas.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { lgTest } from "./lgTest"
import { expect, describe, vi } from "vitest"
import { LGraphCanvas } from "@/LGraphCanvas"
import { LinkRenderType } from "@/types/globalEnums"

describe("Link rendering", () => {
lgTest("should not draw link mouseover effect when links are hidden", () => {
const mockCtx = {
fillText: vi.fn(),
measureText: vi.fn(() => ({ width: 100 })),
} as unknown as CanvasRenderingContext2D

const mockLink = {} as any

const mockCanvas: Partial<LGraphCanvas> = {
links_render_mode: LinkRenderType.HIDDEN_LINK,
} as LGraphCanvas

// Directly call the method that draws link mouseover effects and tooltips
const drawLinkTooltip = LGraphCanvas.prototype.drawLinkTooltip
drawLinkTooltip.call(mockCanvas, mockCtx, mockLink)

// Verify that no text rendering was attempted
expect(mockCtx.fillText).not.toHaveBeenCalled()
})
})

0 comments on commit 6a6837f

Please sign in to comment.