diff --git a/tests/clipboard/clipboard_plugin.test.ts b/tests/clipboard/clipboard_plugin.test.ts index e508d7b218..cf720a31d2 100644 --- a/tests/clipboard/clipboard_plugin.test.ts +++ b/tests/clipboard/clipboard_plugin.test.ts @@ -2344,7 +2344,59 @@ describe("copy/paste cell content and cell formatting from one given sheet to an expect(getBorder(modelB, "D2")).toEqual({ top: DEFAULT_BORDER_DESC }); }); - test("it should copy/paste a cell with conditional formatting", () => {}); + test("it should copy/paste a cell with conditional formatting", () => { + const modelA = new Model(); + const modelB = new Model(); + + setCellContent(modelA, "A1", "1"); + setCellContent(modelA, "A2", "2"); + setCellContent(modelA, "A3", "1"); + const sheetId = modelA.getters.getActiveSheetId(); + const cf = createEqualCF("1", { fillColor: "#00FF00" }, "1"); + const res = modelA.dispatch("ADD_CONDITIONAL_FORMAT", { + cf, + sheetId, + ranges: toRangesData(sheetId, "A1,A3"), + }); + + expect(res).toBeSuccessfullyDispatched(); + + copy(modelA, "A1:A3"); + pasteFromOSClipboard( + modelB, + "D1", + modelA.getters.getClipboardTextContent(), + modelA.getters.getClipboardCellFormattingContent() + ); + + expect(getStyle(modelA, "A1")).toEqual({ + fillColor: "#00FF00", + }); + expect(getStyle(modelA, "A2")).toEqual({}); + expect(getStyle(modelA, "A3")).toEqual({ + fillColor: "#00FF00", + }); + /** Check if the values and conditional formatting are copied/pasted correctly */ + expect(getCell(modelB, "D1")).toMatchObject({ + content: "1", + }); + expect(getCell(modelB, "D2")).toMatchObject({ + content: "2", + }); + expect(getCell(modelB, "D3")).toMatchObject({ + content: "1", + }); + expect(modelB.getters.getConditionalFormats(modelB.getters.getActiveSheetId())).toMatchObject([ + { ranges: ["D1:D3"], rule: cf.rule }, + ]); + expect(getStyle(modelB, "D1")).toEqual({ + fillColor: "#00FF00", + }); + expect(getStyle(modelB, "D2")).toEqual({}); + expect(getStyle(modelB, "D3")).toEqual({ + fillColor: "#00FF00", + }); + }); test("it should copy/paste a cell with a formula", () => {});