Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import Canvas from '@antv/g-canvas/lib/canvas';
import '../../../src/shape/edge'
import '../../../src/shape/edges'
import Shape from '../../../src/shape/shape'
const div = document.createElement('div');
div.id = 'edge-shape';
document.body.appendChild(div);
const canvas = new Canvas({
container: 'edge-shape',
width: 600,
height: 600
});
describe('shape edge test', () => {
describe('basic method test', () => {
it('get factory', () => {
const factory = Shape.getFactory('edge');
expect(factory).not.toEqual(undefined);
});
it('get default', () => {
const factory = Shape.getFactory('edge');
const shape = factory.getShape();
expect(shape.type).toEqual('line');
});
import Shape from '../../../src/shape/shape'
import Global from '../../../src/global';
import Canvas from '@antv/g-canvas/lib/canvas';
import Node from '../../../src/item/node';
import { translate } from '../../../src/util/math'
import Graph from '../../../src/graph/graph'
import '../../../src/shape/node'
import '../../../src/shape/nodes'
import { IGroup } from '@antv/g-canvas/lib/interfaces';
const div = document.createElement('div');
div.id = 'node-shape';
document.body.appendChild(div);
const canvas = new Canvas({
container: 'node-shape',
width: 500,
height: 500
});
describe('shape node test', () => {
describe('basic method test', () => {
it('get factory', () => {
const factory = Shape.getFactory('node');
expect(factory).not.toBe(undefined);
});
it('get default', () => {
const factory = Shape.getFactory('node');
const shape = factory.getShape();
expect(shape.type).toBe('circle');
});
private initCanvas() {
let container: string | HTMLElement = this.get('container')
if(isString(container)) {
container = document.getElementById(container)
this.set('container', container)
}
if(!container) {
throw new Error('invalid container')
}
const width: number = this.get('width')
const height: number = this.get('height')
const pixelRatio: number = this.get('pixelRatio')
const canvas = new GCanvas({
container,
width,
height,
pixelRatio
})
this.set('canvas', canvas)
this.initGroups()
}