mirror of https://github.com/artf/grapesjs.git
5 changed files with 123 additions and 128 deletions
@ -0,0 +1,65 @@ |
|||
const Modal = require('modal_dialog'); |
|||
const ModalView = require('./view/ModalView'); |
|||
|
|||
describe.only('Modal dialog', () => { |
|||
|
|||
describe('Main', () => { |
|||
|
|||
var obj; |
|||
|
|||
beforeEach(() => { |
|||
obj = new Modal().init(); |
|||
}); |
|||
|
|||
afterEach(() => { |
|||
obj = null; |
|||
}); |
|||
|
|||
it('Object exists', () => { |
|||
expect(obj).toExist(); |
|||
}); |
|||
|
|||
it('Is close by default', () => { |
|||
expect(obj.isOpen()).toEqual(false); |
|||
}); |
|||
|
|||
it('Title is empty', () => { |
|||
expect(obj.getTitle()).toEqual(''); |
|||
}); |
|||
|
|||
it('Content is empty', () => { |
|||
expect(obj.getContent()).toEqual(''); |
|||
}); |
|||
|
|||
it('Set title', () => { |
|||
obj.setTitle('Test'); |
|||
expect(obj.getTitle()).toEqual('Test'); |
|||
|
|||
}); |
|||
|
|||
it('Set content', () => { |
|||
obj.setContent('Test'); |
|||
expect(obj.getContent()).toEqual('Test'); |
|||
}); |
|||
|
|||
it('Set HTML content', () => { |
|||
obj.setContent('<h1>Test</h1>'); |
|||
expect(obj.getContent()).toEqual('<h1>Test</h1>'); |
|||
}); |
|||
|
|||
it('Open modal', () => { |
|||
obj.open(); |
|||
expect(obj.isOpen()).toEqual(true); |
|||
}); |
|||
|
|||
it('Close modal', () => { |
|||
obj.open(); |
|||
obj.close(); |
|||
expect(obj.isOpen()).toEqual(false); |
|||
}); |
|||
|
|||
}); |
|||
|
|||
ModalView.run(); |
|||
|
|||
}); |
|||
@ -1,67 +0,0 @@ |
|||
define(function(require, exports, module){ |
|||
'use strict'; |
|||
var Modal = require('ModalDialog'); |
|||
var ModalView = require('undefined'); |
|||
|
|||
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(); |
|||
|
|||
}); |
|||
}); |
|||
@ -1,75 +1,71 @@ |
|||
define(function(require, exports, module){ |
|||
'use strict'; |
|||
var ModalView = require('undefined'); |
|||
var Modal = require('ModalDialog/model/Modal'); |
|||
const ModalView = require('modal_dialog/view/ModalView'); |
|||
const Modal = require('modal_dialog/model/Modal'); |
|||
|
|||
module.exports = { |
|||
run : function(){ |
|||
describe('ModalView', function() { |
|||
module.exports = { |
|||
run() { |
|||
describe('ModalView', () => { |
|||
|
|||
var $fixtures; |
|||
var $fixture; |
|||
var model; |
|||
var view; |
|||
var editorModel; |
|||
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); |
|||
}); |
|||
before(() => { |
|||
$fixtures = $("#fixtures"); |
|||
$fixture= $('<div class="modal-fixture"></div>'); |
|||
}); |
|||
|
|||
afterEach(function () { |
|||
delete view; |
|||
delete model; |
|||
}); |
|||
beforeEach(() => { |
|||
model = new Modal(); |
|||
view = new ModalView({ |
|||
model |
|||
}); |
|||
$fixture.empty().appendTo($fixtures); |
|||
$fixture.html(view.render().el); |
|||
}); |
|||
|
|||
after(function () { |
|||
$fixture.remove(); |
|||
}); |
|||
afterEach(() => { |
|||
view = null; |
|||
model = null; |
|||
}); |
|||
|
|||
it("The content is not empty", function (){ |
|||
view.el.innerHTML.should.be.not.empty; |
|||
}); |
|||
after(() => { |
|||
$fixture.remove(); |
|||
}); |
|||
|
|||
it("Get content", function (){ |
|||
view.getContent().should.be.ok; |
|||
}); |
|||
it("The content is not empty", () => { |
|||
expect(view.el.innerHTML).toExist(); |
|||
}); |
|||
|
|||
it("Update content", function (){ |
|||
model.set('content', 'test'); |
|||
view.getContent().get(0).innerHTML.should.equal('test'); |
|||
}); |
|||
it("Get content", () => { |
|||
expect(view.getContent()).toExist(); |
|||
}); |
|||
|
|||
it("Get title", function (){ |
|||
view.getTitle().should.be.ok; |
|||
}); |
|||
it("Update content", () => { |
|||
model.set('content', 'test'); |
|||
expect(view.getContent().get(0).innerHTML).toEqual('test'); |
|||
}); |
|||
|
|||
it("Update title", function (){ |
|||
model.set('title', 'test'); |
|||
view.getTitle().innerHTML.should.equal('test'); |
|||
}); |
|||
it("Get title", () => { |
|||
expect(view.getTitle()).toExist(); |
|||
}); |
|||
|
|||
it("Close by default", function (){ |
|||
view.updateOpen(); |
|||
view.el.style.display.should.equal('none'); |
|||
}); |
|||
it("Update title", () => { |
|||
model.set('title', 'test'); |
|||
expect(view.getTitle().innerHTML).toEqual('test'); |
|||
}); |
|||
|
|||
it("Open dialog", function (){ |
|||
model.set('open', 1); |
|||
view.el.style.display.should.equal(''); |
|||
}); |
|||
it("Close by default", () => { |
|||
view.updateOpen(); |
|||
expect(view.el.style.display).toEqual('none'); |
|||
}); |
|||
|
|||
it("Open dialog", () => { |
|||
model.set('open', 1); |
|||
expect(view.el.style.display).toEqual(''); |
|||
}); |
|||
} |
|||
}; |
|||
|
|||
}); |
|||
}); |
|||
} |
|||
}; |
|||
|
|||
Loading…
Reference in new issue