import type { NestableContent, SharedSliceContent } from "@prismicio/types-internal/lib/content"; import type { WidgetContent } from "@prismicio/types-internal/lib/content"; import type { DynamicWidget, FieldType } from "@prismicio/types-internal/lib/customtypes"; import type { DiffChange, NestableWidgetDiff, SliceDiff } from "@prismicio/types-internal/lib/customtypes/diff"; import type { SharedSlice, SlicesTypes } from "@prismicio/types-internal/lib/customtypes/widgets/slices"; import type { StaticSlice } from "@prismicio/types-internal/lib/customtypes/widgets/slices/Slice"; import type { DynamicSlices } from "@prismicio/types-internal/lib/customtypes/widgets/slices/Slices"; import type { MockConfig } from "./MockConfig"; import type { NestableWidgetMockConfig } from "./widgets"; export declare type Patch = { diff: NestableWidgetDiff; content?: NestableContent | undefined; config?: NestableWidgetMockConfig | undefined; }; export interface WidgetMockWithDiff | "Repeatable", unknown> | undefined = undefined> { generate(def: D, config?: C): W; patch(diff: DiffChange, content?: W, config?: C): W | undefined; } export interface NestableMock | "Repeatable", unknown> | undefined = undefined> extends WidgetMockWithDiff { generate(def: D, config?: C): W; patch(diff: DiffChange, content?: W, config?: C): W | undefined; applyPatch(patch: Patch): { result: W | undefined; } | undefined; } /** * We support the diff only for shared slice for now we have a dedicated * interface without the patch for now */ export interface WidgetMock | "Repeatable", unknown> | undefined = undefined> { generate(def: D, config?: C): W; } export interface SlicesMock | undefined = undefined> { generate(def: D, sharedSlices: Partial>, config?: C): W; } export interface SliceMock | undefined = undefined> { generate(def: D, config?: C): S; patch(diff: SliceDiff, content?: S, config?: C): { ok: true; result: S | undefined; } | { ok: false; error: Error; }; }