Skip to content

Commit

Permalink
fix: correct lint and types issues
Browse files Browse the repository at this point in the history
  • Loading branch information
hdinia committed Oct 14, 2024
1 parent f237d0d commit 960e55f
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 130 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ function ResultDetails() {
columns={generateCustomColumns({
titles: matrix.columns,
})}
isReaOnlyEnabled
isReadOnlyEnabled
/>
)
}
Expand All @@ -292,7 +292,7 @@ function ResultDetails() {
}),
]}
dateTime={dateTime}
isReaOnlyEnabled
isReadOnlyEnabled
/>
)
}
Expand Down
56 changes: 0 additions & 56 deletions webapp/src/components/common/MatrixGrid/useGridCellContent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,42 +80,6 @@ function renderGridCellContent(
}

describe("useGridCellContent", () => {
test("returns correct text cell content for DateTime columns", () => {
const columns: EnhancedGridColumn[] = [
{
id: "date",
title: "Date",
type: ColumnTypes.DateTime,
width: 150,
editable: false,
},
{
id: "data1",
title: "TS 1",
type: ColumnTypes.Number,
width: 50,
editable: true,
},
];

const dateTime = ["2024-01-07T00:00:00Z", "2024-01-02T00:00:00Z"];

const data = [
[11, 10],
[12, 15],
];

const getCellContent = renderGridCellContent(data, columns, dateTime);
const cell = getCellContent([0, 0]);

if ("displayData" in cell) {
expect(cell.kind).toBe("text");
expect(cell.displayData).toBe("7 janv. 2024, 00:00");
} else {
throw new Error("Expected a text cell with displayData");
}
});

describe("returns correct cell content for Aggregate columns", () => {
const columns: EnhancedGridColumn[] = [
{
Expand Down Expand Up @@ -220,17 +184,6 @@ describe("useGridCellContent", () => {
aggregates,
);

const dateTimeCell = getCellContent([0, 0]);

if (dateTimeCell.kind === "text" && "displayData" in dateTimeCell) {
expect(dateTimeCell.data).toBe("");
expect(dateTimeCell.displayData).toBe("1 janv. 2021, 00:00");
} else {
throw new Error(
"Expected a DateTime cell with displayData containing the year 2021",
);
}

const numberCell = getCellContent([1, 0]);

if (numberCell.kind === "number" && "data" in numberCell) {
Expand Down Expand Up @@ -319,15 +272,6 @@ describe("useGridCellContent with mixed column types", () => {
throw new Error("Expected a text cell with data for row header");
}

// Test date column (DateTime column)
const dateCell = getCellContent([1, 0]);
if (dateCell.kind === "text" && "displayData" in dateCell) {
expect(dateCell.data).toBe("");
expect(dateCell.displayData).toBe("1 janv. 2024, 00:00");
} else {
throw new Error("Expected a text cell with data for date");
}

// Test first data column (Number column)
const firstDataCell = getCellContent([2, 0]);

Expand Down
72 changes: 0 additions & 72 deletions webapp/src/components/common/MatrixGrid/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,78 +35,6 @@ describe("generateDateTime", () => {
const result = generateDateTime(metadata);
expect(result).toHaveLength(5);
});

test.each([
{
level: "hourly",
start: "2023-01-01T00:00:00Z",
expected: [
"2023-01-01T00:00:00.000Z",
"2023-01-01T01:00:00.000Z",
"2023-01-01T02:00:00.000Z",
],
},
{
level: "daily",
start: "2023-01-01T00:00:00Z",
expected: [
"2023-01-01T00:00:00.000Z",
"2023-01-02T00:00:00.000Z",
"2023-01-03T00:00:00.000Z",
],
},
{
level: "weekly",
start: "2023-01-01T00:00:00Z",
expected: [
"2023-01-01T00:00:00.000Z",
"2023-01-08T00:00:00.000Z",
"2023-01-15T00:00:00.000Z",
],
},
{
level: "monthly",
start: "2023-01-15T00:00:00Z",
expected: [
"2023-01-15T00:00:00.000Z",
"2023-02-15T00:00:00.000Z",
"2023-03-15T00:00:00.000Z",
],
},
{
level: "annual",
start: "2020-02-29T00:00:00Z",
expected: ["2020-02-29T00:00:00.000Z", "2021-02-28T00:00:00.000Z"],
},
] as const)(
"generates correct dates for $level level",
({ level, start, expected }) => {
const metadata: MatrixIndex = {
start_date: start,
steps: expected.length,
first_week_size: 7,
level: level as MatrixIndex["level"],
};

const result = generateDateTime(metadata);

expect(result).toEqual(expected);
},
);

test("handles edge cases", () => {
const metadata: MatrixIndex = {
start_date: "2023-12-31T23:59:59Z",
steps: 2,
first_week_size: 7,
level: StudyOutputDownloadLevelDTO.HOURLY,
};
const result = generateDateTime(metadata);
expect(result).toEqual([
"2023-12-31T23:59:59.000Z",
"2024-01-01T00:59:59.000Z",
]);
});
});

describe("generateTimeSeriesColumns", () => {
Expand Down

0 comments on commit 960e55f

Please sign in to comment.