Fix failing unit tests.

This commit is contained in:
Jürg Lehni 2016-02-15 09:21:11 +01:00
parent 08e51b5ca4
commit 3d330da4fc
3 changed files with 34 additions and 31 deletions

View file

@ -411,7 +411,7 @@ new function() {
? new Rectangle([0, 0], view.getViewSize()) ? new Rectangle([0, 0], view.getViewSize())
: bounds === 'content' : bounds === 'content'
? Item._getBounds(children, matrix, { stroke: true }) ? Item._getBounds(children, matrix, { stroke: true })
: Rectangle.read([bounds], 0, { readNull: true }); : Rectangle.read([bounds], 0, { readNull: true }),
attrs = { attrs = {
version: '1.1', version: '1.1',
xmlns: SvgElement.svg, xmlns: SvgElement.svg,

View file

@ -472,7 +472,7 @@ var compareSVG = function(done, actual, expected, message, options) {
? item ? item
: typeof item === 'string' : typeof item === 'string'
? new Raster({ ? new Raster({
source: 'data:image/svg+xml;base64,' + btoa(item), source: 'data:image/svg+xml;base64,' + window.btoa(item),
insert: false insert: false
}) })
: null; : null;

View file

@ -113,36 +113,39 @@ test('Export SVG path at precision 0', function() {
equals(path.exportSVG({ precision: 0 }).getAttribute('d'), 'M0,2l1,1'); equals(path.exportSVG({ precision: 0 }).getAttribute('d'), 'M0,2l1,1');
}); });
test('Export transformed shapes', function(assert) { if (!isNode) {
var rect = new Shape.Rectangle({ // JSDom does not have SVG rendering, so we can't test there.
point: [200, 100], test('Export transformed shapes', function(assert) {
size: [200, 300], var rect = new Shape.Rectangle({
fillColor: 'red' point: [200, 100],
}); size: [200, 300],
rect.rotate(40); fillColor: 'red'
});
rect.rotate(40);
var circle = new Shape.Circle({ var circle = new Shape.Circle({
center: [200, 300], center: [200, 300],
radius: 100, radius: 100,
fillColor: 'green' fillColor: 'green'
}); });
circle.scale(0.5, 1); circle.scale(0.5, 1);
circle.rotate(40); circle.rotate(40);
var ellipse = new Shape.Ellipse({ var ellipse = new Shape.Ellipse({
point: [300, 300], point: [300, 300],
size: [100, 200], size: [100, 200],
fillColor: 'blue' fillColor: 'blue'
}); });
ellipse.rotate(-40); ellipse.rotate(-40);
var rect = new Shape.Rectangle({ var rect = new Shape.Rectangle({
point: [250, 20], point: [250, 20],
size: [200, 300], size: [200, 300],
radius: [40, 20], radius: [40, 20],
fillColor: 'yellow' fillColor: 'yellow'
});
rect.rotate(-20);
var svg = project.exportSVG({ bounds: 'content', asString: true });
compareSVG(assert.async(), svg, project.activeLayer);
}); });
rect.rotate(-20); }
var svg = project.exportSVG({ bounds: 'content', asString: true });
compareSVG(assert.async(), svg, project.activeLayer);
});