forked from antvis/G6
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add scroll-canvas integration
- Loading branch information
liujiangyu
committed
Sep 9, 2023
1 parent
40d52a3
commit ceb8100
Showing
3 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
63 changes: 63 additions & 0 deletions
63
packages/g6/tests/integration/behaviors-scroll-canvas.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
}); | ||
}); | ||
}); |
Binary file added
BIN
+6.58 KB
packages/g6/tests/integration/snapshots/canvas/behaviors-scroll-canvas.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions
1
packages/g6/tests/integration/snapshots/svg/behaviors-scroll-canvas.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.