|
@@ -96,6 +96,36 @@ def test_wrap(text: str, open: str, expected: str, check_first: bool, num: int):
|
|
|
assert format.wrap(text, open, check_first=check_first, num=num) == expected
|
|
|
|
|
|
|
|
|
+@pytest.mark.parametrize(
|
|
|
+ "string,expected_output",
|
|
|
+ [
|
|
|
+ ("This is a random string", "This is a random string"),
|
|
|
+ (
|
|
|
+ "This is a random string with `backticks`",
|
|
|
+ "This is a random string with \\`backticks\\`",
|
|
|
+ ),
|
|
|
+ (
|
|
|
+ "This is a random string with `backticks`",
|
|
|
+ "This is a random string with \\`backticks\\`",
|
|
|
+ ),
|
|
|
+ (
|
|
|
+ "This is a string with ${someValue[`string interpolation`]} unescaped",
|
|
|
+ "This is a string with ${someValue[`string interpolation`]} unescaped",
|
|
|
+ ),
|
|
|
+ (
|
|
|
+ "This is a string with `backticks` and ${someValue[`string interpolation`]} unescaped",
|
|
|
+ "This is a string with \\`backticks\\` and ${someValue[`string interpolation`]} unescaped",
|
|
|
+ ),
|
|
|
+ (
|
|
|
+ "This is a string with `backticks`, ${someValue[`the first string interpolation`]} and ${someValue[`the second`]}",
|
|
|
+ "This is a string with \\`backticks\\`, ${someValue[`the first string interpolation`]} and ${someValue[`the second`]}",
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+)
|
|
|
+def test_escape_js_string(string, expected_output):
|
|
|
+ assert format._escape_js_string(string) == expected_output
|
|
|
+
|
|
|
+
|
|
|
@pytest.mark.parametrize(
|
|
|
"text,indent_level,expected",
|
|
|
[
|