Sha256: 9bb124802a620cca9d99cc047ee82d23dd2a606511affaaa6fd7bde9ad2ab5f6

Contents?: true

Size: 1.13 KB

Versions: 2

Compression:

Stored size: 1.13 KB

Contents

#
# File::      test_JavaScriptProcessor.rb
# Copyright:: 2009
# License::   GPL
#
# Unit tests for the JavaScriptProcessor
#

$:.unshift File.join(File.dirname(__FILE__), '..', 'lib')

require 'test/unit'
require 'sitefuel/processors/JavaScriptProcessor'

include SiteFuel::Processor

class TestJavaScriptProcessor < Test::Unit::TestCase

  def test_file_extensions
    assert JavaScriptProcessor.processes_file?('foo.js')
  end

  def test_name
    assert_equal 'JS', JavaScriptProcessor.processor_name
  end

  # CDATA fields need to be left intact
  def test_cdata
    assert_equal(
      "//<![CDATA[\nfunction foo(){12}\n//]]>",

      JavaScriptProcessor.filter_string(:minify,
        %q{
          //<![CDATA[
          function foo() {
            12
          }
          //]]>
        }
      )
    )
  end

  # test comment-only javascripts
  def test_comments_only
    assert_equal(
      '',
      JavaScriptProcessor.filter_string(:minify,
        %q{
          // just a comment....
        }
      )
    )

    assert_equal(
      '',
      JavaScriptProcessor.filter_string(:minify,
        %q{//just a comment...}
      )
    )
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sitefuel-0.0.0b test/test_JavaScriptProcessor.rb
sitefuel-0.0.0a test/test_JavaScriptProcessor.rb