forked from zauberzeug/nicegui
-
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.
zauberzeug#228 add markdown and mermaid tests
- Loading branch information
1 parent
ced4b0f
commit ed05443
Showing
2 changed files
with
65 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
from nicegui import ui | ||
|
||
from .screen import Screen | ||
|
||
|
||
def test_markdown(screen: Screen): | ||
m = ui.markdown('This is **markdown**') | ||
|
||
screen.open('/') | ||
element = screen.find('This is') | ||
assert element.text == 'This is markdown' | ||
assert element.get_attribute('innerHTML') == 'This is <strong>markdown</strong>' | ||
|
||
m.set_content('New **content**') | ||
element = screen.find('New') | ||
assert element.text == 'New content' | ||
assert element.get_attribute('innerHTML') == 'New <strong>content</strong>' | ||
|
||
|
||
def test_markdown_with_mermaid(screen: Screen): | ||
m = ui.markdown(''' | ||
Mermaid: | ||
```mermaid | ||
graph TD; | ||
Node_A --> Node_B; | ||
``` | ||
''', extras=['mermaid', 'fenced-code-blocks']) | ||
|
||
screen.open('/') | ||
screen.should_contain('Mermaid') | ||
assert screen.find_by_tag('svg').get_attribute('id') == f'mermaid_{m.id}_0' | ||
assert screen.find('Node_A').get_attribute('class') == 'nodeLabel' | ||
|
||
m.set_content(''' | ||
New: | ||
```mermaid | ||
graph TD; | ||
Node_C --> Node_D; | ||
``` | ||
''') | ||
screen.should_contain('New') | ||
assert screen.find('Node_C').get_attribute('class') == 'nodeLabel' | ||
screen.should_not_contain('Node_A') |
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,20 @@ | ||
from nicegui import ui | ||
|
||
from .screen import Screen | ||
|
||
|
||
def test_mermaid(screen: Screen): | ||
m = ui.mermaid(''' | ||
graph TD; | ||
Node_A --> Node_B; | ||
''') | ||
|
||
screen.open('/') | ||
assert screen.find('Node_A').get_attribute('class') == 'nodeLabel' | ||
|
||
m.set_content(''' | ||
graph TD; | ||
Node_C --> Node_D; | ||
''') | ||
assert screen.find('Node_C').get_attribute('class') == 'nodeLabel' | ||
screen.should_not_contain('Node_A') |