|
|
@@ -9,6 +9,7 @@ from hyde.generator import Generator |
|
|
|
from hyde.site import Site |
|
|
|
|
|
|
|
from fswrap import File, Folder |
|
|
|
from hyde.tests.util import assert_no_diff |
|
|
|
|
|
|
|
UGLIFY_SOURCE = File(__file__).parent.child_folder('uglify') |
|
|
|
TEST_SITE = File(__file__).parent.parent.child_folder('_test') |
|
|
@@ -38,25 +39,26 @@ class TestUglify(object): |
|
|
|
gen.generate_resource_at_path(source) |
|
|
|
|
|
|
|
assert target.exists |
|
|
|
expected = File(UGLIFY_SOURCE.child('expected-jquery.js')) |
|
|
|
expected = UGLIFY_SOURCE.child_file('expected-jquery.js').read_all() |
|
|
|
# TODO: Very fragile. Better comparison needed. |
|
|
|
assert target.read_all() == expected.read_all() |
|
|
|
text = target.read_all() |
|
|
|
assert_no_diff(expected, text) |
|
|
|
|
|
|
|
def test_uglify_with_extra_options(self): |
|
|
|
s = Site(TEST_SITE) |
|
|
|
s.config.plugins = ['hyde.ext.plugins.js.UglifyPlugin'] |
|
|
|
s.config.mode = "production" |
|
|
|
s.config.uglify = Expando(dict(args={"nc":""})) |
|
|
|
s.config.uglify = Expando(dict(args={"comments":"/http\:\/\/jquery.org\/license/"})) |
|
|
|
source = TEST_SITE.child('content/media/js/jquery.js') |
|
|
|
target = File(Folder(s.config.deploy_root_path).child('media/js/jquery.js')) |
|
|
|
gen = Generator(s) |
|
|
|
gen.generate_resource_at_path(source) |
|
|
|
|
|
|
|
assert target.exists |
|
|
|
expected = File(UGLIFY_SOURCE.child('expected-jquery-nc.js')) |
|
|
|
expected = UGLIFY_SOURCE.child_file('expected-jquery-nc.js').read_all() |
|
|
|
# TODO: Very fragile. Better comparison needed. |
|
|
|
text = target.read_all() |
|
|
|
assert text.startswith("(function(") |
|
|
|
assert_no_diff(expected, text) |
|
|
|
|
|
|
|
def test_no_uglify_in_dev_mode(self): |
|
|
|
s = Site(TEST_SITE) |
|
|
@@ -68,10 +70,9 @@ class TestUglify(object): |
|
|
|
gen.generate_resource_at_path(source) |
|
|
|
|
|
|
|
assert target.exists |
|
|
|
expected = File(UGLIFY_SOURCE.child('jquery.js')) |
|
|
|
expected = UGLIFY_SOURCE.child_file('jquery.js').read_all() |
|
|
|
# TODO: Very fragile. Better comparison needed. |
|
|
|
text = target.read_all() |
|
|
|
expected = expected.read_all() |
|
|
|
assert text == expected |
|
|
|
assert_no_diff(expected, text) |
|
|
|
|
|
|
|
|