Skip to content

Commit

Permalink
test: combo combined layout test (#5535)
Browse files Browse the repository at this point in the history
  • Loading branch information
lxfu1 authored Mar 15, 2024
1 parent 26ba38c commit 7ea9471
Show file tree
Hide file tree
Showing 8 changed files with 676 additions and 193 deletions.
522 changes: 522 additions & 0 deletions packages/g6/__tests__/dataset/combo.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions packages/g6/__tests__/demo/case/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export * from './layout-circular-configuration-translate';
export * from './layout-circular-degree';
export * from './layout-circular-division';
export * from './layout-circular-spiral';
export * from './layout-combo-combined';
export * from './layout-concentric';
export * from './layout-dagre-flow';
export * from './layout-dagre-flow-combo';
Expand Down
41 changes: 41 additions & 0 deletions packages/g6/__tests__/demo/case/layout-combo-combined.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { Graph } from '@/src';
import data from '@@/dataset/combo.json';
import type { STDTestCase } from '../types';

type Item = {
id: string;
data: {
size?: number;
color?: string;
};
};

export const layoutComboCombined: STDTestCase = async (context) => {
const graph = new Graph({
...context,
data,
layout: {
type: 'combo-combined',
comboPadding: 2,
},
node: {
style: {
size: 20,
labelText: (d: Item) => d.id,
},
},
edge: {
// @ts-expect-error
style: (model: Item) => {
const { size, color } = model.data;
return { stroke: color || '#99ADD1', lineWidth: size || 1 };
},
},
behaviors: ['drag-combo', 'drag-node', 'drag-canvas', 'zoom-canvas'],
autoFit: 'view',
});

await graph.render();

return graph;
};
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ export const layoutRadialConfigurationTranslate: STDTestCase = async (context) =
},
},
behaviors: ['drag-canvas', 'drag-node'],
animation: true,
});

await graph.render();
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions packages/g6/__tests__/unit/layouts/combo-layout.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { layoutComboCombined } from '@@/demo/case';
import { createDemoGraph } from '@@/utils';

describe('combo layout', () => {
/** ComboCombinedLayout 在当前环境下运行异常 */
it.skip('combined', async () => {
const graph = await createDemoGraph(layoutComboCombined);
await expect(graph).toMatchSnapshot(__filename, 'combined');
graph.destroy();
});
});
Loading

0 comments on commit 7ea9471

Please sign in to comment.