<commit_before>var CssRulesView = require('css_composer/view/CssRulesView');
var CssRules = require('css_composer/model/CssRules');

module.exports = {
  run() {
    describe('CssRulesView', () => {
      let obj;

      beforeEach(function() {
        var col = new CssRules([]);
        obj = new CssRulesView({
          collection: col
        });
        document.body.innerHTML = '<div id="fixtures"></div>';
        document.body.querySelector('#fixtures').appendChild(obj.render().el);
      });

      afterEach(() => {
        obj.collection.reset();
      });

      it('Object exists', () => {
        expect(CssRulesView).toExist();
      });

      it('Collection is empty', () => {
        expect(obj.$el.html()).toNotExist();
      });

      it('Add new rule', () => {
        sinon.stub(obj, 'addToCollection');
        obj.collection.add({});
        expect(obj.addToCollection.calledOnce).toExist(true);
      });

      it('Render new rule', () => {
        obj.collection.add({});
        expect(obj.$el.html()).toExist();
      });
    });
  }
};<commit_msg>Fixed tests<commit_after>const CssRulesView = require('css_composer/view/CssRulesView');
const CssRules = require('css_composer/model/CssRules');
const CssRule = require('css_composer/model/CssRule');
const Editor = require('editor/model/Editor');

module.exports = {
  run() {
    describe('CssRulesView', () => {
      let obj;
      const prefix = 'rules-';
      const devices = [
        {
          name: 'Desktop',
          width: '',
          widthMedia: ''
        },
        {
          name: 'Tablet',
          width: '768px',
          widthMedia: '992px'
        }
      ];

      beforeEach(function() {
        const col = new CssRules([]);
        obj = new CssRulesView({
          collection: col,
          config: {
            em: new Editor({
              deviceManager: {
                devices
              }
            })
          }
        });
        document.body.innerHTML = '<div id="fixtures"></div>';
        document.body.querySelector('#fixtures').appendChild(obj.render().el);
      });

      afterEach(() => {
        obj.collection.reset();
      });

      it('Object exists', () => {
        expect(CssRulesView).toExist();
      });

      it('Collection is empty. Styles structure bootstraped', () => {
        expect(obj.$el.html()).toExist();
        const foundStylesContainers = obj.$el.find('div');
        expect(foundStylesContainers.length).toEqual(devices.length);
        foundStylesContainers.each(function($styleC, idx) {
          expect($styleC.id).toEqual(prefix + devices[idx].widthMedia);
        });
      });

      it('Add new rule', () => {
        sinon.stub(obj, 'addToCollection');
        obj.collection.add({});
        expect(obj.addToCollection.calledOnce).toExist(true);
      });

      it('Render new rule', () => {
        obj.collection.add({});
        expect(
          obj.$el.find(`#${prefix}${devices[0].widthMedia}`).html()
        ).toExist();
      });
    });
  }
};
{'fraction_non_alphanumeric': 0.17670286278381048, 'fraction_numerical': 0.002303389272787101, 'mean_word_length': 2.095723014256619, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 19, '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': '6950866', 'n_tokens_mistral': 906, 'n_tokens_neox': 896, 'n_words': 133}