Exemplo n.º 1
0
    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'})
        ]
Exemplo n.º 2
0
    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)]
Exemplo n.º 3
0
    def test_push_consecutive_retain_with_not_matching_attributes(self):
        delta = Delta().retain(1, {'bold': True})
        delta.push({'retain': 3})

        assert len(delta.ops) == 2
        assert delta.ops == [Retain(1, {'bold': True}), Retain(3, None)]
Exemplo n.º 4
0
    def test_push_consecutive_retain_with_matching_attributes(self):
        delta = Delta().retain(1, {'bold': True})
        delta.push({'retain': 3, 'attributes': {'bold': True}})

        assert len(delta.ops) == 1
        assert delta.ops == [Retain(4, {'bold': True})]
Exemplo n.º 5
0
    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})]
Exemplo n.º 6
0
    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)]
Exemplo n.º 7
0
    def test_push_consecutive_delete(self):
        delta = Delta().delete(2)
        delta.push({'delete': 3})

        assert len(delta.ops) == 1
        assert delta.ops == [Delete(5)]
Exemplo n.º 8
0
 def test_push_into_empty(self):
     delta = Delta()
     delta.push({'insert': 'test'})
     assert len(delta.ops) == 1