Skip to content

Commit

Permalink
les tests passent i
Browse files Browse the repository at this point in the history
  • Loading branch information
rrahir committed Apr 11, 2024
1 parent f4f0a8a commit 96f8c40
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion tests/pivots/pivot_data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ export const pivotModelData = function (xc: string) {
},
],
name: "My pivot",
zone: `${toZone(xc)}`,
zone: toZone(xc),
sheetId: "pivot",
formulaId: "1",
},
Expand Down
11 changes: 6 additions & 5 deletions tests/pivots/spreadsheet_pivot.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Model } from "../../src";
import { toZone } from "../../src/helpers";
import { deleteContent, redo, setCellContent, undo } from "../test_helpers/commands_helpers";
import { getCellContent, getCellError } from "../test_helpers/getters_helpers";
import { addPivot, createModelWithPivot, updatePivot } from "../test_helpers/pivot_helpers";
Expand All @@ -21,7 +22,7 @@ describe("Spreadsheet Pivot", () => {
},
],
});
addPivot(model, { range: "A1:C5" });
addPivot(model, { zone: toZone("A1:C5") });
const fields = model.getters.getPivot("1").getFields()!;
expect(Object.keys(fields)).toEqual(["Customer", "Order", "Date"]);
});
Expand All @@ -37,7 +38,7 @@ describe("Spreadsheet Pivot", () => {
},
],
});
addPivot(model, { range: "A1:B5" });
addPivot(model, { zone: toZone("A1:B5") });
const fields = model.getters.getPivot("1").getFields()!;
expect(Object.keys(fields)).toEqual(["Customer", "Customer2"]);
});
Expand All @@ -53,7 +54,7 @@ describe("Spreadsheet Pivot", () => {
},
],
});
addPivot(model, { range: "A1:B5" });
addPivot(model, { zone: toZone("A1:B5") });
const fields = model.getters.getPivot("1").getFields()!;
expect(Object.keys(fields)).toEqual(["Customer", "Hello"]);
});
Expand Down Expand Up @@ -101,7 +102,7 @@ describe("Spreadsheet Pivot", () => {
},
],
});
addPivot(model, { range: "A1:I4" });
addPivot(model, { zone: toZone("A1:I4") });
const fields = model.getters.getPivot("1").getFields()!;
expect(
Object.keys(fields).map((field) => ({ name: field, type: fields[field]?.type }))
Expand Down Expand Up @@ -129,7 +130,7 @@ describe("Spreadsheet Pivot", () => {
},
],
});
addPivot(model, { range: "A1:B5" });
addPivot(model, { zone: toZone("A1:B5") });
expect(model.getters.getPivot("1").isLoadedAndValid()).toBeFalsy();
});

Expand Down
8 changes: 4 additions & 4 deletions tests/test_helpers/pivot_helpers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { DispatchResult, Model, UID } from "../../src";
import { toZone } from "../../src/helpers";
import { SpreadsheetPivotCoreDefinition } from "../../src/types/pivot";
import { pivotModelData } from "../pivots/pivot_data";

Expand All @@ -9,10 +10,11 @@ export function createModelWithPivot(range: string): Model {
const DEFAULT_PIVOT_DATA: SpreadsheetPivotCoreDefinition = {
name: "Pivot",
type: "SPREADSHEET",
range: "A1:D5",
zone: toZone("A1:D5"),
rows: [],
columns: [],
measures: [],
sheetId: "1",
};

export function addPivot(
Expand All @@ -24,9 +26,7 @@ export function addPivot(
const pivot: SpreadsheetPivotCoreDefinition = {
...DEFAULT_PIVOT_DATA,
...pivotData,
range: `${model.getters.getSheetName(model.getters.getActiveSheetId())}:${
pivotData.range || DEFAULT_PIVOT_DATA.range
}`,
sheetId: model.getters.getActiveSheetId(),
};
const result = model.dispatch("ADD_PIVOT", { pivot, pivotId });
const instance = model.getters.getPivot(pivotId);
Expand Down

0 comments on commit 96f8c40

Please sign in to comment.