more unit tests

This commit is contained in:
Klemek
2019-07-16 11:40:33 +02:00
parent 5876a0d345
commit f299f7d96e
2 changed files with 143 additions and 33 deletions
+1 -1
View File
@@ -216,7 +216,7 @@ module.exports = (options) => {
},
'g': {
'_attributes': {
'transform': `scale(${scale / resources.height} ${scale / resources.height}) translate(${-icon.width / 2} ${-256})`,
'transform': `scale(${scale / resources.height} ${scale / resources.height}) translate(${-icon.width / 2} ${-resources.height / 2})`,
'stroke': (node['color'] || options['icons']['color'] || undefined),
'fill': (node['color'] || options['icons']['color'] || undefined)
},
+112 -2
View File
@@ -130,7 +130,6 @@ describe('getLinkPath (non-regression)', () => {
});
});
});
test('none', () => {
expect(rendering().getLinkPath('none', 1)).toEqual(null);
});
@@ -156,7 +155,118 @@ describe('getBounds', () => {
});
describe('renderNode', () => {
test('no icon', () => {
const res = rendering({'h-spacing': 1}).renderNode({
icon: '',
x: 2,
y: 1
});
expect(res).toBe(null);
});
test('simple icon', () => {
const res = rendering({'h-spacing': 1}).renderNode({
icon: 'circle',
x: 2,
y: 1
});
expect(res).toEqual({
'_attributes': {'transform': 'translate(2.5 1.5)'},
'g': {
'_attributes': {
'transform': 'scale(0.00078125 0.00078125) translate(-256 -256)',
'stroke': undefined,
'fill': undefined
},
'path': {'_attributes': {'d': solidCirclePath}}
}
});
});
test('icon recolor global', () => {
const res = rendering({
'h-spacing': 1,
'icons': {'color': 'green'}
}).renderNode({
icon: 'circle',
x: 2,
y: 1
});
expect(res).toEqual({
'_attributes': {'transform': 'translate(2.5 1.5)'},
'g': {
'_attributes': {
'transform': 'scale(0.00078125 0.00078125) translate(-256 -256)',
'stroke': 'green',
'fill': 'green'
},
'path': {'_attributes': {'d': solidCirclePath}}
}
});
});
test('icon recolor local', () => {
const res = rendering({
'h-spacing': 1,
'icons': {'color': 'green'}
}).renderNode({
icon: 'circle',
x: 2,
y: 1,
color: 'red'
});
expect(res).toEqual({
'_attributes': {'transform': 'translate(2.5 1.5)'},
'g': {
'_attributes': {
'transform': 'scale(0.00078125 0.00078125) translate(-256 -256)',
'stroke': 'red',
'fill': 'red'
},
'path': {'_attributes': {'d': solidCirclePath}}
}
});
});
test('icon scale global', () => {
const res = rendering({
'h-spacing': 1,
'icons': {'scale': 512 / 0.4}
}).renderNode({
icon: 'circle',
x: 2,
y: 1
});
expect(res).toEqual({
'_attributes': {'transform': 'translate(2.5 1.5)'},
'g': {
'_attributes': {
'transform': 'scale(1 1) translate(-256 -256)',
'stroke': undefined,
'fill': undefined
},
'path': {'_attributes': {'d': solidCirclePath}}
}
});
});
test('icon scale local', () => {
const res = rendering({
'h-spacing': 1,
'icons': {'scale': 512 / 0.4}
}).renderNode({
icon: 'circle',
x: 2,
y: 1,
scale: 1024 / 0.4
});
expect(res).toEqual({
'_attributes': {'transform': 'translate(2.5 1.5)'},
'g': {
'_attributes': {
'transform': 'scale(2 2) translate(-256 -256)',
'stroke': undefined,
'fill': undefined
},
'path': {'_attributes': {'d': solidCirclePath}}
}
});
});
});
describe('toXML', () => {