Beispiel #1
0
 def test_rich_text_with_custom_features(self):
     # feature list doesn't allow <h2>, so it should become an unstyled paragraph block
     result = rich_text("<h2>title</h2><p>para</p>", features=["p"])
     self.assertTrue(
         content_state_equal(
             json.loads(result),
             {
                 "entityMap": {},
                 "blocks": [
                     {
                         "inlineStyleRanges": [],
                         "text": "title",
                         "depth": 0,
                         "type": "unstyled",
                         "key": "00000",
                         "entityRanges": [],
                     },
                     {
                         "inlineStyleRanges": [],
                         "text": "para",
                         "depth": 0,
                         "type": "unstyled",
                         "key": "00000",
                         "entityRanges": [],
                     },
                 ],
             },
         ))
Beispiel #2
0
 def test_default_rich_text(self):
     result = rich_text("<h2>title</h2><p>para</p>")
     self.assertTrue(
         content_state_equal(
             json.loads(result),
             {
                 "entityMap": {},
                 "blocks": [
                     {
                         "inlineStyleRanges": [],
                         "text": "title",
                         "depth": 0,
                         "type": "header-two",
                         "key": "00000",
                         "entityRanges": [],
                     },
                     {
                         "inlineStyleRanges": [],
                         "text": "para",
                         "depth": 0,
                         "type": "unstyled",
                         "key": "00000",
                         "entityRanges": [],
                     },
                 ],
             },
         ))
Beispiel #3
0
 def test_default_rich_text(self):
     result = rich_text('<h2>title</h2><p>para</p>')
     self.assertTrue(content_state_equal(
         json.loads(result),
         {
             'entityMap': {},
             'blocks': [
                 {'inlineStyleRanges': [], 'text': 'title', 'depth': 0, 'type': 'header-two', 'key': '00000', 'entityRanges': []},
                 {'inlineStyleRanges': [], 'text': 'para', 'depth': 0, 'type': 'unstyled', 'key': '00000', 'entityRanges': []},
             ]
         }
     ))
Beispiel #4
0
 def test_rich_text_with_custom_features(self):
     # feature list doesn't allow <h2>, so it should become an unstyled paragraph block
     result = rich_text('<h2>title</h2><p>para</p>', features=['p'])
     self.assertTrue(content_state_equal(
         json.loads(result),
         {
             'entityMap': {},
             'blocks': [
                 {'inlineStyleRanges': [], 'text': 'title', 'depth': 0, 'type': 'unstyled', 'key': '00000', 'entityRanges': []},
                 {'inlineStyleRanges': [], 'text': 'para', 'depth': 0, 'type': 'unstyled', 'key': '00000', 'entityRanges': []},
             ]
         }
     ))