Skip to content

Commit

Permalink
[TEST]
Browse files Browse the repository at this point in the history
  • Loading branch information
Rachico committed Apr 15, 2024
1 parent 6584473 commit 7a773c4
Showing 1 changed file with 53 additions and 1 deletion.
54 changes: 53 additions & 1 deletion tests/clipboard/clipboard_plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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", () => {});

Expand Down

0 comments on commit 7a773c4

Please sign in to comment.