diff options
author | Adam Johnson <me@adamj.eu> | 2022-06-03 12:04:59 +0100 |
---|---|---|
committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2022-06-03 20:07:35 +0200 |
commit | 00639dbd6d023aaba20efa5497988cd730923633 (patch) | |
tree | d844b09187660a857b82a588fd55535056135f1d /tests/staticfiles_tests | |
parent | d0863429a39dbc99a52a6d781006e7075c743d33 (diff) | |
download | django-00639dbd6d023aaba20efa5497988cd730923633.tar.gz |
Refs #33765 -- Added tests for trailing whitespace in JavaScript source map references.
Diffstat (limited to 'tests/staticfiles_tests')
-rw-r--r-- | tests/staticfiles_tests/project/documents/cached/source_map_trailing_whitespace.js | 2 | ||||
-rw-r--r-- | tests/staticfiles_tests/test_storage.py | 14 |
2 files changed, 16 insertions, 0 deletions
diff --git a/tests/staticfiles_tests/project/documents/cached/source_map_trailing_whitespace.js b/tests/staticfiles_tests/project/documents/cached/source_map_trailing_whitespace.js new file mode 100644 index 0000000000..e15bc402a9 --- /dev/null +++ b/tests/staticfiles_tests/project/documents/cached/source_map_trailing_whitespace.js @@ -0,0 +1,2 @@ +//# sourceMappingURL=source_map.js.map +let a_variable = 1; diff --git a/tests/staticfiles_tests/test_storage.py b/tests/staticfiles_tests/test_storage.py index 3783d32872..745094acf6 100644 --- a/tests/staticfiles_tests/test_storage.py +++ b/tests/staticfiles_tests/test_storage.py @@ -280,6 +280,20 @@ class TestHashedFiles: ) self.assertPostCondition() + def test_js_source_map_trailing_whitespace(self): + relpath = self.hashed_file_path("cached/source_map_trailing_whitespace.js") + self.assertEqual( + relpath, "cached/source_map_trailing_whitespace.cd45b8534a87.js" + ) + with storage.staticfiles_storage.open(relpath) as relfile: + content = relfile.read() + self.assertNotIn(b"//# sourceMappingURL=source_map.js.map\t ", content) + self.assertIn( + b"//# sourceMappingURL=source_map.js.99914b932bd3.map", + content, + ) + self.assertPostCondition() + def test_js_source_map_sensitive(self): relpath = self.hashed_file_path("cached/source_map_sensitive.js") self.assertEqual(relpath, "cached/source_map_sensitive.5da96fdd3cb3.js") |