test: refactor graph initialization (#288)

Use the graph initialization util function in the "serialization" tests.
development
Thomas Bouffard 2023-12-11 08:54:15 +01:00 committed by GitHub
parent 1507490c72
commit 871e1c37d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 9 additions and 9 deletions

View File

@ -15,7 +15,8 @@ limitations under the License.
*/ */
import { describe, expect, test } from '@jest/globals'; 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'; import { getPrettyXml, parseXml } from '../../src/util/xmlUtils';
type ModelExportOptions = { 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', () => { test('use Graph - reproduced what is described in issue 178', () => {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion const graph = createGraphWithoutContainer();
const graph = new Graph(null!);
expect(() => expect(() =>
new ModelXmlSerializer(graph.getDataModel()).import(xmlFromIssue178) new ModelXmlSerializer(graph.getDataModel()).import(xmlFromIssue178)
).toThrow(new Error('Invalid x supplied.')); ).toThrow(new Error('Invalid x supplied.'));

View File

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
import { Graph } from '../../../src'; import { Graph } from '../src';
// no need for a container, we don't check the view here // no need for a container, we don't check the view here
export const createGraphWithoutContainer = (): Graph => new Graph(null!); export const createGraphWithoutContainer = (): Graph => new Graph(null!);

View File

@ -15,7 +15,7 @@ limitations under the License.
*/ */
import { expect, test } from '@jest/globals'; import { expect, test } from '@jest/globals';
import { createGraphWithoutPlugins } from './utils'; import { createGraphWithoutPlugins } from '../../utils';
test('The "ConnectionHandler" plugin is not available', () => { test('The "ConnectionHandler" plugin is not available', () => {
const graph = createGraphWithoutPlugins(); const graph = createGraphWithoutPlugins();

View File

@ -15,7 +15,7 @@ limitations under the License.
*/ */
import { describe, expect, test } from '@jest/globals'; import { describe, expect, test } from '@jest/globals';
import { createGraphWithoutContainer } from './utils'; import { createGraphWithoutContainer } from '../../utils';
import { Cell, type CellStyle, Geometry } from '../../../src'; import { Cell, type CellStyle, Geometry } from '../../../src';
describe('insertEdge', () => { describe('insertEdge', () => {

View File

@ -15,7 +15,7 @@ limitations under the License.
*/ */
import { test } from '@jest/globals'; import { test } from '@jest/globals';
import { createGraphWithoutPlugins } from './utils'; import { createGraphWithoutPlugins } from '../../utils';
test('The "PanningHandler" plugin is not available', () => { test('The "PanningHandler" plugin is not available', () => {
const graph = createGraphWithoutPlugins(); const graph = createGraphWithoutPlugins();

View File

@ -15,7 +15,7 @@ limitations under the License.
*/ */
import { test } from '@jest/globals'; import { test } from '@jest/globals';
import { createGraphWithoutPlugins } from './utils'; import { createGraphWithoutPlugins } from '../../utils';
import { Cell, CellState } from '../../../src'; import { Cell, CellState } from '../../../src';
test('The "TooltipHandler" plugin is not available', () => { test('The "TooltipHandler" plugin is not available', () => {

View File

@ -15,7 +15,7 @@ limitations under the License.
*/ */
import { describe, expect, test } from '@jest/globals'; import { describe, expect, test } from '@jest/globals';
import { createGraphWithoutContainer } from './utils'; import { createGraphWithoutContainer } from '../../utils';
import { type CellStyle, Geometry } from '../../../src'; import { type CellStyle, Geometry } from '../../../src';
describe('insertVertex', () => { describe('insertVertex', () => {