Skip to content

OpenReel Video - Professional browser-based video editor. Open source CapCut alternative. 100% browser-based, no installation, no cloud uploads, no watermarks.

TypeScript
1.3 KB
Raw Blame
import { describe, expect, it } from "vitest";
import { BLEND_MODES } from "../video/types";
import {
  buildMotionCssBlendMode,
  getMotionCanvasBlendMode,
} from "./motion-blend-modes";

describe("motion blend modes", () => {
  it("maps normal blend mode to source-over and no CSS override", () => {
    expect(getMotionCanvasBlendMode(undefined)).toBe("source-over");
    expect(getMotionCanvasBlendMode("normal")).toBe("source-over");
    expect(buildMotionCssBlendMode(undefined)).toBeUndefined();
    expect(buildMotionCssBlendMode("normal")).toBeUndefined();
  });

  it("maps shared video blend modes to Canvas and CSS values", () => {
    expect(getMotionCanvasBlendMode("screen")).toBe("screen");
    expect(getMotionCanvasBlendMode("color-dodge")).toBe("color-dodge");
    expect(buildMotionCssBlendMode("screen")).toBe("screen");
    expect(buildMotionCssBlendMode("color-dodge")).toBe("color-dodge");
  });

  it("includes the additive Add family in BLEND_MODES", () => {
    expect(BLEND_MODES).toContain("add");
    expect(BLEND_MODES).toContain("linear-dodge");
  });

  it("maps the Add family to the Canvas2D lighter operation", () => {
    expect(getMotionCanvasBlendMode("add")).toBe("lighter");
    expect(getMotionCanvasBlendMode("linear-dodge")).toBe("lighter");
  });

});