Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('node update, change shape', () => {
const group = new G.Group();
const node = new Node({
model: {
x: 100,
y: 100,
size: [ 20, 40 ],
shape: 'rect',
label: 'ni hao'
},
group
});
const shape = node.get('keyShape');
expect(shape.get('type')).eql('rect');
expect(shape.attr('width')).eql(20);
expect(group.attr('matrix')[6]).eql(100);
node.update({ shape: 'circle', size: 10, x: 50 });
const newShape = node.get('keyShape');
it('node update', () => {
const group = new G.Group();
const node = new Node({
model: {
x: 5,
y: 5,
size: [ 40, 20 ],
shape: 'rect',
label: 'ni hao'
},
group
});
const shape = group.get('children')[0];
expect(shape.attr('x')).eql(-20);
expect(group.attr('matrix')[6]).eql(5);
node.update({ x: 6, y: 10, size: [ 20, 20 ] });
expect(group.attr('matrix')[6]).eql(6);
it('new node and destroy', () => {
const group = new G.Group();
const node = new Node({
model: {
x: 100,
y: 100,
shape: 'circle'
},
group,
id: 'a'
});
expect(node.get('type')).eql('node');
const shape = group.get('children')[0];
expect(shape.attr('x')).eql(0);
expect(group.attr('matrix')[6]).eql(100);
expect(group.getCount()).eql(1);
node.destroy();
expect(node.destroyed).eql(true);
it('getLinkPointByAnchor', () => {
const group = new G.Group();
const node = new Node({
model: {
x: 100,
y: 100,
size: [ 20, 20 ],
shape: 'rect',
anchorPoints: [
[ 0.5, 0 ], [ 1, 0.5 ], [ 0.5, 1 ], [ 0, 0.5 ]
]
},
group
});
const point = node.getLinkPointByAnchor(0);
expect(snap(point.x, 100)).eql(true);
expect(snap(point.y, 89.5)).eql(true);
const Util = require('../../util');
const Group = require('@antv/g/lib').Group;
module.exports = Util.augment(Group, {
findByClassName(className) {
return this.find(function(shape) {
return shape.get('className') === className;
});
}
});
const Util = require('../../util');
const Group = require('@antv/g/lib').Group;
module.exports = Util.augment(Group, {
findByClassName(className) {
return this.find(function(shape) {
return shape.get('className') === className;
});
}
});