Skip to content

Commit

Permalink
test: add test with edgeFilterLens
Browse files Browse the repository at this point in the history
  • Loading branch information
ColinChen2 committed Sep 21, 2023
1 parent fbc64ff commit a45a9e2
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/g6/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"fix": "eslint ./src ./tests --fix && prettier ./src ./tests --write ",
"test": "jest",
"test:integration": "node --expose-gc --max-old-space-size=4096 --unhandled-rejections=strict node_modules/jest/bin/jest tests/integration/ --config jest.node.config.js --coverage -i --logHeapUsage --detectOpenHandles",
"test:integration_one": "node --expose-gc --max-old-space-size=4096 --unhandled-rejections=strict node_modules/jest/bin/jest tests/integration/items-edge-loop.spec.ts --config jest.node.config.js --coverage -i --logHeapUsage --detectOpenHandles",
"test:integration_one": "node --expose-gc --max-old-space-size=4096 --unhandled-rejections=strict node_modules/jest/bin/jest tests/integration/plugins-edgeFilterLens.spec.ts --config jest.node.config.js --coverage -i --logHeapUsage --detectOpenHandles",
"size": "limit-size",
"test-live": "DEBUG_MODE=1 jest --watch ./tests/unit/item-animate-spec.ts",
"test-behavior": "DEBUG_MODE=1 jest --watch ./tests/unit/item-3d-spec.ts"
Expand Down
8 changes: 6 additions & 2 deletions packages/g6/tests/demo/plugins/edgeFilterLens.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Graph, Extensions, extend } from '../../../src/index';
import { TestCaseContext } from '../interface';

export default async () => {
export default async (context: TestCaseContext) => {
let trigger = 'mousemove';
let filterLens = {
type: 'filterLens',
Expand Down Expand Up @@ -100,6 +101,7 @@ export default async () => {
},
});
const graph = new ExtGraph({
...context,
container: 'container',
width,
height: height,
Expand Down Expand Up @@ -188,7 +190,7 @@ export default async () => {
graph.updatePlugin(filterLens);
});

fetch('https://gw.alipayobjects.com/os/bmw-prod/afe8b2a6-f691-4070-aa73-46fc07fd1171.json')
await fetch('https://gw.alipayobjects.com/os/bmw-prod/afe8b2a6-f691-4070-aa73-46fc07fd1171.json')
.then((res) => res.json())
.then((data) => {
data.edges.forEach((edge) => {
Expand All @@ -201,4 +203,6 @@ export default async () => {
graph.read(data);
graph.zoom(0.6);
});

return graph;
}
38 changes: 38 additions & 0 deletions packages/g6/tests/integration/plugins-edgeFilterLens.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { resetEntityCounter } from '@antv/g';
import EdgeFilterLens from '../demo/plugins/edgeFilterLens';
import { createContext, sleep } from './utils';
import { triggerEvent } from './utils/event';
import './utils/useSnapshotMatchers';

describe('Default EdgeFilterLens', () => {
beforeEach(() => {
resetEntityCounter();
});

it('should be rendered correctly with Canvas2D', async () => {
const dir = `${__dirname}/snapshots/canvas/plugins/edgeFilterLens`;
const { backgroundCanvas, canvas, transientCanvas, container } =
createContext('canvas', 500, 500);
const graph = await EdgeFilterLens({
backgroundCanvas,
canvas,
transientCanvas,
width: 500,
height: 500,
container,
});

const process = new Promise((reslove) => {
graph.on('afterlayout', reslove);
})

await process;
await sleep(300);
triggerEvent(graph, 'mousedown', 100, 100);
await expect(canvas).toMatchCanvasSnapshot(
dir,
'plugins-edge-filter-lens',
);
graph.destroy();
});
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit a45a9e2

Please sign in to comment.