Skip to content

Commit

Permalink
fix: update graphin test
Browse files Browse the repository at this point in the history
  • Loading branch information
zxc0328 committed Nov 20, 2019
1 parent 210cfcb commit b6f6afb
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 6 deletions.
5 changes: 4 additions & 1 deletion packages/graphin/src/layout/basic/__tests__/circle.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import CircleLayout, { CircleLayoutOption } from '../circle';
import json from './__mock__/concentric.input.json';
import { Data } from '../../../types';

const defaultOptions = {
/** 圆心 x坐标 */
Expand All @@ -22,9 +23,11 @@ const node = {
},
};

const data: Data = json;

describe('Cricle Layout', () => {
it('Should return result that matches snapshot', () => {
expect(CircleLayout(json, defaultOptions as CircleLayoutOption)).toMatchSnapshot();
expect(CircleLayout(data, defaultOptions as CircleLayoutOption)).toMatchSnapshot();
});

it('Should return correct result for empty input', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import ConcentricLayout from '../concentric';
import json from './__mock__/concentric.input.json';
import { Data } from '../../../types';

const concentricOptions = {
/** 同心圆的布局范围,默认为当前画布的宽高范围 */
Expand Down Expand Up @@ -44,12 +45,14 @@ const concentricOptions2 = {
sweep: 0.1,
};

const data: Data = json;

describe('Concentric Layout', () => {
it('Should return result that matches snapshot', () => {
expect(
new ConcentricLayout({
...concentricOptions,
data: json,
data,
}).run(),
).toMatchSnapshot();
});
Expand All @@ -58,7 +61,7 @@ describe('Concentric Layout', () => {
expect(
new ConcentricLayout({
...concentricOptions2,
data: json,
data,
}).run(),
).toMatchSnapshot();
});
Expand Down
4 changes: 3 additions & 1 deletion packages/graphin/src/layout/basic/__tests__/grid.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ const gridLayoutOption = {
nodeSize: 50,
};

const data: Data = json;

describe('Grid Layout', () => {
it('Should return result that matches snapshot', () => {
expect(GridLayout(json as Data, gridLayoutOption as GridLayoutOptions)).toMatchSnapshot();
expect(GridLayout(data, gridLayoutOption as GridLayoutOptions)).toMatchSnapshot();
});
});
4 changes: 3 additions & 1 deletion packages/graphin/src/layout/g6/__tests__/dagre.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ const defaultOptions = {
align: 'UL',
};

const data: Data = json;

describe('Dagre Layout', () => {
it('Should return result that matches snapshot', () => {
expect(DagreLayout(json as Data, defaultOptions as DagreLayoutOption)).toMatchSnapshot();
expect(DagreLayout(data, defaultOptions as DagreLayoutOption)).toMatchSnapshot();
});
});
5 changes: 4 additions & 1 deletion packages/graphin/src/layout/g6/__tests__/radial.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import RadialLayout, { RadialLayoutOption } from '../radial';
import json from '../../basic/__tests__/__mock__/concentric.input.json';
import { Data } from '../../../types';

const defaultOptions = {
/** 中心点坐标 */
Expand All @@ -12,8 +13,10 @@ const defaultOptions = {
unitRadius: 150,
};

const data: Data = json;

describe('Radial Layout', () => {
it('Should return result that matches snapshot', () => {
expect(RadialLayout(json, defaultOptions as RadialLayoutOption)).toMatchSnapshot();
expect(RadialLayout(data, defaultOptions as RadialLayoutOption)).toMatchSnapshot();
});
});

0 comments on commit b6f6afb

Please sign in to comment.