<commit_before>require File.expand_path(File.dirname(__FILE__) + '/test_helper')

# Test cases for the handling of media types
class CssParserMediaTypesTests < Test::Unit::TestCase
  include CssParser

  def setup
    @cp = Parser.new
  end

  def test_finding_by_media_type
    # from http://www.w3.org/TR/CSS21/media.html#at-media-rule
    css = <<-EOT
      @media print {
        body { font-size: 10pt }
      }
      @media screen {
        body { font-size: 13px }
      }
      @media screen, print {
        body { line-height: 1.2 }
      }<commit_msg>Add test to missing cleaning of media type in parsing<commit_after>require File.expand_path(File.dirname(__FILE__) + '/test_helper')

# Test cases for the handling of media types
class CssParserMediaTypesTests < Test::Unit::TestCase
  include CssParser

  def setup
    @cp = Parser.new
  end

  def test_that_media_types_dont_include_all
    css = <<-EOT
      @media handheld {
        body { color: blue; }
        p { color: grey; }
      }
      @media screen {
        body { color: red; }
    }
    EOT
    @cp.add_block!(css)
    rules = @cp.rules_by_media_query
    assert !rules.include?(:all)
  end

  def test_finding_by_media_type
    # from http://www.w3.org/TR/CSS21/media.html#at-media-rule
    css = <<-EOT
      @media print {
        body { font-size: 10pt }
      }
      @media screen {
        body { font-size: 13px }
      }
      @media screen, print {
        body { line-height: 1.2 }
      }
{'fraction_non_alphanumeric': 0.10803511141120864, 'fraction_numerical': 0.012153950033760972, 'mean_word_length': 2.3303370786516853, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1866854', 'n_tokens_mistral': 512, 'n_tokens_neox': 489, 'n_words': 119}