From 74afb3e93879be693c8190b7ccfd341d4e8fa9b3 Mon Sep 17 00:00:00 2001 From: Edwin van der Graaf Date: Wed, 9 Jul 2014 15:08:01 +0200 Subject: [PATCH] Testing if /*! comments are preserved in YUI --- test/unit/processor_test.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/unit/processor_test.rb b/test/unit/processor_test.rb index 3222936..f9c47db 100644 --- a/test/unit/processor_test.rb +++ b/test/unit/processor_test.rb @@ -51,8 +51,26 @@ def test_behaviour_processor_minify assert(File.exists?('file.css')) end + # Test that /*! comments are maintained in the output of YUI + def test_preserve_comments_in_css + preserved_comment = '/*! This comment remains */' + removed_comment = '/* This comment is removed */' + + ["file.js", "file.css"].each do |tmp_file| + File.open(tmp_file, 'w') do |tmp_file| + tmp_file.write(preserved_comment) + tmp_file.write(removed_comment) + end + + assert_match /remains/, File.read(@processor.minify_file(tmp_file, nil)), "/*! should be preserved by Yuicompressor" + assert_no_match /removed/, File.read(@processor.minify_file(tmp_file, nil)), "/* should be removed by Yuicompressor" + end + + end + def teardown File.delete('file.css') if File.exists?('file.css') File.delete('file.min.css') if File.exists?('file.min.css') + File.delete('file.js') if File.exists?('file.js') end end \ No newline at end of file