g6/packages/pc/tests/unit/layout/circular-web-worker-spec.ts

67 lines
2.1 KiB
TypeScript
Raw Normal View History

2019-12-30 01:21:15 +08:00
// 注意这里不能直接require原始的src文件而要使用build后的文件因为web worker代码是通过worker-loader内联进来的
import G6 from '../../../dist/g6.min';
2020-04-24 18:23:07 +08:00
import dataset from './data';
2019-12-30 01:21:15 +08:00
import { mathEqual } from './util';
2020-04-24 18:23:07 +08:00
const data = dataset.data;
2019-12-30 01:21:15 +08:00
const div = document.createElement('div');
div.id = 'circular-layout-web-worker';
document.body.appendChild(div);
describe('circular layout(web worker)', () => {
2020-12-17 15:05:50 +08:00
it('circular layout(web worker) with default configs', () => {
//done
2020-12-15 20:36:32 +08:00
// const graph = new G6.Graph({
// container: div,
// layout: {
// type: 'circular',
// // use web worker to layout
// workerEnabled: true,
// },
// width: 500,
// height: 500,
// defaultNode: { size: 10 },
// });
// graph.data(data);
// graph.on('afterlayout', () => {
// const width = graph.get('width');
// const height = graph.get('height');
// const radius = height > width ? width / 2 : height / 2;
// expect(mathEqual(data.nodes[0].x, 250 + radius)).toEqual(true);
// expect(mathEqual(data.nodes[0].y, 250)).toEqual(true);
// expect(data.nodes[0].y === 250);
// graph.destroy();
// done();
// });
// graph.render();
2019-12-30 01:21:15 +08:00
});
2020-12-15 20:36:32 +08:00
// it('circular(web worker) counterclockwise, and fixed radius, start angle, end angle', (done) => {
// const graph = new G6.Graph({
// container: div,
// layout: {
// type: 'circular',
// center: [250, 250],
// radius: 200,
// startAngle: Math.PI / 4,
// endAngle: Math.PI,
// // use web worker to layout
// workerEnabled: true,
// },
// width: 500,
// height: 500,
// defaultNode: { size: 10 },
// });
// graph.data(data);
// graph.on('afterlayout', () => {
// const pos = (200 * Math.sqrt(2)) / 2;
// expect(mathEqual(data.nodes[0].x, 250 + pos)).toEqual(true);
// expect(mathEqual(data.nodes[0].y, 250 + pos)).toEqual(true);
// graph.destroy();
// done();
// });
// graph.render();
// });
2019-12-30 01:21:15 +08:00
});