import { isSeparatorContent, SeparatorContent, SeparatorContentType, } from "@prismicio/types-internal/lib/content" import type { Separator } from "@prismicio/types-internal/lib/customtypes" import { DiffChange, DiffOperation, } from "@prismicio/types-internal/lib/customtypes/diff" import type { NestableMock, Patch } from "../../Mock" export const SeparatorMock: NestableMock = { generate(): SeparatorContent { return { __TYPE__: SeparatorContentType, } }, applyPatch(data: Patch): | { result: SeparatorContent | undefined } | undefined { if (data.diff.op === DiffOperation.Removed) return { result: undefined } if (data.diff.value.type === "Separator") { const patched = this.patch( data.diff, isSeparatorContent(data.content) ? data.content : undefined, ) return { result: patched } } return }, patch( diff: DiffChange, _content: SeparatorContent, ): SeparatorContent | undefined { switch (diff.op) { case DiffOperation.Removed: return case DiffOperation.Updated: case DiffOperation.Added: return this.generate(diff.value) } }, }