Skip to content

Commit

Permalink
fix: Mocking of GQL client
Browse files Browse the repository at this point in the history
  • Loading branch information
bprusinowski committed Oct 26, 2022
1 parent 4cfe9dc commit 008dba9
Showing 1 changed file with 33 additions and 34 deletions.
67 changes: 33 additions & 34 deletions app/configurator/configurator-state.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,39 @@ jest.mock("@/utils/chart-config/exchange", () => ({
fetchChartConfig: jest.fn(),
}));

jest.mock("@/graphql/client", () => {
return {
client: {
readQuery: () => {
return {
data: {
dataCubeByIri: {
dimensions: [
{
__typename: "GeoShapesDimension",
iri: "newAreaLayerColorIri",
values: [{ value: "orange", label: "orange" }],
},
{
__typename: "GeoCoordinatesDimension",
iri: "symbolLayerIri",
values: [{ value: "x", label: "y" }],
},
],
measures: [
{
__typename: "NumericalMeasure",
iri: "measure",
},
],
},
},
};
},
},
};
});

afterEach(() => {
jest.restoreAllMocks();
});
Expand Down Expand Up @@ -692,23 +725,6 @@ describe("colorMapping", () => {
});

describe("handleChartFieldChanged", () => {
jest.mock("@/graphql/client", () => ({
readQuery: () => {
return {
dimensions: [
{
iri: "newAreaLayerColorIri",
values: [{ value: "orange", label: "orange" }],
},
{
iri: "symbolLayerIri",
values: [{ value: "x", label: "y" }],
},
],
};
},
}));

it("should not reset symbol layer when it's being updated", () => {
const state = {
state: "CONFIGURING_CHART",
Expand Down Expand Up @@ -755,23 +771,6 @@ describe("handleChartFieldChanged", () => {
});

describe("handleChartOptionChanged", () => {
jest.mock("@/graphql/client", () => ({
readQuery: () => {
return {
dimensions: [
{
iri: "newAreaLayerColorIri",
values: [{ value: "orange", label: "orange" }],
},
{
iri: "symbolLayerIri",
values: [{ value: "x", label: "y" }],
},
],
};
},
}));

it("should reset previous color filters", () => {
const state = {
state: "CONFIGURING_CHART",
Expand Down

0 comments on commit 008dba9

Please sign in to comment.