From 2c6b14ee53ca884644dfbac08feaacf4eee9a5c6 Mon Sep 17 00:00:00 2001 From: Alex Wilson Date: Sat, 9 Sep 2023 14:44:48 +0100 Subject: [PATCH] refactor(test_parse.py): Split render tests into their own file --- adr_viewer/test_parse.py | 41 ++------------------------------------- adr_viewer/test_render.py | 40 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 39 deletions(-) create mode 100644 adr_viewer/test_render.py diff --git a/adr_viewer/test_parse.py b/adr_viewer/test_parse.py index 36c6f23..667565a 100644 --- a/adr_viewer/test_parse.py +++ b/adr_viewer/test_parse.py @@ -1,4 +1,4 @@ -from adr_viewer import parse_adr_to_config, render_html +from adr_viewer import parse_adr_to_config def test_should_extract_title_from_record(): @@ -42,49 +42,12 @@ def test_should_mark_pending_records(): assert config['status'] == 'pending' + def test_should_mark_pproposed_records(): config = parse_adr_to_config('test/adr/0004-proposed-status.md') assert config['status'] == 'pending' -def test_should_render_html_with_project_title(): - html = render_html({ - 'project_title': 'my-project' - }) - - assert 'ADR Viewer - my-project' in html - - -def test_should_render_html_with_record_status(): - html = render_html({ - 'records': [{ - 'status': 'accepted', - }] - }) - - assert '
' in html - - -def test_should_render_html_with_record_body(): - html = render_html({ - 'records': [{ - 'body': '

This is my ADR

', - }] - }) - - assert '

This is my ADR

' in html - - -def test_should_render_html_with_collapsible_index(): - html = render_html({ - 'records': [{ - 'title': 'Record 123', - 'index': 123 - }] - }) - - assert 'Record 123' in html - def test_should_ignore_invalid_files(): config = parse_adr_to_config('test/adr/0003-bad-formatting.md') diff --git a/adr_viewer/test_render.py b/adr_viewer/test_render.py new file mode 100644 index 0000000..f2cb8d2 --- /dev/null +++ b/adr_viewer/test_render.py @@ -0,0 +1,40 @@ +from adr_viewer import render_html + + +def test_should_render_html_with_project_title(): + html = render_html({ + 'project_title': 'my-project' + }) + + assert 'ADR Viewer - my-project' in html + + +def test_should_render_html_with_record_status(): + html = render_html({ + 'records': [{ + 'status': 'accepted', + }] + }) + + assert '
' in html + + +def test_should_render_html_with_record_body(): + html = render_html({ + 'records': [{ + 'body': '

This is my ADR

', + }] + }) + + assert '

This is my ADR

' in html + + +def test_should_render_html_with_collapsible_index(): + html = render_html({ + 'records': [{ + 'title': 'Record 123', + 'index': 123 + }] + }) + + assert 'Record 123' in html