add unit test for IText functions insertNewlineStyleObject and shiftLineStyles

This commit is contained in:
Milan Wanielik 2015-05-12 11:57:41 +02:00
parent c824c8a8da
commit 5259cdbb2e

View file

@ -274,6 +274,51 @@
equal(iText.text, 't\nt');
});
test('insertNewlineStyleObject', function() {
var iText = new fabric.IText('test\n');
equal(typeof iText.insertNewlineStyleObject, 'function');
iText.insertNewlineStyleObject(0, 4, true);
deepEqual(iText.styles, { '1': { '0': { } } });
});
test('shiftLineStyles', function() {
var iText = new fabric.IText('test\ntest\ntest', {
styles: {
'1': {
'0': { 'fill': 'red' },
'1': { 'fill': 'red' },
'2': { 'fill': 'red' },
'3': { 'fill': 'red' }
}
}
});
equal(typeof iText.shiftLineStyles, 'function');
iText.shiftLineStyles(0, +1);
deepEqual(iText.styles, {
'2': {
'0': { 'fill': 'red' },
'1': { 'fill': 'red' },
'2': { 'fill': 'red' },
'3': { 'fill': 'red' }
}
});
iText.shiftLineStyles(0, -1);
deepEqual(iText.styles, {
'1': {
'0': { 'fill': 'red' },
'1': { 'fill': 'red' },
'2': { 'fill': 'red' },
'3': { 'fill': 'red' }
}
});
});
test('selectWord', function() {
var iText = new fabric.IText('test foo bar-baz\nqux');