Example #1
0
 def test_render_entities_inline_multiple(self):
     self.entity_state.apply(Command('start_entity', 0, '0'))
     self.entity_state.render_entities('Test 1', {}, [])
     self.entity_state.apply(Command('stop_entity', 5, '0'))
     self.entity_state.apply(Command('start_entity', 5, '2'))
     self.assertEqual(DOM.render_debug(self.entity_state.render_entities('Test text', {}, [])), '<a href="http://example.com">Test 1</a>')
     self.entity_state.render_entities('Test 2', {}, [])
     self.entity_state.apply(Command('stop_entity', 10, '2'))
     self.assertEqual(DOM.render_debug(self.entity_state.render_entities('Test text', {}, [])), '<a href="http://test.com"><fragment>Test textTest 2</fragment></a>')
 def test_render_styles_styled(self):
     self.style_state.apply(Command('start_inline_style', 0, 'ITALIC'))
     self.assertEqual(
         DOM.render_debug(
             self.style_state.render_styles('Test text', {}, [])),
         '<em>Test text</em>')
     self.style_state.apply(Command('stop_inline_style', 9, 'ITALIC'))
 def test_render_styles_styled_multiple(self):
     self.style_state.apply(Command('start_inline_style', 0, 'BOLD'))
     self.style_state.apply(Command('start_inline_style', 0, 'ITALIC'))
     self.assertEqual(
         DOM.render_debug(
             self.style_state.render_styles('Test text', {}, [])),
         '<strong><em>Test text</em></strong>')
 def test_render_styles_attributes(self):
     self.style_state.apply(Command('start_inline_style', 0, 'KBD'))
     self.assertEqual(
         DOM.render_debug(
             self.style_state.render_styles('Test text', {}, [])),
         '<kbd class="o-keyboard-shortcut">Test text</kbd>')
     self.style_state.apply(Command('stop_inline_style', 9, 'KBD'))
 def test_render_styles_component(self):
     self.style_state.apply(Command('start_inline_style', 0, 'IMPORTANT'))
     self.assertEqual(
         DOM.render_debug(
             self.style_state.render_styles('Test text', {}, [])),
         '<strong style="color: red;">Test text</strong>')
     self.style_state.apply(Command('stop_inline_style', 9, 'IMPORTANT'))
Example #6
0
 def test_create_element(self):
     self.assertEqual(
         DOM.render_debug(
             DOM.create_element("p", {"class": "intro"}, "Test test")
         ),
         '<p class="intro">Test test</p>',
     )
Example #7
0
 def test_create_element_none(self):
     self.assertEqual(
         DOM.render_debug(
             DOM.create_element('a', {}, None,
                                DOM.create_element('span', {},
                                                   'Test test'))),
         '<a><span>Test test</span></a>')
Example #8
0
 def test_render_debug(self):
     self.assertEqual(
         DOM.render_debug(
             DOM.create_element(list_item, {"block": {"depth": 5}}, "Test")
         ),
         '<li class="list-item--depth-5">Test</li>',
     )
Example #9
0
 def test_render_debug(self):
     self.assertEqual(DOM.render_debug(DOM.create_element(blockquote, {
         'block': {
             'data': {
                 'cite': 'http://example.com/',
             },
         },
     }, 'Test')), '<blockquote cite="http://example.com/">Test</blockquote>')
 def test_render_styles_styled(self):
     self.style_state.apply(Command("start_inline_style", 0, "ITALIC"))
     self.assertEqual(
         DOM.render_debug(
             self.style_state.render_styles("Test text", {}, [])),
         "<em>Test text</em>",
     )
     self.style_state.apply(Command("stop_inline_style", 9, "ITALIC"))
 def test_render_styles_attributes(self):
     self.style_state.apply(Command("start_inline_style", 0, "KBD"))
     self.assertEqual(
         DOM.render_debug(
             self.style_state.render_styles("Test text", {}, [])),
         '<kbd class="o-keyboard-shortcut">Test text</kbd>',
     )
     self.style_state.apply(Command("stop_inline_style", 9, "KBD"))
Example #12
0
 def test_create_element_none(self):
     self.assertEqual(
         DOM.render_debug(
             DOM.create_element("a", {}, None,
                                DOM.create_element("span", {},
                                                   "Test test"))),
         "<a><span>Test test</span></a>",
     )
 def test_render_styles_styled_multiple(self):
     self.style_state.apply(Command("start_inline_style", 0, "BOLD"))
     self.style_state.apply(Command("start_inline_style", 0, "ITALIC"))
     self.assertEqual(
         DOM.render_debug(
             self.style_state.render_styles("Test text", {}, [])),
         "<strong><em>Test text</em></strong>",
     )
Example #14
0
 def test_render_entities_inline_multiple(self):
     self.entity_state.apply(Command("start_entity", 0, "0"))
     self.entity_state.render_entities("Test 1", {}, [])
     self.entity_state.apply(Command("stop_entity", 5, "0"))
     self.entity_state.apply(Command("start_entity", 5, "2"))
     self.assertEqual(
         DOM.render_debug(
             self.entity_state.render_entities("Test text", {}, [])),
         '<a href="http://example.com">Test 1</a>',
     )
     self.entity_state.render_entities("Test 2", {}, [])
     self.entity_state.apply(Command("stop_entity", 10, "2"))
     self.assertEqual(
         DOM.render_debug(
             self.entity_state.render_entities("Test text", {}, [])),
         '<a href="http://test.com"><fragment>Test textTest 2</fragment></a>',
     )
Example #15
0
 def test_render_debug(self):
     self.assertEqual(
         DOM.render_debug(
             DOM.create_element(list_item, {
                 'block': {
                     'depth': 5,
                 },
             }, 'Test')), '<li class="list-item--depth-5">Test</li>')
 def test_render_styles_component(self):
     self.style_state.apply(Command("start_inline_style", 0, "IMPORTANT"))
     self.assertEqual(
         DOM.render_debug(
             self.style_state.render_styles("Test text", {}, [])),
         '<strong style="color: red;">Test text</strong>',
     )
     self.style_state.apply(Command("stop_inline_style", 9, "IMPORTANT"))
Example #17
0
 def test_create_element_style_str(self):
     self.assertEqual(
         DOM.render_debug(
             DOM.create_element(
                 'p',
                 {'style': 'border-color: red;text-decoration: underline;'},
                 'Test test')),
         '<p style="border-color: red;text-decoration: underline;">Test test</p>'
     )
Example #18
0
 def test_element_for_element_content(self):
     self.assertEqual(DOM.render_debug(self.wrapper_state.element_for({
         'key': '5s7g9',
         'text': 'Paragraph',
         'type': 'unstyled',
         'depth': 0,
         'inlineStyleRanges': [],
         'entityRanges': []
     }, DOM.create_element('strong', {}, 'Paragraph'))), '<div><strong>Paragraph</strong></div>')
Example #19
0
 def test_element_for_dismiss_content(self):
     self.assertEqual(DOM.render_debug(self.wrapper_state.element_for({
         'key': '5s7g9',
         'text': 'Paragraph',
         'type': 'ignore',
         'depth': 0,
         'inlineStyleRanges': [],
         'entityRanges': []
     }, DOM.create_element('img', {'src': '/example.png'}))), '<fragment></fragment>')
Example #20
0
 def test_element_for_no_block(self):
     self.assertEqual(DOM.render_debug(self.wrapper_state.element_for({
         'key': '5s7g9',
         'text': 'Paragraph',
         'type': 'atomic',
         'depth': 0,
         'inlineStyleRanges': [],
         'entityRanges': []
     }, DOM.create_element('img', {'src': '/example.png'}))), '<img src="/example.png"/>')
Example #21
0
 def test_render_entities_inline(self):
     self.entity_state.apply(Command("start_entity", 0, "0"))
     self.entity_state.render_entities("Test text", {}, [])
     self.entity_state.apply(Command("stop_entity", 9, "0"))
     self.assertEqual(
         DOM.render_debug(
             self.entity_state.render_entities("Test text", {}, [])),
         '<a href="http://example.com">Test text</a>',
     )
Example #22
0
 def test_str_elts(self):
     self.assertEqual(DOM.render_debug(self.wrapper_state.element_for({
         'key': '5s7g9',
         'text': 'Header',
         'type': 'header-one',
         'depth': 0,
         'inlineStyleRanges': [],
         'entityRanges': []
     }, '')), '<h1></h1>')
 def test_render_styles_component_multiple(self):
     self.style_state.apply(Command('start_inline_style', 0, 'IMPORTANT'))
     self.style_state.apply(Command('start_inline_style', 0, 'SHOUT'))
     self.assertEqual(
         DOM.render_debug(
             self.style_state.render_styles('Test text', {}, [])),
         '<strong style="color: red;"><span style="text-transform: uppercase;">Test text</span></strong>'
     )
     self.style_state.apply(Command('stop_inline_style', 9, 'IMPORTANT'))
     self.style_state.apply(Command('stop_inline_style', 9, 'SHOUT'))
Example #24
0
 def test_element_for_component_wrapper(self):
     self.assertEqual(DOM.render_debug(self.wrapper_state.element_for({
         'key': '5s7g9',
         'text': 'Test',
         'type': 'ordered-list-item',
         'depth': 0,
         'data': {},
         'inlineStyleRanges': [],
         'entityRanges': []
     }, 'Test')), '<ol class="list--depth-0"><li class="list-item--depth-0">Test</li></ol>')
 def test_render_styles_component_multiple_invert(self):
     self.style_state.apply(Command("start_inline_style", 0, "SHOUT"))
     self.style_state.apply(Command("start_inline_style", 0, "IMPORTANT"))
     self.assertEqual(
         DOM.render_debug(
             self.style_state.render_styles("Test text", {}, [])),
         '<strong style="color: red;"><span style="text-transform: uppercase;">Test text</span></strong>',
     )
     self.style_state.apply(Command("stop_inline_style", 9, "SHOUT"))
     self.style_state.apply(Command("stop_inline_style", 9, "IMPORTANT"))
Example #26
0
 def test_create_element_style_str(self):
     self.assertEqual(
         DOM.render_debug(
             DOM.create_element(
                 "p",
                 {"style": "border-color: red;text-decoration: underline;"},
                 "Test test",
             )),
         '<p style="border-color: red;text-decoration: underline;">Test test</p>',
     )
Example #27
0
 def test_render_debug(self):
     self.assertEqual(
         DOM.render_debug(
             DOM.create_element(
                 blockquote,
                 {"block": {"data": {"cite": "http://example.com/"}}},
                 "Test",
             )
         ),
         '<blockquote cite="http://example.com/">Test</blockquote>',
     )
Example #28
0
 def test_create_element_style_dict(self):
     self.assertEqual(
         DOM.render_debug(
             DOM.create_element('p', {
                 'style': {
                     'borderColor': 'red',
                     'textDecoration': 'underline'
                 }
             }, 'Test test')),
         '<p style="border-color: red;text-decoration: underline;">Test test</p>'
     )
Example #29
0
 def test_element_for_component(self):
     self.assertEqual(DOM.render_debug(self.wrapper_state.element_for({
         'key': '5s7g9',
         'text': 'Paragraph',
         'type': 'blockquote',
         'depth': 0,
         'data': {
             'cite': 'http://example.com/',
         },
         'inlineStyleRanges': [],
         'entityRanges': []
     }, 'Test')), '<blockquote cite="http://example.com/">Test</blockquote>')
Example #30
0
 def test_create_element_style_dict(self):
     self.assertEqual(
         DOM.render_debug(
             DOM.create_element(
                 "p",
                 {
                     "style": {
                         "borderColor": "red",
                         "textDecoration": "underline",
                     }
                 },
                 "Test test",
             )),
         '<p style="border-color: red;text-decoration: underline;">Test test</p>',
     )
 def test_render_code_block(self):
     self.assertEqual(DOM.render_debug(code_block({'children': 'test'})), '<pre><code>test</code></pre>')
 def test_render_styles_attributes(self):
     self.style_state.apply(Command('start_inline_style', 0, 'KBD'))
     self.assertEqual(DOM.render_debug(self.style_state.render_styles('Test text', {}, [])), '<kbd class="o-keyboard-shortcut">Test text</kbd>')
     self.style_state.apply(Command('stop_inline_style', 9, 'KBD'))
 def test_render_styles_styled_multiple(self):
     self.style_state.apply(Command('start_inline_style', 0, 'BOLD'))
     self.style_state.apply(Command('start_inline_style', 0, 'ITALIC'))
     self.assertEqual(DOM.render_debug(self.style_state.render_styles('Test text', {}, [])), '<strong><em>Test text</em></strong>')
Example #34
0
 def test_create_element_none(self):
     self.assertEqual(DOM.render_debug(DOM.create_element('a', {}, None, DOM.create_element('span', {}, 'Test test'))), '<a><span>Test test</span></a>')
 def test_render_styles_component(self):
     self.style_state.apply(Command('start_inline_style', 0, 'IMPORTANT'))
     self.assertEqual(DOM.render_debug(self.style_state.render_styles('Test text', {}, [])), '<strong style="color: red;">Test text</strong>')
     self.style_state.apply(Command('stop_inline_style', 9, 'IMPORTANT'))
 def test_render_styles_component_multiple_invert(self):
     self.style_state.apply(Command('start_inline_style', 0, 'SHOUT'))
     self.style_state.apply(Command('start_inline_style', 0, 'IMPORTANT'))
     self.assertEqual(DOM.render_debug(self.style_state.render_styles('Test text', {}, [])), '<strong style="color: red;"><span style="text-transform: uppercase;">Test text</span></strong>')
     self.style_state.apply(Command('stop_inline_style', 9, 'SHOUT'))
     self.style_state.apply(Command('stop_inline_style', 9, 'IMPORTANT'))
Example #37
0
 def test_render_debug(self):
     self.assertEqual(DOM.render_debug(
         DOM.create_element('a', {}, DOM.create_element('span', {'class': 'file-info icon-text'}, DOM.create_element('span', {'class': 'icon-text__text'}, 'Test test'), DOM.create_element('svg', {'class': 'icon'}, DOM.create_element('use', {'xlink:href': '#icon-test'}))))
     ), '<a><span class="file-info icon-text"><span class="icon-text__text">Test test</span><svg class="icon"><use xlink:href="#icon-test"></use></svg></span></a>')
Example #38
0
 def test_append_child(self):
     parent = DOM.create_element('p')
     DOM.append_child(parent, DOM.create_element('span', {}, 'Test text'))
     self.assertEqual(DOM.render_debug(parent), '<p><span>Test text</span></p>')
Example #39
0
 def test_create_element_style_str(self):
     self.assertEqual(DOM.render_debug(DOM.create_element('p', {'style': 'border-color: red;text-decoration: underline;'}, 'Test test')), '<p style="border-color: red;text-decoration: underline;">Test test</p>')
Example #40
0
 def test_create_element_entity(self):
     self.assertEqual(DOM.render_debug(DOM.create_element(icon, {'name': 'rocket'})), '<svg class="icon"><use xlink:href="#icon-rocket"></use></svg>')
Example #41
0
 def test_create_element_empty(self):
     self.assertEqual(DOM.render_debug(DOM.create_element()), '<fragment></fragment>')
Example #42
0
 def test_create_element(self):
     self.assertEqual(DOM.render_debug(DOM.create_element('p', {'class': 'intro'}, 'Test test')), '<p class="intro">Test test</p>')
Example #43
0
 def test_parse_html(self):
     self.assertEqual(DOM.render_debug(DOM.parse_html('<p><span>Test text</span></p>')), '<p><span>Test text</span></p>')
Example #44
0
 def test_create_element_style_dict(self):
     self.assertEqual(DOM.render_debug(DOM.create_element('p', {'style': {'borderColor': 'red', 'textDecoration': 'underline'}}, 'Test test')), '<p style="border-color: red;text-decoration: underline;">Test test</p>')
 def test_render_styles_styled(self):
     self.style_state.apply(Command('start_inline_style', 0, 'ITALIC'))
     self.assertEqual(DOM.render_debug(self.style_state.render_styles('Test text', {}, [])), '<em>Test text</em>')
     self.style_state.apply(Command('stop_inline_style', 9, 'ITALIC'))