var Backbone = require('backbone');
var BlocksView = require('block_manager/view/BlocksView');
var Blocks = require('block_manager/model/Blocks');

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

        var $fixtures;
        var $fixture;
        var model;
        var view;
        var editorModel;
        var ppfx;

        before(() => {
          $fixtures = $('#fixtures');
          $fixture = $('<div class="devices-fixture"></div>');
        });

        beforeEach(() => {
          model = new Blocks([]);
          view = new BlocksView({ collection: model });
          $fixture.empty().appendTo($fixtures);
          $fixture.html(view.render().el);
        });

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

        after(() => {
          $fixture.remove();
        });

        it("The container is not empty", () => {
          expect(view.el.outerHTML).toExist();
        });

        it("No children inside", () => {
          expect(view.getBlocksEl().children.length).toEqual(0);
        });

        it("Render children on add", () => {
          model.add({});
          expect(view.getBlocksEl().children.length).toEqual(1);
          model.add([{},{}]);
          expect(view.getBlocksEl().children.length).toEqual(3);
        });

        it("Destroy children on remove", () => {
          model.add([{},{}]);
          expect(view.getBlocksEl().children.length).toEqual(2);
          model.at(0).destroy();
          expect(view.getBlocksEl().children.length).toEqual(1);
        });

        describe('With configs', () => {

          beforeEach(() => {
            ppfx = 'pfx-t-';
            editorModel = new Backbone.Model();
            model = new Blocks([
              {name:'test1'},
              {name:'test2'}
            ]);
            view = new BlocksView({
              collection: model,
            },{
              pStylePrefix: ppfx
            });
            $fixture.empty().appendTo($fixtures);
            $fixture.html(view.render().el);
          });

          it("Render children", () => {
            expect(view.getBlocksEl().children.length).toEqual(2);
          });

          it("Render container", () => {
            expect(view.getBlocksEl().getAttribute('class')).toEqual(ppfx + 'blocks-c');
          });

        });

    });
  }
};

@@ -352,319 +352,238 @@
 fore
-(() =%3E %7B%0A          $fixtures = $('#fixtures');%0A          $fixture = $('%3Cdiv class=%22devices-fixture%22%3E%3C/div%3E');%0A        %7D);%0A%0A        beforeEach(() =%3E %7B%0A          model = new Blocks(%5B%5D);%0A          view = new BlocksView(%7B collection: model %7D);%0A          $fixture.empty().appendTo($fixtures);%0A          $fixture.html
+Each(() =%3E %7B%0A          model = new Blocks(%5B%5D);%0A          view = new BlocksView(%7B collection: model %7D);%0A          document.body.innerHTML = '%3Cdiv id=%22fixtures%22%3E%3C/div%3E';%0A          document.body.querySelector('#fixtures').appendChild
 (vie
@@ -689,72 +689,8 @@
 );%0A%0A
-        after(() =%3E %7B%0A          $fixture.remove();%0A        %7D);%0A%0A
     
@@ -1817,71 +1817,127 @@
     
-$fixture.empty().appendTo($fixtures);%0A            $fixture.html
+document.body.innerHTML = '%3Cdiv id=%22fixtures%22%3E%3C/div%3E';%0A            document.body.querySelector('#fixtures').appendChild
 (vie

Fix blocks regressions