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){ |
const ModalView = require('modal_dialog/view/ModalView'); |
||||
'use strict'; |
const Modal = require('modal_dialog/model/Modal'); |
||||
var ModalView = require('undefined'); |
|
||||
var Modal = require('ModalDialog/model/Modal'); |
|
||||
|
|
||||
module.exports = { |
module.exports = { |
||||
run : function(){ |
run() { |
||||
describe('ModalView', function() { |
describe('ModalView', () => { |
||||
|
|
||||
var $fixtures; |
var $fixtures; |
||||
var $fixture; |
var $fixture; |
||||
var model; |
var model; |
||||
var view; |
var view; |
||||
var editorModel; |
var editorModel; |
||||
|
|
||||
before(function () { |
before(() => { |
||||
$fixtures = $("#fixtures"); |
$fixtures = $("#fixtures"); |
||||
$fixture= $('<div class="modal-fixture"></div>'); |
$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 () { |
beforeEach(() => { |
||||
delete view; |
model = new Modal(); |
||||
delete model; |
view = new ModalView({ |
||||
}); |
model |
||||
|
}); |
||||
|
$fixture.empty().appendTo($fixtures); |
||||
|
$fixture.html(view.render().el); |
||||
|
}); |
||||
|
|
||||
after(function () { |
afterEach(() => { |
||||
$fixture.remove(); |
view = null; |
||||
}); |
model = null; |
||||
|
}); |
||||
|
|
||||
it("The content is not empty", function (){ |
after(() => { |
||||
view.el.innerHTML.should.be.not.empty; |
$fixture.remove(); |
||||
}); |
}); |
||||
|
|
||||
it("Get content", function (){ |
it("The content is not empty", () => { |
||||
view.getContent().should.be.ok; |
expect(view.el.innerHTML).toExist(); |
||||
}); |
}); |
||||
|
|
||||
it("Update content", function (){ |
it("Get content", () => { |
||||
model.set('content', 'test'); |
expect(view.getContent()).toExist(); |
||||
view.getContent().get(0).innerHTML.should.equal('test'); |
}); |
||||
}); |
|
||||
|
|
||||
it("Get title", function (){ |
it("Update content", () => { |
||||
view.getTitle().should.be.ok; |
model.set('content', 'test'); |
||||
}); |
expect(view.getContent().get(0).innerHTML).toEqual('test'); |
||||
|
}); |
||||
|
|
||||
it("Update title", function (){ |
it("Get title", () => { |
||||
model.set('title', 'test'); |
expect(view.getTitle()).toExist(); |
||||
view.getTitle().innerHTML.should.equal('test'); |
}); |
||||
}); |
|
||||
|
|
||||
it("Close by default", function (){ |
it("Update title", () => { |
||||
view.updateOpen(); |
model.set('title', 'test'); |
||||
view.el.style.display.should.equal('none'); |
expect(view.getTitle().innerHTML).toEqual('test'); |
||||
}); |
}); |
||||
|
|
||||
it("Open dialog", function (){ |
it("Close by default", () => { |
||||
model.set('open', 1); |
view.updateOpen(); |
||||
view.el.style.display.should.equal(''); |
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