-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Inlines tests; change feature.get_url and feature.get_full_url to cla…
…ssmethod
- Loading branch information
Showing
8 changed files
with
243 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
from .render import * | ||
from .attrs import * | ||
from .attrs import * | ||
from .inlines import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
from django.test import TestCase | ||
|
||
|
||
from .utils import BaseEditorJSTest | ||
from ..registry import ( | ||
InlineEditorJSFeature, | ||
EDITOR_JS_FEATURES, | ||
) | ||
|
||
import bs4 | ||
|
||
|
||
|
||
TESTING_HTML = """ | ||
<div class="editorjs"> | ||
<div class="editorjs-block" data-type="paragraph"> | ||
<p>Hello, World!</p> | ||
</div> | ||
<div class="editorjs-block" data-type="header"> | ||
<h1>Header</h1> | ||
</div> | ||
<div class="editorjs-block" data-type="list" data-testing-id="TARGET"> | ||
</div> | ||
<div class="editorjs-block" data-type="table"> | ||
<table> | ||
<tr> | ||
<td>1</td> | ||
<td>2</td> | ||
</tr> | ||
<tr> | ||
<td>3</td> | ||
<td>4</td> | ||
</tr> | ||
</table> | ||
</div> | ||
</div> | ||
""" | ||
|
||
|
||
class TestEditorJSInline(BaseEditorJSTest): | ||
def setUp(self): | ||
super().setUp() | ||
self.inlines = [ | ||
feature | ||
for feature in EDITOR_JS_FEATURES.features.values() | ||
if isinstance(feature, InlineEditorJSFeature) | ||
] | ||
|
||
def test_inlines(self): | ||
|
||
for feature in self.inlines: | ||
feature: InlineEditorJSFeature | ||
test_data = feature.get_test_data() | ||
|
||
if not test_data: | ||
continue | ||
|
||
soup = bs4.BeautifulSoup(TESTING_HTML, "html.parser") | ||
testing_block = soup.find("div", {"data-testing-id": "TARGET"}) | ||
testing_block.clear() | ||
|
||
for i, (initial, _) in enumerate(test_data): | ||
initial_soup = bs4.BeautifulSoup(initial, "html.parser") | ||
initial_soup.attrs["data-testing-id"] = f"test_{i}" | ||
testing_block.append(initial_soup) | ||
|
||
feature.parse_inline_data(soup) | ||
|
||
html = str(soup) | ||
|
||
outputs = [i[1] for i in test_data] | ||
for i, output in enumerate(outputs): | ||
self.assertInHTML( | ||
output, | ||
html | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.