Skip to content

Commit

Permalink
chore: add scroll-canvas integration
Browse files Browse the repository at this point in the history
  • Loading branch information
liujiangyu committed Sep 9, 2023
1 parent 40d52a3 commit ceb8100
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 0 deletions.
63 changes: 63 additions & 0 deletions packages/g6/tests/integration/behaviors-scroll-canvas.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import { resetEntityCounter } from '@antv/g';
import scrollCanvas from '../demo/behaviors/activate-relations';
import './utils/useSnapshotMatchers';
import { createContext, triggerEvent } from './utils';

describe('Scroll canvas behavior', () => {
beforeEach(() => {
/**
* SVG Snapshot testing will generate a unique id for each element.
* Reset to 0 to keep snapshot consistent.
*/
resetEntityCounter();
});

it('should be rendered correctly with Canvas2D', (done) => {
const dir = `${__dirname}/snapshots/canvas`;
const { backgroundCanvas, canvas, transientCanvas, container } =
createContext('canvas', 500, 500);

const graph = scrollCanvas({
container,
backgroundCanvas,
canvas,
transientCanvas,
width: 500,
height: 500,
});

graph.on('afterlayout', async () => {
await expect(canvas).toMatchCanvasSnapshot(
dir,
'behaviors-scroll-canvas',
);

graph.destroy();
done();
});
});

it('should be rendered correctly with SVG', (done) => {
const dir = `${__dirname}/snapshots/svg`;
const { backgroundCanvas, canvas, transientCanvas, container } =
createContext('svg', 500, 500);

const graph = scrollCanvas({
container,
backgroundCanvas,
canvas,
transientCanvas,
width: 500,
height: 500,
});

graph.on('afterlayout', async () => {
await expect(canvas).toMatchSVGSnapshot(
dir,
'behaviors-scroll-canvas',
);
graph.destroy();
done();
});
});
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 ceb8100

Please sign in to comment.