Skip to content

Commit ffd8d9f

Browse files
committed
Test compressed_js for correct whitespace, async and defer. Add myself to AUTHORS.
1 parent c83365d commit ffd8d9f

File tree

3 files changed

+64
-2
lines changed

3 files changed

+64
-2
lines changed

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ or just made Pipeline more awesome.
5151
* Miroslav Shubernetskiy <[email protected]>
5252
* Patrick Altman <[email protected]>
5353
* Peter Baumgartner <[email protected]>
54+
* Philipp Wollermann <[email protected]>
5455
* Pierre Drescher <[email protected]>
5556
* Rajiv Bose <[email protected]>
5657
* Rami Chowdhury <[email protected]>

tests/settings.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,5 +65,42 @@
6565
'pipeline/templates/**/*.jst'
6666
),
6767
'output_filename': 'scripts.js'
68+
},
69+
'scripts_async': {
70+
'source_filenames': (
71+
'pipeline/js/first.js',
72+
'pipeline/js/second.js',
73+
'pipeline/js/application.js',
74+
'pipeline/templates/**/*.jst'
75+
),
76+
'output_filename': 'scripts_async.js',
77+
'extra_context': {
78+
'async': True,
79+
}
80+
},
81+
'scripts_defer': {
82+
'source_filenames': (
83+
'pipeline/js/first.js',
84+
'pipeline/js/second.js',
85+
'pipeline/js/application.js',
86+
'pipeline/templates/**/*.jst'
87+
),
88+
'output_filename': 'scripts_defer.js',
89+
'extra_context': {
90+
'defer': True,
91+
}
92+
},
93+
'scripts_async_defer': {
94+
'source_filenames': (
95+
'pipeline/js/first.js',
96+
'pipeline/js/second.js',
97+
'pipeline/js/application.js',
98+
'pipeline/templates/**/*.jst'
99+
),
100+
'output_filename': 'scripts_async_defer.js',
101+
'extra_context': {
102+
'async': True,
103+
'defer': True,
104+
}
68105
}
69106
}

tests/tests/test_template.py

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,19 @@ def test_package_css_disabled(self):
3535

3636
def test_package_js(self):
3737
template = self.env.from_string(u"""{% compressed_js "scripts" %}""")
38-
self.assertEqual(u'<script type="text/javascript" src="/static/scripts.js" charset="utf-8"></script>', template.render())
38+
self.assertEqual(u'<script type="text/javascript" src="/static/scripts.js" charset="utf-8"></script>', template.render())
39+
40+
def test_package_js_async(self):
41+
template = self.env.from_string(u"""{% compressed_js "scripts_async" %}""")
42+
self.assertEqual(u'<script async type="text/javascript" src="/static/scripts_async.js" charset="utf-8"></script>', template.render())
43+
44+
def test_package_js_defer(self):
45+
template = self.env.from_string(u"""{% compressed_js "scripts_defer" %}""")
46+
self.assertEqual(u'<script defer type="text/javascript" src="/static/scripts_defer.js" charset="utf-8"></script>', template.render())
47+
48+
def test_package_js_async_defer(self):
49+
template = self.env.from_string(u"""{% compressed_js "scripts_async_defer" %}""")
50+
self.assertEqual(u'<script async defer type="text/javascript" src="/static/scripts_async_defer.js" charset="utf-8"></script>', template.render())
3951

4052

4153
class DjangoTest(TestCase):
@@ -52,4 +64,16 @@ def test_compressed_css(self):
5264

5365
def test_compressed_js(self):
5466
rendered = self.render_template(u"""{% load compressed %}{% compressed_js "scripts" %}""")
55-
self.assertEqual(u'<script type="text/javascript" src="/static/scripts.js" charset="utf-8"></script>', rendered)
67+
self.assertEqual(u'<script type="text/javascript" src="/static/scripts.js" charset="utf-8"></script>', rendered)
68+
69+
def test_compressed_js_async(self):
70+
rendered = self.render_template(u"""{% load compressed %}{% compressed_js "scripts_async" %}""")
71+
self.assertEqual(u'<script async type="text/javascript" src="/static/scripts_async.js" charset="utf-8"></script>', rendered)
72+
73+
def test_compressed_js_defer(self):
74+
rendered = self.render_template(u"""{% load compressed %}{% compressed_js "scripts_defer" %}""")
75+
self.assertEqual(u'<script defer type="text/javascript" src="/static/scripts_defer.js" charset="utf-8"></script>', rendered)
76+
77+
def test_compressed_js_async_defer(self):
78+
rendered = self.render_template(u"""{% load compressed %}{% compressed_js "scripts_async_defer" %}""")
79+
self.assertEqual(u'<script async defer type="text/javascript" src="/static/scripts_async_defer.js" charset="utf-8"></script>', rendered)

0 commit comments

Comments
 (0)