Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix tests #310

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ import { setupStore } from "../../../redux/store";
import { setColorsByAttrubute } from "../../../redux/slices/colors-by-attribute-slice";

jest.mock("@loaders.gl/core");
jest.mock("@loaders.gl/i3s", () => {
return jest.fn().mockImplementation(() => {
return null;
});
});

jest.mock("../histogram", () => ({
HistogramChart: jest.fn().mockImplementation(() => <div>HistogramChart</div>),
Expand Down
46 changes: 30 additions & 16 deletions src/components/comparison/comparison-side/comparison-side.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,36 @@ import { MemoryUsagePanel } from "../../memory-usage-panel/memory-usage-panel";
import { setupStore } from "../../../redux/store";
import { setDragMode } from "../../../redux/slices/drag-mode-slice";

jest.mock("@deck.gl/geo-layers", () => ({
load: jest.fn(),
}));
jest.mock("@deck.gl/layers", () => ({
load: jest.fn(),
}));
jest.mock("maplibre-gl", () => ({
load: jest.fn(),
}));
jest.mock("@loaders.gl/i3s", () => ({
load: jest.fn(),
}));
jest.mock("@loaders.gl/3d-tiles", () => ({
load: jest.fn(),
}));
jest.mock("@loaders.gl/core");
jest.mock("react-map-gl/maplibre", () => {
return jest.fn().mockImplementation(() => {
return null;
});
});
jest.mock("@loaders.gl/core", () => {
return {
load: jest.fn(),
};
});
jest.mock("@loaders.gl/i3s", () => {
return jest.fn().mockImplementation(() => {
return null;
});
});
jest.mock("@loaders.gl/3d-tiles", () => {
return jest.fn().mockImplementation(() => {
return null;
});
});
jest.mock("@deck.gl/layers", () => {
return jest.fn().mockImplementation(() => {
return null;
});
});
jest.mock("@deck.gl/geo-layers", () => {
return jest.fn().mockImplementation(() => {
return null;
});
});
jest.mock("../../deck-gl-wrapper/deck-gl-wrapper");
jest.mock("../../main-tools-panel/main-tools-panel");
jest.mock("../../layers-panel/layers-panel");
Expand Down
5 changes: 5 additions & 0 deletions src/components/debug-panel/debug-panel.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ import {
selectBoundingVolumeType,
} from "../../redux/slices/debug-options-slice";

jest.mock("@loaders.gl/i3s", () => {
return jest.fn().mockImplementation(() => {
return null;
});
});
jest.mock("../../utils/hooks/layout");
jest.mock("../close-button/close-button", () => ({
CloseButton: ({ onClick }) => {
Expand Down
46 changes: 31 additions & 15 deletions src/components/deck-gl-wrapper/deck-gl-wrapper.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,45 @@ import {

// Mocks
jest.mock("@loaders.gl/core");
jest.mock("@loaders.gl/i3s", () => {
return {
COORDINATE_SYSTEM: {
METER_OFFSETS: 2,
LNGLAT_OFFSETS: 3,
},
};
});
jest.mock("@loaders.gl/3d-tiles", () => {
return jest.fn().mockImplementation(() => {
return null;
});
});
jest.mock("@loaders.gl/images");
jest.mock("@loaders.gl/tiles");
jest.mock("@deck.gl/react", () => {
return jest.fn().mockImplementation(() => {
return null;
});
});
jest.mock("@deck.gl/geo-layers", () => ({
load: jest.fn(),
}));
jest.mock("@deck.gl/layers", () => ({
load: jest.fn(),
}));
jest.mock("maplibre-gl", () => ({
load: jest.fn(),
}));
jest.mock("@loaders.gl/i3s", () => ({
load: jest.fn(),
}));
jest.mock("@loaders.gl/3d-tiles", () => ({
load: jest.fn(),
}));
jest.mock("react-map-gl/maplibre", () => {
return {
Map: jest.fn().mockImplementation(() => <div></div>),
};
});
jest.mock("@deck.gl/core");
jest.mock("@deck.gl/layers", () => {
return {
LineLayer: jest.fn(),
ScatterplotLayer: jest.fn(),
};
});

jest.mock("@deck.gl/geo-layers", () => {
return {
Tile3DLayer: jest.fn(),
TerrainLayer: jest.fn(),
};
});
jest.mock("../../utils/debug/build-minimap-data");
jest.mock("../../utils/debug/texture-selector-utils");
jest.mock("../../utils/debug/frustum-utils");
Expand Down
5 changes: 5 additions & 0 deletions src/components/layers-panel/map-options-panel.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ import {
selectSelectedBaseMapId,
} from "../../redux/slices/base-maps-slice";

jest.mock("@loaders.gl/i3s", () => {
return jest.fn().mockImplementation(() => {
return null;
});
});
jest.mock("./base-map-list-item/base-map-list-item");
jest.mock("../plus-button/plus-button");
jest.mock("./delete-confirmation");
Expand Down
6 changes: 6 additions & 0 deletions src/components/map-control-panel/map-control-panel.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ import { MapControllPanel } from "./map-control-panel";
import { setupStore } from "../../redux/store";
import { setDragMode } from "../../redux/slices/drag-mode-slice";

jest.mock("@loaders.gl/i3s", () => {
return jest.fn().mockImplementation(() => {
return null;
});
});

describe("MapControllPanel", () => {
let componentElement;
let buttons;
Expand Down
11 changes: 6 additions & 5 deletions src/redux/slices/attribute-stats-map-slice.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import {
getAttributeStatsInfo,
selectStatisitcsMap,
} from "./attribute-stats-map-slice";
import { StatsInfo } from "@loaders.gl/i3s";

jest.mock("@loaders.gl/core");
jest.mock("@loaders.gl/i3s", () => ({
load: jest.fn(),
}));
jest.mock("@loaders.gl/i3s", () => {
return jest.fn().mockImplementation(() => {
return null;
});
});

describe("slice: attribute-stats-map", () => {
it("Selector should return the initial state", () => {
Expand Down Expand Up @@ -57,7 +58,7 @@ describe("slice: attribute-stats-map", () => {
});
});

const stats: StatsInfo = {
const stats = {
avg: 27.159085097827166,
max: 1408.377901,
min: 0,
Expand Down
8 changes: 5 additions & 3 deletions src/redux/slices/base-maps-slice.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ import reducer, {
deleteBaseMaps,
} from "./base-maps-slice";

jest.mock("@loaders.gl/i3s", () => ({
load: jest.fn(),
}));
jest.mock("@loaders.gl/i3s", () => {
return jest.fn().mockImplementation(() => {
return null;
});
});

describe("slice: base-maps", () => {
it("Reducer should return the initial state", () => {
Expand Down
2 changes: 1 addition & 1 deletion src/redux/slices/base-maps-slice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { BASE_MAPS } from "../../constants/map-styles";
import { RootState } from "../store";

// Define a type for the slice state
interface BaseMapsState {
export interface BaseMapsState {
baseMap: BaseMap[];
selectedBaseMap: string;
}
Expand Down
6 changes: 6 additions & 0 deletions src/redux/slices/colors-by-attribute-slice.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ import reducer, {
setColorsByAttrubute,
} from "./colors-by-attribute-slice";

jest.mock("@loaders.gl/i3s", () => {
return jest.fn().mockImplementation(() => {
return null;
});
});

describe("slice: colors-by-attribute", () => {
it("Reducer should return the initial state", () => {
expect(reducer(undefined, { type: undefined })).toEqual({ value: null });
Expand Down
4 changes: 0 additions & 4 deletions src/redux/slices/colors-by-attribute-slice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ import { PayloadAction, createSlice } from "@reduxjs/toolkit";
import { ColorsByAttribute } from "../../types";
import { RootState } from "../store";

jest.mock("@loaders.gl/i3s", () => ({
load: jest.fn(),
}));

// Define a type for the slice state
export interface ColorsByAttributeState {
/** Values of color properties responsible for colorizig by attributes */
Expand Down
6 changes: 6 additions & 0 deletions src/redux/slices/debug-option-slice.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ import reducer, {
setDebugOptions,
} from "./debug-options-slice";

jest.mock("@loaders.gl/i3s", () => {
return jest.fn().mockImplementation(() => {
return null;
});
});

describe("slice: debug-options", () => {
it("Reducer should return the initial state", () => {
expect(reducer(undefined, { type: undefined })).toEqual({
Expand Down
10 changes: 7 additions & 3 deletions src/redux/slices/drag-mode-slice.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@ import reducer, {
selectDragMode,
setDragMode,
} from "./drag-mode-slice";
jest.mock("@loaders.gl/i3s", () => ({
load: jest.fn(),
}));

jest.mock("@loaders.gl/i3s", () => {
return jest.fn().mockImplementation(() => {
return null;
});
});

describe("slice: drag-mode", () => {
it("Reducer should return the initial state", () => {
expect(reducer(undefined, { type: undefined })).toEqual({
Expand Down
8 changes: 5 additions & 3 deletions src/redux/slices/flattened-sublayers-slice.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@ import {
} from "./test-data/fluttened-sublayers-slice-test-data";

jest.mock("@loaders.gl/core");
jest.mock("@loaders.gl/i3s", () => ({
load: jest.fn(),
}));
jest.mock("@loaders.gl/i3s", () => {
return jest.fn().mockImplementation(() => {
return null;
});
});

const previousState: flattenedSublayersState = {
single: {
Expand Down
8 changes: 5 additions & 3 deletions src/redux/slices/uv-debug-texture-slice.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ import {
import { ImageLoader } from "@loaders.gl/images";

jest.mock("@loaders.gl/core");
jest.mock("@loaders.gl/i3s", () => ({
load: jest.fn(),
}));
jest.mock("@loaders.gl/i3s", () => {
return jest.fn().mockImplementation(() => {
return null;
});
});

const imageStubObject = { width: 1024, height: 1024, data: new ArrayBuffer(0) };

Expand Down
Loading