Sha256: d4fb6d48135993ee6fb3436d0e71210d8025bfa69fdd03922c7ca86cd4e31935

Contents?: true

Size: 1.21 KB

Versions: 1

Compression:

Stored size: 1.21 KB

Contents

# encoding: utf-8
require_relative 'support/common'

describe 'Serialization' do
  make_my_diffs_pretty!
  parallelize_me!

  # Parse a bunch of real-world CSS and make sure it's the same when we
  # serialize it.
  Dir[File.join(File.dirname(__FILE__), 'support/serialization/*.css')].each do |filepath|
    it "should parse and serialize #{filepath}" do
      input = File.read(filepath)

      tree = Crass.parse(input,
        :preserve_comments => true,
        :preserve_hacks => true)

      assert_equal(input, CP.stringify(tree))
    end
  end

  # -- Regression tests --------------------------------------------------------
  it "should not omit a trailing semicolon when serializing a `@charset` rule" do
    css  = '@charset "utf-8";'
    tree = Crass.parse(css)

    assert_equal(css, CP.stringify(tree))
  end

  it "should reflect modifications made to the block of an `:at_rule`" do
    tree = Crass.parse(%[
      @media (screen) {
        .froggy { color: green; }
        .piggy { color: pink; }
      }
    ].strip)

    tree[0][:block] = Crass::Parser.parse_rules(".piggy { color: pink; }")

    assert_equal(
      "@media (screen) {.piggy { color: pink; }}",
      Crass::Parser.stringify(tree)
    )
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
crass-1.0.1 test/test_serialization.rb