diff options
author | bashonly <bashonly@bashonly.com> | 2023-09-21 16:51:57 -0500 |
---|---|---|
committer | bashonly <bashonly@bashonly.com> | 2023-09-21 16:51:57 -0500 |
commit | 52414d64ca7b92d3f83964cdd68247989b0c4625 (patch) | |
tree | 5f3bc6931f4b203567192b07801a7d0e565384cb /test/test_utils.py | |
parent | 2269065ad60cb0ab62408ae6a7b20283e5252232 (diff) |
[utils] `js_to_json`: Handle `Array` objects
Authored by: Grub4K, std-move
Co-authored-by: std-move <26625259+std-move@users.noreply.github.com>
Co-authored-by: Simon Sawicki <accounts@grub4k.xyz>
Diffstat (limited to 'test/test_utils.py')
-rw-r--r-- | test/test_utils.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/test/test_utils.py b/test/test_utils.py index 91e3ffd39..47d1f71bf 100644 --- a/test/test_utils.py +++ b/test/test_utils.py @@ -1218,6 +1218,12 @@ class TestUtil(unittest.TestCase): self.assertEqual(js_to_json('`${name}"${name}"`', {'name': '5'}), '"5\\"5\\""') self.assertEqual(js_to_json('`${name}`', {}), '"name"') + def test_js_to_json_map_array_constructors(self): + self.assertEqual(json.loads(js_to_json('new Map([["a", 5]])')), {'a': 5}) + self.assertEqual(json.loads(js_to_json('Array(5, 10)')), [5, 10]) + self.assertEqual(json.loads(js_to_json('new Array(15,5)')), [15, 5]) + self.assertEqual(json.loads(js_to_json('new Map([Array(5, 10),new Array(15,5)])')), {'5': 10, '15': 5}) + def test_extract_attributes(self): self.assertEqual(extract_attributes('<e x="y">'), {'x': 'y'}) self.assertEqual(extract_attributes("<e x='y'>"), {'x': 'y'}) |