var _ = require('underscore'); var Backbone = require('backbone'); var CoreView = require('backbone/core-view'); var ModalViewModel = require('builder/components/modals/modal-view-model'); var ModalView = require('builder/components/modals/modal-view'); describe('components/modals/modal-view', function () { var view, model, contentView, contentViewModel, contentViewEventSpy; var createViewFn = function (options) { contentViewEventSpy = jasmine.createSpy('test'); model = new ModalViewModel({ createContentView: function () { return contentView; } }); var TestView = CoreView.extend({ initialize: function () { this.model.on('test', contentViewEventSpy, this); } }); contentViewModel = new Backbone.Model(); contentView = new TestView({model: contentViewModel}); spyOn(contentView, 'render').and.callThrough(); var defaultOptions = { model: model }; view = new ModalView(_.extend(defaultOptions, options)); return view; }; it('should have no leaks', function () { view = createViewFn(); view.render(); expect(view).toHaveNoLeaks(); }); it('should render dialog classes', function () { view = createViewFn(); view.render(); expect(view.$el.html()).toContain('Dialog'); expect(view.$el.html()).toContain('Dialog-contentWrapper'); }); it('should not render close button if escapeOptionsDisabled is present', function () { view = createViewFn({ escapeOptionsDisabled: true }); view.render(); expect(view.$el.html()).not.toContain('js-close'); }); it('should not render close button if breadcrumbsEnabled is present', function () { view = createViewFn({ breadcrumbsEnabled: true }); view.render(); expect(view.$el.html()).toContain('