Skip to content

Commit

Permalink
fix: add type to test code
Browse files Browse the repository at this point in the history
  • Loading branch information
miettal committed Aug 1, 2024
1 parent 062d960 commit 24405e8
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { QueryHistoricTimeseriesEnergyResponse } from "src/app/shared/jsonrpc/re

export namespace History {

export const LINE_CHART_OPTIONS = (period: string, chartType: 'line' | 'bar', options: { [key: string]: { scale: { min: number, max: number; }, ticks: { stepSize: number; }; }; }): OeChartTester.Dataset.Option => ({
export const LINE_CHART_OPTIONS = (period: string, chartType: 'line' | 'bar', options: { [key: string]: { scale: { min: number, max: number; } | null, ticks: { stepSize: number }; }; }): OeChartTester.Dataset.Option => ({
type: 'option',
options: {
"responsive": true, "maintainAspectRatio": false, "elements": { "point": { "radius": 0, "hitRadius": 0, "hoverRadius": 0 }, "line": { "stepped": false, "fill": true } }, "datasets": { "bar": {}, "line": {} }, "plugins": { "colors": { "enabled": false }, "legend": { "display": true, "position": "bottom", "labels": { "color": '' } }, "tooltip": { "intersect": false, "mode": "index", "callbacks": {} }, "annotation": { annotations: {} } }, "scales": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const DATASET = (data: OeChartTester.Dataset.Data, labels: OeChartTester.
options: options,
});

export const DATA = (name: string, value: number[]): OeChartTester.Dataset.Data => ({
export const DATA = (name: string, value: (number | null)[]): OeChartTester.Dataset.Data => ({
type: "data",
label: name,
value: value,
Expand Down
4 changes: 2 additions & 2 deletions ui/src/app/shared/components/edge/edgeconfig.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ export namespace DummyConfig {
});
export const GOODWE_GRID_METER = (id: string, alias?: string): Component => ({
id: id,
alias: alias,
alias: alias ?? id,
factory: Factory.METER_GOODWE_GRID,
properties: {
invert: false,
Expand All @@ -205,7 +205,7 @@ export namespace DummyConfig {

export const SOLAR_EDGE_PV_INVERTER = (id: string, alias?: string): Component => ({
id: id,
alias: alias,
alias: alias ?? id,
factoryId: 'SolarEdge.PV-Inverter',
factory: Factory.SOLAR_EDGE_PV_INVERTER,
properties: {
Expand Down
2 changes: 1 addition & 1 deletion ui/src/app/shared/components/shared/testing/tester.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ export namespace OeChartTester {
export type Data = {
type: 'data',
label: string | Converter,
value: number[] | null
value: (number | null)[]
};

export type LegendLabel = {
Expand Down
4 changes: 2 additions & 2 deletions ui/src/app/shared/utils/array/array.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export namespace ArrayUtils {
* @param arr the arr
* @returns a number if arr not empty, else null
*/
export function findSmallestNumber(arr: number[]): number | null {
export function findSmallestNumber(arr: (number | null | undefined)[]): number | null {
if (arr?.length === 0 || arr?.every(el => el == null)) {
return null; // Return undefined for an empty array or handle it based on your requirements
}
Expand All @@ -23,7 +23,7 @@ export namespace ArrayUtils {
* @param arr the arr
* @returns a number if arr not empty, else null
*/
export function findBiggestNumber(arr: number[]): number | null {
export function findBiggestNumber(arr: (number | null | undefined)[]): number | null {
if (arr?.length === 0 || arr?.every(el => el == null)) {
return null; // Return undefined for an empty array or handle it based on your requirements
}
Expand Down
2 changes: 1 addition & 1 deletion ui/src/app/shared/utils/date/dateutils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe('DateUtils', () => {
});

it('#isDateBefore - checks if given date is before date to be compared to', () => {
const date: Date = DateUtils.stringToDate('2023-01-01');
const date: Date = DateUtils.stringToDate('2023-01-01') as Date;
expect(DateUtils.isDateBefore(date, DateUtils.stringToDate("2023-01-31"))).toEqual(true);
expect(DateUtils.isDateBefore(date, DateUtils.stringToDate("2022-12-31"))).toEqual(false);
expect(DateUtils.isDateBefore(date, DateUtils.stringToDate("2023-01-01"))).toEqual(false);
Expand Down

0 comments on commit 24405e8

Please sign in to comment.