Skip to content

Commit

Permalink
Unit tests for testing escaping
Browse files Browse the repository at this point in the history
  • Loading branch information
Christoph-Koschel committed Jul 8, 2023
1 parent 85df7d0 commit b11a016
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
19 changes: 19 additions & 0 deletions tests/test_escape.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
diff --git a/tests/ExampleFile.java b/tests/ExampleFile.java
index d340f6a..29b54da 100644
--- a/tests/ExampleFile.java
+++ b/tests/ExampleFile.java
@@ -1,13 +1,5 @@
package com.mydomain.myapp;

public class JavaTests {
- // TODO: Some Java
- // # Some title
- // <SomeTag>

- /*
- TODO: Definitely some Java
- # Another title
- <AnotherTag>
- */
}
\ No newline at end of file
25 changes: 24 additions & 1 deletion tests/test_todo_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def test_clojure_issues(self):

def test_nix_issues(self):
self.assertEqual(count_issues_for_file_type(self.raw_issues, 'nix'), 2)

def test_xaml_issues(self):
self.assertEqual(count_issues_for_file_type(self.raw_issues, 'xml'), 2)

Expand Down Expand Up @@ -204,3 +204,26 @@ def test_multiple_ignores(self):
# Includes 2 tests for Crystal.
self.assertEqual(count_issues_for_file_type(self.raw_issues, 'ruby'), 5)
os.environ['INPUT_IGNORE'] = ''

class EscapeMarkdownTest(unittest.TestCase):
def test_simple_escape(self):
os.environ['INPUT_ESCAPE'] = 'true'
parser = TodoParser()
with open('syntax.json', 'r') as syntax_json:
parser.syntax_dict = json.load(syntax_json)
diff_file = open('tests/test_escape.diff', 'r')

# I had no other idea to make these checks dynamic.
self.raw_issues = parser.parse(diff_file)
self.assertEqual(len(self.raw_issues), 2)

issue = self.raw_issues[0]
self.assertEqual(len(issue.body), 2)
self.assertEqual(issue.body[0], '\\# Some title')
self.assertEqual(issue.body[1], '\\<SomeTag\\>')

issue = self.raw_issues[1]
self.assertEqual(len(issue.body), 2)
self.assertEqual(issue.body[0], '\\# Another title')
self.assertEqual(issue.body[1], '\\<AnotherTag\\>')

0 comments on commit b11a016

Please sign in to comment.