chore: remove consoles in tests

This commit is contained in:
Yanyan-Wang 2021-01-05 14:45:36 +08:00 committed by Yanyan Wang
parent 0b1344f2ab
commit f03dd62013
5 changed files with 54 additions and 57 deletions

View File

@ -118,19 +118,19 @@ describe('dragenter dragleave', () => {
graph.render();
it('dragenter', () => {
graph.on('node:dragenter', (e) => {
console.log('dragenter');
// console.log('dragenter');
});
graph.on('node:dragleave', (e) => {
console.log('dragleave');
// console.log('dragleave');
});
graph.on('node:mouseenter', (e) => {
console.log('mouseenter');
// console.log('mouseenter');
});
graph.on('node:mouseleave', (e) => {
console.log('mouseleave');
// console.log('mouseleave');
});
graph.on('node:dragover', (e) => {
console.log('dragover');
// console.log('dragover');
});
});
graph.destroy();

View File

@ -98,7 +98,7 @@ const Eva = () => {
}
});
});
console.log('原始数据', data.nodes.length, data.edges.length);
// console.log('原始数据', data.nodes.length, data.edges.length);
mapNodeSize(data.nodes, 'degree', [1, 15]);
// console.log(data.nodes);
graph.data(data);
@ -112,7 +112,7 @@ const Eva = () => {
graph.setItemState(item, 'hover', false);
});
console.log('图上数据大小', graph);
// console.log('图上数据大小', graph);
/* normalize */
// let cx = 0, cy = 0;

View File

@ -106,7 +106,7 @@ describe('find connected components', () => {
it('detect strongly connected components in undirected graph', () => {
let result = G6.Algorithm.connectedComponent(data, false);
console.log('result', result);
// console.log('result', result);
expect(result.length).toEqual(2);
expect(result[0].map((node) => node.id).sort()).toEqual(['A', 'B', 'C', 'D', 'E', 'F']);
expect(result[1].map((node) => node.id).sort()).toEqual(['G', 'H']);

View File

@ -117,21 +117,21 @@ describe('dragenter dragleave', () => {
graph.data(data);
graph.render();
it('dragenter', () => {
graph.on('node:dragenter', (e) => {
console.log('dragenter');
});
graph.on('node:dragleave', (e) => {
console.log('dragleave');
});
graph.on('node:mouseenter', (e) => {
console.log('mouseenter');
});
graph.on('node:mouseleave', (e) => {
console.log('mouseleave');
});
graph.on('node:dragover', (e) => {
console.log('dragover');
});
// graph.on('node:dragenter', (e) => {
// console.log('dragenter');
// });
// graph.on('node:dragleave', (e) => {
// console.log('dragleave');
// });
// graph.on('node:mouseenter', (e) => {
// console.log('mouseenter');
// });
// graph.on('node:mouseleave', (e) => {
// console.log('mouseleave');
// });
// graph.on('node:dragover', (e) => {
// console.log('dragover');
// });
});
graph.destroy();
});

View File

@ -15,10 +15,10 @@ describe('node state label update', () => {
type: 'rect',
labelCfg: {
style: {
fill: "rgb(49,158,236)",
fill: 'rgb(49,158,236)',
// fontSize: 12
},
position: "bottom"
position: 'bottom',
},
},
{
@ -29,20 +29,18 @@ describe('node state label update', () => {
type: 'rect',
labelCfg: {
style: {
fill: "rgb(49,158,236)",
fill: 'rgb(49,158,236)',
// fontSize: 12
},
position: "bottom"
position: 'bottom',
},
},
],
edges: [
{ source: 'node1', target: 'node2', label: 'edge' }
]
edges: [{ source: 'node1', target: 'node2', label: 'edge' }],
};
G6.registerNode(
"rect-img",
'rect-img',
{
afterDraw(cfg, item) {
// 添加图片
@ -51,17 +49,17 @@ describe('node state label update', () => {
_cfg.y = -cfg.size / 2;
_cfg.width = cfg.size;
_cfg.height = cfg.size;
item.addShape("image", {
item.addShape('image', {
attrs: _cfg,
draggable: true,
name: "image-shape"
name: 'image-shape',
});
},
update: undefined,
afterUpdate: undefined,
setItemState: undefined
setItemState: undefined,
},
"rect"
'rect',
);
it('label update', () => {
@ -73,45 +71,45 @@ describe('node state label update', () => {
hover: {},
selected: {
lineWidth: 3,
fill: "rgba(0,0,0,0)" //背景填充色
}
fill: 'rgba(0,0,0,0)', //背景填充色
},
},
});
graph.data(data);
graph.render();
graph.on('canvas:click', () => {
const node = graph.getNodes()[0]
const node = graph.getNodes()[0];
// model.labelCfg.style.fontSize = 50;
graph.updateItem(node, {
labelCfg: {
style: {
fontSize: 50
}
}
fontSize: 50,
},
},
});
const edge = graph.getEdges()[0]
const edge = graph.getEdges()[0];
graph.updateItem(edge, {
labelCfg: {
style: {
fontSize: 30
}
}
fontSize: 30,
},
},
});
})
graph.on('node:click', e => {
graph.setItemState(e.item, 'selected', !e.item.hasState("selected"));
});
graph.on('edge:click', e => {
graph.setItemState(e.item, 'selected', !e.item.hasState("selected"));
graph.on('node:click', (e) => {
graph.setItemState(e.item, 'selected', !e.item.hasState('selected'));
});
graph.on('edge:click', (e) => {
graph.setItemState(e.item, 'selected', !e.item.hasState('selected'));
});
const node = graph.getNodes()[0];
const edge = graph.getEdges()[0];
const nodeTextShape = node.getContainer().find(e => e.get('name') === 'text-shape');
const edgeTextShape = edge.getContainer().find(e => e.get('name') === 'text-shape');
const nodeTextShape = node.getContainer().find((e) => e.get('name') === 'text-shape');
const edgeTextShape = edge.getContainer().find((e) => e.get('name') === 'text-shape');
expect(edgeTextShape.attr('fontSize')).toBe(12);
graph.emit('canvas:click', {});
@ -130,7 +128,6 @@ describe('node state label update', () => {
});
});
describe('force layout', () => {
const data = {
// 点集
@ -191,9 +188,9 @@ describe('force layout', () => {
});
graph.on('canvas:click', () => {
console.log('canvas click');
// console.log('canvas click');
graph.getEdges().forEach((edge) => {
console.log('selected false');
// console.log('selected false');
graph.setItemState(edge, 'selected', false);
});
});
@ -293,6 +290,6 @@ describe('force layout', () => {
expect(text.attr('x')).toBe(250);
expect(text.attr('y')).toBe(200);
graph.destroy()
graph.destroy();
});
});