aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_utils.py
diff options
context:
space:
mode:
authorSimon Sawicki <contact@grub4k.xyz>2023-03-25 19:41:28 +0100
committerGitHub <noreply@github.com>2023-03-25 19:41:28 +0100
commit0898c5c8ccadfc404472456a7a7751b72afebadd (patch)
tree36aff78eca23d72a6b22c8601258f6be33dd5449 /test/test_utils.py
parentf68434cc74cfd3db01b266476a2eac8329fbb267 (diff)
downloadhypervideo-pre-0898c5c8ccadfc404472456a7a7751b72afebadd.tar.lz
hypervideo-pre-0898c5c8ccadfc404472456a7a7751b72afebadd.tar.xz
hypervideo-pre-0898c5c8ccadfc404472456a7a7751b72afebadd.zip
[utils] `js_to_json`: Implement template strings (#6623)
Authored by: Grub4K
Diffstat (limited to 'test/test_utils.py')
-rw-r--r--test/test_utils.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/test/test_utils.py b/test/test_utils.py
index 3045b6d7e..d4a301583 100644
--- a/test/test_utils.py
+++ b/test/test_utils.py
@@ -1190,6 +1190,13 @@ class TestUtil(unittest.TestCase):
self.assertEqual(js_to_json('42a1'), '42"a1"')
self.assertEqual(js_to_json('42a-1'), '42"a"-1')
+ def test_js_to_json_template_literal(self):
+ self.assertEqual(js_to_json('`Hello ${name}`', {'name': '"world"'}), '"Hello world"')
+ self.assertEqual(js_to_json('`${name}${name}`', {'name': '"X"'}), '"XX"')
+ self.assertEqual(js_to_json('`${name}${name}`', {'name': '5'}), '"55"')
+ self.assertEqual(js_to_json('`${name}"${name}"`', {'name': '5'}), '"5\\"5\\""')
+ self.assertEqual(js_to_json('`${name}`', {}), '"name"')
+
def test_extract_attributes(self):
self.assertEqual(extract_attributes('<e x="y">'), {'x': 'y'})
self.assertEqual(extract_attributes("<e x='y'>"), {'x': 'y'})