import Delta from 'quill-delta'; import Editor from '../../../core/editor'; describe('Color', function() { it('add', function() { const editor = this.initialize(Editor, '

0123

'); editor.formatText(1, 2, { color: 'red' }); expect(editor.getDelta()).toEqual( new Delta() .insert('0') .insert('12', { color: 'red' }) .insert('3\n'), ); expect(editor.scroll.domNode).toEqualHTML( '

0123

', ); }); it('remove', function() { const editor = this.initialize( Editor, '

0123

', ); editor.formatText(1, 2, { color: false }); const delta = new Delta() .insert('0') .insert('12', { bold: true }) .insert('3\n'); expect(editor.getDelta()).toEqual(delta); expect(editor.scroll.domNode).toEqualHTML('

0123

'); }); it('remove unwrap', function() { const editor = this.initialize( Editor, '

0123

', ); editor.formatText(1, 2, { color: false }); expect(editor.getDelta()).toEqual(new Delta().insert('0123\n')); expect(editor.scroll.domNode).toEqualHTML('

0123

'); }); it('invalid scope', function() { const editor = this.initialize(Editor, '

0123

'); const initial = editor.scroll.domNode.innerHTML; editor.formatText(4, 1, { color: 'red' }); expect(editor.getDelta()).toEqual(new Delta().insert('0123\n')); expect(editor.scroll.domNode).toEqualHTML(initial); }); });