def inst_ops(self): return [ Insert('abc', None), Retain(1, {'color': 'red'}), Delete(4), Insert('def', {'bold': True}), Retain(6, None) ]
def test_delta_chain(self): delta = (Delta().insert('Hello').insert({ 'image': True }).insert('World')) assert delta.ops == [ Insert('Hello', None), Insert({'image': True}, None), Insert('World', None), ]
def test_delta_delete_text(self): delta = (Delta().insert('foo').insert(' ').insert('bar')) assert delta.ops == [Insert('foo bar', None)] delta = delta.delete(2).delete(2) delta.insert(' ') delta.insert('baz') assert delta.ops == [Insert('foo bar baz', None), Delete(4)]
def test_push_consecutive_embeds_with_matching_attributes(self): delta = Delta().insert(1, {'alt': 'Description'}) delta.push({ 'insert': { 'url': 'http://quilljs.com' }, 'attributes': { 'alt': 'Description' } }) assert len(delta.ops) == 2 assert delta.ops == [ Insert(1, {'alt': 'Description'}), Insert({'url': 'http://quilljs.com'}, {'alt': 'Description'}) ]
def test_insert_embed_non_integer(self): value = {'url': 'https://quilljs.com'} attrs = {'alt': 'Quill'} delta = Delta().insert(value, attrs) assert len(delta.ops) == 1 assert delta.ops == [Insert(value, attrs)]
def test_delta_insert_text(self): delta = Delta() assert delta.ops == [] delta = (delta.insert('Hello', None).insert(' ', None).insert('World!', None)) assert len(delta.ops) == 1, delta.ops assert delta.ops == [Insert('Hello World!', None)] delta.insert('\n', None) delta.insert('Hello World', None) delta.insert('!', None) assert len(delta.ops) == 1, delta.ops assert delta.ops == [Insert('Hello World!\nHello World!', None)]
def test_insert_text_none(self): delta = Delta().insert('test', None) assert len(delta.ops) == 1 assert delta.ops == [Insert('test', None)]
def test_push_consecutive_text_with_not_matching_attributes(self): delta = Delta().insert('a', {'bold': True}) delta.push({'insert': 'b'}) assert len(delta.ops) == 2 assert delta.ops == [Insert('a', {'bold': True}), Insert('b', None)]
def test_push_consecutive_text_with_matching_attributes(self): delta = Delta().insert('a', {'bold': True}) delta.push({'insert': 'b', 'attributes': {'bold': True}}) assert len(delta.ops) == 1 assert delta.ops == [Insert('ab', {'bold': True})]
def test_push_consecutive_text(self): delta = Delta().insert('a') delta.push({'insert': 'b'}) assert len(delta.ops) == 1 assert delta.ops == [Insert('ab', None)]
def test_insert_text_attributes(self): delta = Delta().insert('test', {'bold': True}) assert len(delta.ops) == 1 assert delta.ops == [Insert('test', {'bold': True})]
def test_insert_embed_attributes(self): obj = {'url': 'https://quilljs.com', 'alt': 'Quill'} delta = Delta().insert(1, obj) assert len(delta.ops) == 1 assert delta.ops == [Insert(1, obj)]
def test_insert_embed(self): delta = Delta().insert(1) assert len(delta.ops) == 1 assert delta.ops == [Insert(1, None)]