mirror of
https://github.com/Hopiu/fabric.js.git
synced 2026-05-28 14:58:16 +00:00
add unit test for IText functions insertNewlineStyleObject and shiftLineStyles
This commit is contained in:
parent
c824c8a8da
commit
5259cdbb2e
1 changed files with 45 additions and 0 deletions
|
|
@ -274,6 +274,51 @@
|
||||||
equal(iText.text, 't\nt');
|
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() {
|
test('selectWord', function() {
|
||||||
var iText = new fabric.IText('test foo bar-baz\nqux');
|
var iText = new fabric.IText('test foo bar-baz\nqux');
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue