summaryrefslogtreecommitdiff
path: root/tests/staticfiles_tests
diff options
context:
space:
mode:
authorAdam Johnson <me@adamj.eu>2022-06-03 12:04:59 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2022-06-03 20:07:35 +0200
commit00639dbd6d023aaba20efa5497988cd730923633 (patch)
treed844b09187660a857b82a588fd55535056135f1d /tests/staticfiles_tests
parentd0863429a39dbc99a52a6d781006e7075c743d33 (diff)
downloaddjango-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.js2
-rw-r--r--tests/staticfiles_tests/test_storage.py14
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")