{"size": 1302, "ext": "js", "max_stars_repo_path": "test/specs/css_composer/view/CssRulesView.js", "max_stars_repo_name": "ALACRITIC/grapesjs", "max_stars_repo_stars_event_min_datetime": "2018-05-21T07:40:42.000Z", "max_stars_repo_stars_event_max_datetime": "2020-09-05T19:43:39.000Z", "max_issues_repo_path": "test/specs/css_composer/view/CssRulesView.js", "max_issues_repo_name": "ALACRITIC/grapesjs", "max_issues_repo_issues_event_min_datetime": "2020-08-30T22:40:23.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-10T18:24:16.000Z", "max_forks_repo_path": "test/specs/css_composer/view/CssRulesView.js", "max_forks_repo_name": "ALACRITIC/grapesjs", "max_forks_repo_forks_event_min_datetime": "2019-03-25T04:41:17.000Z", "max_forks_repo_forks_event_max_datetime": "2019-03-25T04:41:17.000Z"}
{"max_stars_count": 3, "max_issues_count": 5, "max_forks_count": 1, "avg_line_length": 24.1111111111, "max_line_length": 68, "alphanum_fraction": 0.4815668203}
var CssRulesView = require('css_composer/view/CssRulesView');
var CssRules = require('css_composer/model/CssRules');

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

        let obj;

        before(function () {
          this.$fixtures = $("#fixtures");
          this.$fixture = $('<div class="cssrules-fixture"></div>');
        });

        beforeEach(function () {
          var col = new CssRules([]);
          obj = new CssRulesView({
            collection: col
          });
          this.$fixture.empty().appendTo(this.$fixtures);
          this.$fixture.html(obj.render().el);
        });

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

        after(function () {
          this.$fixture.remove();
        });

        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();
        });

    });
  }
};
