<commit_before>CSS   = require('../lib/autoprefixer/css')
cases = require('./lib/cases')
utils = require('../lib/autoprefixer/utils')

describe 'CSS', ->
  beforeEach ->
    @nodes = cases.load('css')
    @css   = new CSS(@nodes.stylesheet)

  describe 'eachKeyframes()', ->

    it 'should iterate all keyframes', ->
      names = []
      @css.eachKeyframes (i) -> names.push(i.rule.name)
      names.should.eql ['coloring', 'moving']

  describe 'containKeyframes()', ->

    it 'should find keyframes with same name and prefix', ->
      css = new CSS(cases.load('css.prefix').stylesheet)

      css.containKeyframes(name: 'one').should.be.true
      css.containKeyframes(name: 'one', vendor: '-webkit-').should.be.true

      css.containKeyframes(name: 'one1').should.be.false
      css.containKeyframes(name: 'one', vendor: '-moz-').should.be.false

  describe 'addKeyframes()', ->

    it 'should add keyframes in iteration', ->
      @css.eachKeyframes (i) =>
        clone = utils.clone(i.rule, name: i.rule.name + '1')
        @css.addKeyframes(i.number, clone)
      cases.compare(@nodes, 'css.double')

    it 'should not double keyframes', ->
      @css.eachKeyframes (i) =>
        clone = utils.clone(i.rule, name: i.rule.name + '1')
        @css.addKeyframes(i.number, clone)
        @css.addKeyframes(i.number, clone)
      cases.compare(@nodes, 'css.double')

  describe 'removeKeyframes()', ->

    it 'should remove keyframes in interation', ->
      names = []

      @css.eachKeyframes (i) =>
        names.push(i.rule.name)
        @css.removeKeyframes(i.number) if i.rule.name == 'coloring'

      cases.compare(@nodes, 'css.remove')
      names.should.eql ['coloring', 'moving']

  describe 'eachDeclaration', -><commit_msg>Clean up test name<commit_after>CSS   = require('../lib/autoprefixer/css')
cases = require('./lib/cases')
utils = require('../lib/autoprefixer/utils')

describe 'CSS', ->
  beforeEach ->
    @nodes = cases.load('css')
    @css   = new CSS(@nodes.stylesheet)

  describe 'eachKeyframes()', ->

    it 'should iterate all keyframes', ->
      names = []
      @css.eachKeyframes (i) -> names.push(i.rule.name)
      names.should.eql ['coloring', 'moving']

  describe 'containKeyframes()', ->

    it 'should find keyframes with same name and prefix', ->
      css = new CSS(cases.load('css.prefix').stylesheet)

      css.containKeyframes(name: 'one').should.be.true
      css.containKeyframes(name: 'one', vendor: '-webkit-').should.be.true

      css.containKeyframes(name: 'one1').should.be.false
      css.containKeyframes(name: 'one', vendor: '-moz-').should.be.false

  describe 'addKeyframes()', ->

    it 'should add keyframes in iteration', ->
      @css.eachKeyframes (i) =>
        clone = utils.clone(i.rule, name: i.rule.name + '1')
        @css.addKeyframes(i.number, clone)
      cases.compare(@nodes, 'css.double')

    it 'should not double keyframes', ->
      @css.eachKeyframes (i) =>
        clone = utils.clone(i.rule, name: i.rule.name + '1')
        @css.addKeyframes(i.number, clone)
        @css.addKeyframes(i.number, clone)
      cases.compare(@nodes, 'css.double')

  describe 'removeKeyframes()', ->

    it 'should remove keyframes in interation', ->
      names = []

      @css.eachKeyframes (i) =>
        names.push(i.rule.name)
        @css.removeKeyframes(i.number) if i.rule.name == 'coloring'

      cases.compare(@nodes, 'css.remove')
      names.should.eql ['coloring', 'moving']

  describe 'eachDeclaration()', ->
{'fraction_non_alphanumeric': 0.17289586305278173, 'fraction_numerical': 0.0017118402282453639, 'mean_word_length': 2.930493273542601, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '6563445', 'n_tokens_mistral': 1171, 'n_tokens_neox': 1140, 'n_words': 231}