mirror of https://github.com/artf/grapesjs.git
11 changed files with 298 additions and 100 deletions
@ -1,13 +1,13 @@ |
|||
define(function () { |
|||
return { |
|||
|
|||
stylePrefix : 'mdl-', |
|||
stylePrefix: 'mdl-', |
|||
|
|||
title : '', |
|||
title: '', |
|||
|
|||
content : '', |
|||
content: '', |
|||
|
|||
backdrop : true, |
|||
backdrop: true, |
|||
|
|||
}; |
|||
}); |
|||
@ -1,15 +1,12 @@ |
|||
define(['backbone'], |
|||
function(Backbone) { |
|||
/** |
|||
* @class Modal |
|||
* */ |
|||
return Backbone.Model.extend({ |
|||
|
|||
|
|||
defaults: { |
|||
title : '', |
|||
content : '', |
|||
open : false, |
|||
title: '', |
|||
content: '', |
|||
open: false, |
|||
} |
|||
|
|||
}); |
|||
|
|||
}); |
|||
}); |
|||
@ -0,0 +1,69 @@ |
|||
var modulePath = './../../../test/specs/modal'; |
|||
|
|||
define([ 'ModalDialog', |
|||
modulePath + '/view/ModalView', |
|||
], |
|||
function(Modal, ModalView) { |
|||
|
|||
describe('Modal dialog', function() { |
|||
|
|||
describe('Main', function() { |
|||
|
|||
var obj; |
|||
|
|||
beforeEach(function () { |
|||
obj = new Modal().init(); |
|||
}); |
|||
|
|||
afterEach(function () { |
|||
delete obj; |
|||
}); |
|||
|
|||
it('Object exists', function() { |
|||
obj.should.be.exist; |
|||
}); |
|||
|
|||
it('Is close by default', function() { |
|||
obj.isOpen().should.equal(false); |
|||
}); |
|||
|
|||
it('Title is empty', function() { |
|||
obj.getTitle().should.equal(''); |
|||
}); |
|||
|
|||
it('Content is empty', function() { |
|||
obj.getContent().should.equal(''); |
|||
}); |
|||
|
|||
it('Set title', function() { |
|||
obj.setTitle('Test'); |
|||
obj.getTitle().should.equal('Test'); |
|||
}); |
|||
|
|||
it('Set content', function() { |
|||
obj.setContent('Test'); |
|||
obj.getContent().should.equal('Test'); |
|||
}); |
|||
|
|||
it('Set HTML content', function() { |
|||
obj.setContent('<h1>Test</h1>'); |
|||
obj.getContent().should.equal('<h1>Test</h1>'); |
|||
}); |
|||
|
|||
it('Open modal', function() { |
|||
obj.open(); |
|||
obj.isOpen().should.equal(true); |
|||
}); |
|||
|
|||
it('Close modal', function() { |
|||
obj.open(); |
|||
obj.close(); |
|||
obj.isOpen().should.equal(false); |
|||
}); |
|||
|
|||
}); |
|||
|
|||
ModalView.run(); |
|||
|
|||
}); |
|||
}); |
|||
@ -0,0 +1,74 @@ |
|||
var path = 'ModalDialog/view/'; |
|||
define([path + 'ModalView', 'ModalDialog/model/Modal'], |
|||
function(ModalView, Modal) { |
|||
|
|||
return { |
|||
run : function(){ |
|||
describe('ModalView', function() { |
|||
|
|||
var $fixtures; |
|||
var $fixture; |
|||
var model; |
|||
var view; |
|||
var editorModel; |
|||
|
|||
before(function () { |
|||
$fixtures = $("#fixtures"); |
|||
$fixture= $('<div class="modal-fixture"></div>'); |
|||
}); |
|||
|
|||
beforeEach(function () { |
|||
model = new Modal(); |
|||
view = new ModalView({ |
|||
model: model |
|||
}); |
|||
$fixture.empty().appendTo($fixtures); |
|||
$fixture.html(view.render().el); |
|||
}); |
|||
|
|||
afterEach(function () { |
|||
delete view; |
|||
delete model; |
|||
}); |
|||
|
|||
after(function () { |
|||
$fixture.remove(); |
|||
}); |
|||
|
|||
it("The content is not empty", function (){ |
|||
view.el.innerHTML.should.be.not.empty; |
|||
}); |
|||
|
|||
it("Get content", function (){ |
|||
view.getContent().should.be.ok; |
|||
}); |
|||
|
|||
it("Update content", function (){ |
|||
model.set('content', 'test'); |
|||
view.getContent().innerHTML.should.equal('test'); |
|||
}); |
|||
|
|||
it("Get title", function (){ |
|||
view.getTitle().should.be.ok; |
|||
}); |
|||
|
|||
it("Update title", function (){ |
|||
model.set('title', 'test'); |
|||
view.getTitle().innerHTML.should.equal('test'); |
|||
}); |
|||
|
|||
it("Close by default", function (){ |
|||
view.updateOpen(); |
|||
view.el.style.display.should.equal('none'); |
|||
}); |
|||
|
|||
it("Open dialog", function (){ |
|||
model.set('open', 1); |
|||
view.el.style.display.should.equal(''); |
|||
}); |
|||
|
|||
}); |
|||
} |
|||
}; |
|||
|
|||
}); |
|||
Loading…
Reference in new issue