Beispiel #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'})
        ]
Beispiel #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)]
Beispiel #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)]
Beispiel #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})]
Beispiel #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})]
Beispiel #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)]
Beispiel #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)]
Beispiel #8
0
 def test_push_into_empty(self):
     delta = Delta()
     delta.push({'insert': 'test'})
     assert len(delta.ops) == 1