From 871e1c37d5e766dc792dc19a1d836b3d7d90f2d4 Mon Sep 17 00:00:00 2001 From: Thomas Bouffard <27200110+tbouffard@users.noreply.github.com> Date: Mon, 11 Dec 2023 08:54:15 +0100 Subject: [PATCH] test: refactor graph initialization (#288) Use the graph initialization util function in the "serialization" tests. --- .../core/__tests__/serialization/serialization.xml.test.ts | 6 +++--- packages/core/__tests__/{view/mixins => }/utils.ts | 2 +- .../core/__tests__/view/mixins/ConnectionsMixin.test.ts | 2 +- packages/core/__tests__/view/mixins/EdgeMixin.test.ts | 2 +- packages/core/__tests__/view/mixins/PanningMixin.test.ts | 2 +- packages/core/__tests__/view/mixins/TooltipMixin.test.ts | 2 +- packages/core/__tests__/view/mixins/VertexMixin.test.ts | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) rename packages/core/__tests__/{view/mixins => }/utils.ts (95%) diff --git a/packages/core/__tests__/serialization/serialization.xml.test.ts b/packages/core/__tests__/serialization/serialization.xml.test.ts index ac857e731..125101f04 100644 --- a/packages/core/__tests__/serialization/serialization.xml.test.ts +++ b/packages/core/__tests__/serialization/serialization.xml.test.ts @@ -15,7 +15,8 @@ limitations under the License. */ import { describe, expect, test } from '@jest/globals'; -import { Cell, Codec, Geometry, Graph, GraphDataModel, Point } from '../../src'; +import { createGraphWithoutContainer } from '../utils'; +import { Cell, Codec, Geometry, GraphDataModel, Point } from '../../src'; import { getPrettyXml, parseXml } from '../../src/util/xmlUtils'; type ModelExportOptions = { @@ -111,8 +112,7 @@ describe('import before the export (reproduce https://github.com/maxGraph/maxGra }); test('use Graph - reproduced what is described in issue 178', () => { - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - const graph = new Graph(null!); + const graph = createGraphWithoutContainer(); expect(() => new ModelXmlSerializer(graph.getDataModel()).import(xmlFromIssue178) ).toThrow(new Error('Invalid x supplied.')); diff --git a/packages/core/__tests__/view/mixins/utils.ts b/packages/core/__tests__/utils.ts similarity index 95% rename from packages/core/__tests__/view/mixins/utils.ts rename to packages/core/__tests__/utils.ts index 96546ae81..7944c5a1d 100644 --- a/packages/core/__tests__/view/mixins/utils.ts +++ b/packages/core/__tests__/utils.ts @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -import { Graph } from '../../../src'; +import { Graph } from '../src'; // no need for a container, we don't check the view here export const createGraphWithoutContainer = (): Graph => new Graph(null!); diff --git a/packages/core/__tests__/view/mixins/ConnectionsMixin.test.ts b/packages/core/__tests__/view/mixins/ConnectionsMixin.test.ts index 933f83c03..955831cf9 100644 --- a/packages/core/__tests__/view/mixins/ConnectionsMixin.test.ts +++ b/packages/core/__tests__/view/mixins/ConnectionsMixin.test.ts @@ -15,7 +15,7 @@ limitations under the License. */ import { expect, test } from '@jest/globals'; -import { createGraphWithoutPlugins } from './utils'; +import { createGraphWithoutPlugins } from '../../utils'; test('The "ConnectionHandler" plugin is not available', () => { const graph = createGraphWithoutPlugins(); diff --git a/packages/core/__tests__/view/mixins/EdgeMixin.test.ts b/packages/core/__tests__/view/mixins/EdgeMixin.test.ts index d4a64e949..e0430b02e 100644 --- a/packages/core/__tests__/view/mixins/EdgeMixin.test.ts +++ b/packages/core/__tests__/view/mixins/EdgeMixin.test.ts @@ -15,7 +15,7 @@ limitations under the License. */ import { describe, expect, test } from '@jest/globals'; -import { createGraphWithoutContainer } from './utils'; +import { createGraphWithoutContainer } from '../../utils'; import { Cell, type CellStyle, Geometry } from '../../../src'; describe('insertEdge', () => { diff --git a/packages/core/__tests__/view/mixins/PanningMixin.test.ts b/packages/core/__tests__/view/mixins/PanningMixin.test.ts index c8f6aa42a..44ac5bc3f 100644 --- a/packages/core/__tests__/view/mixins/PanningMixin.test.ts +++ b/packages/core/__tests__/view/mixins/PanningMixin.test.ts @@ -15,7 +15,7 @@ limitations under the License. */ import { test } from '@jest/globals'; -import { createGraphWithoutPlugins } from './utils'; +import { createGraphWithoutPlugins } from '../../utils'; test('The "PanningHandler" plugin is not available', () => { const graph = createGraphWithoutPlugins(); diff --git a/packages/core/__tests__/view/mixins/TooltipMixin.test.ts b/packages/core/__tests__/view/mixins/TooltipMixin.test.ts index dc0c2f12f..81efc4b0a 100644 --- a/packages/core/__tests__/view/mixins/TooltipMixin.test.ts +++ b/packages/core/__tests__/view/mixins/TooltipMixin.test.ts @@ -15,7 +15,7 @@ limitations under the License. */ import { test } from '@jest/globals'; -import { createGraphWithoutPlugins } from './utils'; +import { createGraphWithoutPlugins } from '../../utils'; import { Cell, CellState } from '../../../src'; test('The "TooltipHandler" plugin is not available', () => { diff --git a/packages/core/__tests__/view/mixins/VertexMixin.test.ts b/packages/core/__tests__/view/mixins/VertexMixin.test.ts index d657b7e95..cc3c9f96a 100644 --- a/packages/core/__tests__/view/mixins/VertexMixin.test.ts +++ b/packages/core/__tests__/view/mixins/VertexMixin.test.ts @@ -15,7 +15,7 @@ limitations under the License. */ import { describe, expect, test } from '@jest/globals'; -import { createGraphWithoutContainer } from './utils'; +import { createGraphWithoutContainer } from '../../utils'; import { type CellStyle, Geometry } from '../../../src'; describe('insertVertex', () => {