mirror of
https://github.com/Hopiu/fabric.js.git
synced 2026-04-05 15:01:01 +00:00
Fix majority of failing unit tests.
This commit is contained in:
parent
1f0b1280d4
commit
3ea4a4ad95
15 changed files with 72 additions and 48 deletions
2
dist/all.js
vendored
2
dist/all.js
vendored
|
|
@ -6082,7 +6082,7 @@ fabric.util.animate = animate;
|
|||
data = imageData.data,
|
||||
iLen = imageData.width,
|
||||
jLen = imageData.height,
|
||||
index, average;
|
||||
index, average, i, j;
|
||||
|
||||
for (i = 0; i < iLen; i++) {
|
||||
for (j = 0; j < jLen; j++) {
|
||||
|
|
|
|||
|
|
@ -2318,7 +2318,7 @@
|
|||
data = imageData.data,
|
||||
iLen = imageData.width,
|
||||
jLen = imageData.height,
|
||||
index, average;
|
||||
index, average, i, j;
|
||||
|
||||
for (i = 0; i < iLen; i++) {
|
||||
for (j = 0; j < jLen; j++) {
|
||||
|
|
|
|||
|
|
@ -62,7 +62,8 @@
|
|||
'flipX': false,
|
||||
'flipY': false,
|
||||
'opacity': 1,
|
||||
'radius': 0
|
||||
'radius': 0,
|
||||
'selectable': true
|
||||
};
|
||||
ok(typeof circle.toObject == 'function');
|
||||
same(circle.toObject(), defaultProperties);
|
||||
|
|
|
|||
|
|
@ -21,10 +21,10 @@
|
|||
|
||||
var PATH_DATALESS_JSON = '{"objects":[{"type":"path","left":100,"top":100,"width":200,"height":200,"fill":"rgb(0,0,0)",'+
|
||||
'"overlayFill":null,"stroke":null,"strokeWidth":1,"scaleX":1,"scaleY":1,"angle":0,"flipX":false,'+
|
||||
'"flipY":false,"opacity":1,"path":"http://example.com/"}],"background":"rgba(0, 0, 0, 0)"}';
|
||||
'"flipY":false,"opacity":1,"selectable":true,"path":"http://example.com/"}],"background":"rgba(0, 0, 0, 0)"}';
|
||||
|
||||
var RECT_JSON = '{"objects":[{"type":"rect","left":0,"top":0,"width":10,"height":10,"fill":"rgb(0,0,0)","overlayFill":null,'+
|
||||
'"stroke":null,"strokeWidth":1,"scaleX":1,"scaleY":1,"angle":0,"flipX":false,"flipY":false,"opacity":1}],'+
|
||||
'"stroke":null,"strokeWidth":1,"scaleX":1,"scaleY":1,"angle":0,"flipX":false,"flipY":false,"opacity":1,"selectable":true}],'+
|
||||
'"background":"#ff5555"}';
|
||||
|
||||
var canvas = this.canvas = new fabric.Element('test');
|
||||
|
|
@ -713,7 +713,7 @@
|
|||
ok(imgEl.width < ORIGINAL_WIDTH);
|
||||
|
||||
start();
|
||||
}, 2000);
|
||||
}, 1000);
|
||||
});
|
||||
|
||||
asyncTest('cache', function() {
|
||||
|
|
@ -763,7 +763,7 @@
|
|||
ok(/fixtures\/very_large_image\.jpg$/.test(objectPassedToCallback.getSrc()), 'image should have correct src');
|
||||
|
||||
start();
|
||||
}, 2000);
|
||||
}, 1000);
|
||||
});
|
||||
|
||||
asyncTest('fxRemove', function() {
|
||||
|
|
@ -783,7 +783,6 @@
|
|||
setTimeout(function() {
|
||||
equals(canvas.item(0), undefined);
|
||||
ok(callbackFired);
|
||||
|
||||
start();
|
||||
}, 1000);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -38,7 +38,8 @@
|
|||
'flipY': false,
|
||||
'opacity': 1,
|
||||
'rx': 0,
|
||||
'ry': 0
|
||||
'ry': 0,
|
||||
'selectable': true
|
||||
};
|
||||
ok(typeof ellipse.toObject == 'function');
|
||||
same(defaultProperties, ellipse.toObject());
|
||||
|
|
|
|||
|
|
@ -114,6 +114,7 @@
|
|||
ok(typeof group.toObject == 'function');
|
||||
|
||||
var clone = group.toObject();
|
||||
|
||||
var expectedObject = {
|
||||
'type': 'group',
|
||||
'left': 80,
|
||||
|
|
@ -126,6 +127,7 @@
|
|||
'strokeWidth': 1,
|
||||
'scaleX': 1,
|
||||
'scaleY': 1,
|
||||
'selectable': true,
|
||||
'angle': 0,
|
||||
'flipX': false,
|
||||
'flipY': false,
|
||||
|
|
@ -133,7 +135,8 @@
|
|||
'objects': clone.objects
|
||||
};
|
||||
|
||||
same(expectedObject, clone);
|
||||
console.log(clone, expectedObject);
|
||||
same(clone, expectedObject);
|
||||
|
||||
ok(group !== clone, 'should produce different object');
|
||||
ok(group.getObjects() !== clone.objects, 'should produce different object array');
|
||||
|
|
|
|||
|
|
@ -30,7 +30,8 @@
|
|||
'flipX': false,
|
||||
'flipY': false,
|
||||
'opacity': 1,
|
||||
'src': IMG_SRC
|
||||
'src': IMG_SRC,
|
||||
'selectable': true
|
||||
}
|
||||
|
||||
function _createImageObject(width, height) {
|
||||
|
|
|
|||
|
|
@ -19,7 +19,8 @@
|
|||
'x1': 11,
|
||||
'y1': 12,
|
||||
'x2': 13,
|
||||
'y2': 14
|
||||
'y2': 14,
|
||||
'selectable': true
|
||||
};
|
||||
|
||||
module('fabric.Line');
|
||||
|
|
|
|||
|
|
@ -364,7 +364,7 @@
|
|||
ok(image);
|
||||
ok(image instanceof fabric.Image);
|
||||
start();
|
||||
}, 1000);
|
||||
}, 500);
|
||||
|
||||
cObj.cloneAsImage(function(i) {
|
||||
image = i;
|
||||
|
|
|
|||
|
|
@ -16,7 +16,8 @@
|
|||
'flipX': false,
|
||||
'flipY': false,
|
||||
'opacity': 1,
|
||||
'path': [['M', 100, 100], ['L', 300, 100], ['L', 200, 300], ['z', NaN]]
|
||||
'path': [['M', 100, 100], ['L', 300, 100], ['L', 200, 300], ['z', NaN]],
|
||||
'selectable': true
|
||||
};
|
||||
|
||||
function getPathElement(path) {
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@
|
|||
'flipX': false,
|
||||
'flipY': false,
|
||||
'opacity': 1,
|
||||
'selectable': true,
|
||||
'paths': getPathObjects()
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,8 @@
|
|||
'flipX': false,
|
||||
'flipY': false,
|
||||
'opacity': 1,
|
||||
'points': getPoints()
|
||||
'points': getPoints(),
|
||||
'selectable': true
|
||||
};
|
||||
|
||||
module('fabric.Polygon');
|
||||
|
|
|
|||
|
|
@ -23,7 +23,8 @@
|
|||
'flipX': false,
|
||||
'flipY': false,
|
||||
'opacity': 1,
|
||||
'points': getPoints()
|
||||
'points': getPoints(),
|
||||
'selectable': true
|
||||
};
|
||||
|
||||
module('fabric.Polyline');
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@
|
|||
'type': 'rect',
|
||||
'left': 0,
|
||||
'top': 0,
|
||||
'width': 100,
|
||||
'height': 100,
|
||||
'width': 0,
|
||||
'height': 0,
|
||||
'fill': 'rgb(0,0,0)',
|
||||
'overlayFill': null,
|
||||
'stroke': null,
|
||||
|
|
@ -15,7 +15,8 @@
|
|||
'angle': 0,
|
||||
'flipX': false,
|
||||
'flipY': false,
|
||||
'opacity': 1
|
||||
'opacity': 1,
|
||||
'selectable': true
|
||||
};
|
||||
|
||||
module('fabric.Rect');
|
||||
|
|
|
|||
|
|
@ -1,34 +1,47 @@
|
|||
(function() {
|
||||
|
||||
function createTextObject() {
|
||||
return new fabric.Text('foo', {
|
||||
fontfamily: 'Modernist_One_400'
|
||||
});
|
||||
}
|
||||
|
||||
var REFERENCE_TEXT_OBJECT = {
|
||||
'type': 'text',
|
||||
'left': 10,
|
||||
'top': 10,
|
||||
'width': 100,
|
||||
'height': 100,
|
||||
'fill': 'rgb(0,0,0)',
|
||||
'overlayFill': null,
|
||||
'stroke': null,
|
||||
'strokeWidth': 1,
|
||||
'scaleX': 1,
|
||||
'scaleY': 1,
|
||||
'angle': 0,
|
||||
'flipX': false,
|
||||
'flipY': false,
|
||||
'opacity': 1,
|
||||
'text': 'foo',
|
||||
'fontsize': 20,
|
||||
'fontweight': 100,
|
||||
'fontfamily': 'Modernist_One_400',
|
||||
'path': null
|
||||
'type': 'text',
|
||||
'left': 0,
|
||||
'top': 0,
|
||||
'width': 0,
|
||||
'height': 0,
|
||||
'fill': 'rgb(0,0,0)',
|
||||
'overlayFill': null,
|
||||
'stroke': null,
|
||||
'strokeWidth': 1,
|
||||
'scaleX': 1,
|
||||
'scaleY': 1,
|
||||
'angle': 0,
|
||||
'flipX': false,
|
||||
'flipY': false,
|
||||
'opacity': 1,
|
||||
'selectable': true,
|
||||
'text': 'foo',
|
||||
'fontsize': 20,
|
||||
'fontweight': 100,
|
||||
'fontfamily': 'Modernist_One_400',
|
||||
"lineHeight": 1,
|
||||
"textDecoration": '',
|
||||
"textShadow": null,
|
||||
"strokeStyle": '',
|
||||
"fontStyle": '',
|
||||
"path": null
|
||||
};
|
||||
|
||||
module('fabric.Text');
|
||||
|
||||
test('constructor', function() {
|
||||
ok(fabric.Text);
|
||||
var text = new fabric.Text('foo');
|
||||
var text = createTextObject();
|
||||
|
||||
ok(text);
|
||||
ok(text instanceof fabric.Text);
|
||||
ok(text instanceof fabric.Object);
|
||||
|
||||
|
|
@ -37,51 +50,51 @@
|
|||
});
|
||||
|
||||
test('toString', function() {
|
||||
var text = new fabric.Text('foo');
|
||||
var text = createTextObject();
|
||||
ok(typeof text.toString == 'function');
|
||||
equals(text.toString(), '#<fabric.Text (0): {"text":"foo","fontfamily":"Modernist_One_400"}>');
|
||||
});
|
||||
|
||||
test('toObject', function() {
|
||||
var text = new fabric.Text('foo');
|
||||
var text = createTextObject();
|
||||
ok(typeof text.toObject == 'function');
|
||||
same(text.toObject(), REFERENCE_TEXT_OBJECT);
|
||||
});
|
||||
|
||||
test('complexity', function(){
|
||||
var text = new fabric.Text('foo');
|
||||
var text = createTextObject();
|
||||
ok(typeof text.complexity == 'function');
|
||||
});
|
||||
|
||||
test('set', function() {
|
||||
var text = new fabric.Text('foo');
|
||||
var text = createTextObject();
|
||||
ok(typeof text.set == 'function');
|
||||
equals(text.set('text', 'bar'), text, 'should be chainable');
|
||||
});
|
||||
|
||||
test('setColor', function(){
|
||||
var text = new fabric.Text('foo');
|
||||
var text = createTextObject();
|
||||
ok(typeof text.setColor == 'function');
|
||||
equals(text.setColor('123456'), text, 'should be chainable');
|
||||
equals(text.get('fill'), '123456');
|
||||
});
|
||||
|
||||
test('setFontsize', function(){
|
||||
var text = new fabric.Text('foo');
|
||||
var text = createTextObject();
|
||||
ok(typeof text.setFontsize == 'function');
|
||||
equals(text.setFontsize(12), text);
|
||||
equals(text.get('fontsize'), 12);
|
||||
});
|
||||
|
||||
test('getText', function(){
|
||||
var text = new fabric.Text('foo');
|
||||
var text = createTextObject();
|
||||
ok(typeof text.getText == 'function');
|
||||
equals(text.getText(), 'foo');
|
||||
equals(text.getText(), text.get('text'));
|
||||
});
|
||||
|
||||
test('setText', function(){
|
||||
var text = new fabric.Text('foo');
|
||||
var text = createTextObject();
|
||||
ok(typeof text.setText == 'function');
|
||||
equals(text.setText('bar'), text, 'should be chainable');
|
||||
equals(text.getText(), 'bar');
|
||||
|
|
|
|||
Loading…
Reference in a new issue