Add test for external link

pull/4136/head
Matt Westcott 2017-12-06 20:49:52 +00:00 zatwierdzone przez Thibaud Colas
rodzic ddc9ba30d2
commit 5660bb85f4
1 zmienionych plików z 20 dodań i 0 usunięć

Wyświetl plik

@ -139,6 +139,7 @@ class TestHtmlToContentState(TestCase):
},
]
})
def test_inline_styles_depend_on_features(self):
converter = ContentstateConverter(features=['italic', 'just-made-it-up'])
result = json.loads(converter.from_database_format(
@ -212,3 +213,22 @@ class TestHtmlToContentState(TestCase):
{'inlineStyleRanges': [], 'text': 'Eggs', 'depth': 0, 'type': 'unordered-list-item', 'key': '00000', 'entityRanges': []},
]
})
def test_external_link(self):
converter = ContentstateConverter(features=['link'])
result = json.loads(converter.from_database_format(
'''
<p>an <a href="http://wagtail.io">external</a> link</p>
'''
))
self.assertContentStateEqual(result, {
'entityMap': {
'0': {'mutability': 'MUTABLE', 'type': 'LINK', 'data': {'url': 'http://wagtail.io'}}
},
'blocks': [
{
'inlineStyleRanges': [], 'text': 'an external link', 'depth': 0, 'type': 'unstyled', 'key': '00000',
'entityRanges': [{'offset': 3, 'length': 8, 'key': 0}]
},
]
})