mirror of https://github.com/artf/grapesjs.git
11 changed files with 483 additions and 502 deletions
@ -1,74 +1,69 @@ |
|||||
define(function(require, exports, module){ |
module.exports = { |
||||
'use strict'; |
run() { |
||||
var GrapesJS = require('GrapesJS'); |
|
||||
|
|
||||
module.exports = { |
describe('E2E tests', () => { |
||||
run : function(){ |
|
||||
|
|
||||
describe('E2E tests', function() { |
var fixtures; |
||||
|
var fixture; |
||||
|
var obj; |
||||
|
var config; |
||||
|
var editorName = 'panel-fixture'; |
||||
|
|
||||
var fixtures; |
before(() => { |
||||
var fixture; |
fixtures = $("#fixtures"); |
||||
var obj; |
}); |
||||
var editorName = 'panel-fixture'; |
|
||||
|
|
||||
before(function () { |
|
||||
fixtures = $("#fixtures"); |
|
||||
}); |
|
||||
|
|
||||
beforeEach(function () { |
|
||||
obj = GrapesJS; |
|
||||
config = { |
|
||||
container: '#' + editorName, |
|
||||
storage: { autoload: 0, type:'none' }, |
|
||||
}; |
|
||||
fixture = $('<div id="' + editorName + '"></div>'); |
|
||||
fixture.empty().appendTo(fixtures); |
|
||||
}); |
|
||||
|
|
||||
afterEach(function () { |
beforeEach(() => { |
||||
delete obj; |
obj = grapesjs; |
||||
delete config; |
config = { |
||||
fixture.remove(); |
container: '#' + editorName, |
||||
}); |
storageManager: { autoload: 0, type:'none' }, |
||||
|
}; |
||||
|
fixture = $('<div id="' + editorName + '"></div>'); |
||||
|
fixture.empty().appendTo(fixtures); |
||||
|
}); |
||||
|
|
||||
after(function () { |
afterEach(() => { |
||||
fixture.remove(); |
obj = null; |
||||
}); |
config = null; |
||||
|
fixture.remove(); |
||||
|
}); |
||||
|
|
||||
it('Command is correctly executed on button click', function() { |
after(() => { |
||||
var commandId = 'command-test'; |
//fixture.remove();
|
||||
config.commands = { |
}); |
||||
defaults: [{ |
|
||||
id: commandId, |
|
||||
run: function(ed, caller){ |
|
||||
ed.testValue = 'testValue'; |
|
||||
caller.set('active', false); |
|
||||
} |
|
||||
}] |
|
||||
}; |
|
||||
config.panels = { |
|
||||
defaults : [{ |
|
||||
id : 'toolbar-test', |
|
||||
buttons : [{ |
|
||||
id : 'button-test', |
|
||||
className : 'fa fa-smile-o', |
|
||||
command : commandId, |
|
||||
}], |
|
||||
}], |
|
||||
}; |
|
||||
var editor = obj.init(config); |
|
||||
editor.testValue = ''; |
|
||||
var button = editor.Panels.getButton('toolbar-test', 'button-test'); |
|
||||
button.set('active', 1); |
|
||||
editor.testValue.should.equal('testValue'); |
|
||||
button.get('active').should.equal(false); |
|
||||
}); |
|
||||
|
|
||||
|
it.skip('Command is correctly executed on button click', () => { |
||||
|
var commandId = 'command-test'; |
||||
|
config.commands = { |
||||
|
defaults: [{ |
||||
|
id: commandId, |
||||
|
run(ed, caller) { |
||||
|
ed.testValue = 'testValue'; |
||||
|
caller.set('active', false); |
||||
|
} |
||||
|
}] |
||||
|
}; |
||||
|
config.panels = { |
||||
|
defaults: [{ |
||||
|
id : 'toolbar-test', |
||||
|
buttons : [{ |
||||
|
id : 'button-test', |
||||
|
className : 'fa fa-smile-o', |
||||
|
command : commandId, |
||||
|
}], |
||||
|
}], |
||||
|
}; |
||||
|
var editor = obj.init(config); |
||||
|
editor.testValue = ''; |
||||
|
var button = editor.Panels.getButton('toolbar-test', 'button-test'); |
||||
|
button.set('active', 1); |
||||
|
expect(editor.testValue).toEqual('testValue'); |
||||
|
expect(button.get('active')).toEqual(false); |
||||
}); |
}); |
||||
|
|
||||
} |
}); |
||||
|
|
||||
}; |
} |
||||
|
|
||||
}); |
}; |
||||
|
|||||
@ -0,0 +1,104 @@ |
|||||
|
const Panels = require('panels'); |
||||
|
const e2e = require('./e2e/PanelsE2e'); |
||||
|
const Models = require('./model/PanelModels'); |
||||
|
const PanelView = require('./view/PanelView'); |
||||
|
const PanelsView = require('./view/PanelsView'); |
||||
|
const ButtonView = require('./view/ButtonView'); |
||||
|
const ButtonsView = require('./view/ButtonsView'); |
||||
|
|
||||
|
describe.only('Panels', () => { |
||||
|
|
||||
|
describe('Main', () => { |
||||
|
|
||||
|
var obj; |
||||
|
|
||||
|
beforeEach(() => { |
||||
|
obj = new Panels().init(); |
||||
|
}); |
||||
|
|
||||
|
afterEach(() => { |
||||
|
obj = null; |
||||
|
}); |
||||
|
|
||||
|
it('Object exists', () => { |
||||
|
expect(obj).toExist(); |
||||
|
}); |
||||
|
|
||||
|
it("No panels inside", () => { |
||||
|
expect(obj.getPanels().length).toEqual(3); |
||||
|
}); |
||||
|
|
||||
|
it("Adds new panel correctly via object", () => { |
||||
|
var panel = obj.addPanel({id: 'test'}); |
||||
|
expect(panel.get('id')).toEqual('test'); |
||||
|
}); |
||||
|
|
||||
|
it("New panel has no buttons", () => { |
||||
|
var panel = obj.addPanel({id: 'test'}); |
||||
|
expect(panel.get('buttons').length).toEqual(0); |
||||
|
}); |
||||
|
|
||||
|
it("Adds new panel correctly via Panel instance", () => { |
||||
|
var oPanel = new obj.Panel({id: 'test'}); |
||||
|
var panel = obj.addPanel(oPanel); |
||||
|
expect(panel).toEqual(oPanel); |
||||
|
expect(panel.get('id')).toEqual('test'); |
||||
|
}); |
||||
|
|
||||
|
it("getPanel returns null in case there is no requested panel", () => { |
||||
|
expect(obj.getPanel('test')).toEqual(null); |
||||
|
}); |
||||
|
|
||||
|
it("getPanel returns correctly the panel", () => { |
||||
|
var panel = obj.addPanel({id: 'test'}); |
||||
|
expect(obj.getPanel('test')).toEqual(panel); |
||||
|
}); |
||||
|
|
||||
|
it("Can't add button to non existent panel", () => { |
||||
|
expect(obj.addButton('test', {id:'btn'})).toEqual(null); |
||||
|
}); |
||||
|
|
||||
|
it("Add button correctly", () => { |
||||
|
var panel = obj.addPanel({id: 'test'}); |
||||
|
var btn = obj.addButton('test', {id:'btn'}); |
||||
|
expect(panel.get('buttons').length).toEqual(1); |
||||
|
expect(panel.get('buttons').at(0).get('id')).toEqual('btn'); |
||||
|
}); |
||||
|
|
||||
|
it("getButton returns null in case there is no requested panel", () => { |
||||
|
expect(obj.addButton('test', 'btn')).toEqual(null); |
||||
|
}); |
||||
|
|
||||
|
it("getButton returns null in case there is no requested button", () => { |
||||
|
var panel = obj.addPanel({id: 'test'}); |
||||
|
expect(obj.getButton('test', 'btn')).toEqual(null); |
||||
|
}); |
||||
|
|
||||
|
it("getButton returns correctly the button", () => { |
||||
|
var panel = obj.addPanel({id: 'test'}); |
||||
|
var btn = obj.addButton('test', {id:'btn'}); |
||||
|
expect(obj.getButton('test', 'btn')).toEqual(btn); |
||||
|
}); |
||||
|
|
||||
|
it("Renders correctly", () => { |
||||
|
expect(obj.render()).toExist(); |
||||
|
}); |
||||
|
|
||||
|
it("Active correctly activable buttons", () => { |
||||
|
var spy = sinon.spy(); |
||||
|
var panel = obj.addPanel({id: 'test'}); |
||||
|
var btn = obj.addButton('test', {id:'btn', active: true}); |
||||
|
btn.on('updateActive', spy); |
||||
|
obj.active(); |
||||
|
expect(spy.called).toEqual(true); |
||||
|
}); |
||||
|
|
||||
|
}); |
||||
|
|
||||
|
Models.run(); |
||||
|
PanelView.run(); |
||||
|
PanelsView.run(); |
||||
|
ButtonView.run(); |
||||
|
ButtonsView.run(); |
||||
|
e2e.run(); |
||||
|
}); |
||||
@ -1,102 +0,0 @@ |
|||||
define(function(require, exports, module){ |
|
||||
'use strict'; |
|
||||
var Panels = require('Panels'); |
|
||||
var e2e = require('undefined'); |
|
||||
|
|
||||
describe('Panels', function() { |
|
||||
|
|
||||
describe('Main', function() { |
|
||||
|
|
||||
var obj; |
|
||||
|
|
||||
beforeEach(function () { |
|
||||
obj = new Panels().init(); |
|
||||
}); |
|
||||
|
|
||||
afterEach(function () { |
|
||||
delete obj; |
|
||||
}); |
|
||||
|
|
||||
it('Object exists', function() { |
|
||||
obj.should.be.exist; |
|
||||
}); |
|
||||
|
|
||||
it("No panels inside", function() { |
|
||||
obj.getPanels().length.should.equal(3); |
|
||||
}); |
|
||||
|
|
||||
it("Adds new panel correctly via object", function() { |
|
||||
var panel = obj.addPanel({id: 'test'}); |
|
||||
panel.get('id').should.equal('test'); |
|
||||
}); |
|
||||
|
|
||||
it("New panel has no buttons", function() { |
|
||||
var panel = obj.addPanel({id: 'test'}); |
|
||||
panel.get('buttons').length.should.equal(0); |
|
||||
}); |
|
||||
|
|
||||
it("Adds new panel correctly via Panel instance", function() { |
|
||||
var oPanel = new obj.Panel({id: 'test'}); |
|
||||
var panel = obj.addPanel(oPanel); |
|
||||
panel.should.deep.equal(oPanel); |
|
||||
panel.get('id').should.equal('test'); |
|
||||
}); |
|
||||
|
|
||||
it("getPanel returns null in case there is no requested panel", function() { |
|
||||
(obj.getPanel('test') == null).should.equal(true); |
|
||||
}); |
|
||||
|
|
||||
it("getPanel returns correctly the panel", function() { |
|
||||
var panel = obj.addPanel({id: 'test'}); |
|
||||
obj.getPanel('test').should.deep.equal(panel); |
|
||||
}); |
|
||||
|
|
||||
it("Can't add button to non existent panel", function() { |
|
||||
(obj.addButton('test', {id:'btn'}) == null).should.equal(true); |
|
||||
}); |
|
||||
|
|
||||
it("Add button correctly", function() { |
|
||||
var panel = obj.addPanel({id: 'test'}); |
|
||||
var btn = obj.addButton('test', {id:'btn'}); |
|
||||
panel.get('buttons').length.should.equal(1); |
|
||||
panel.get('buttons').at(0).get('id').should.equal('btn'); |
|
||||
}); |
|
||||
|
|
||||
it("getButton returns null in case there is no requested panel", function() { |
|
||||
(obj.getButton('test', 'btn') == null).should.equal(true); |
|
||||
}); |
|
||||
|
|
||||
it("getButton returns null in case there is no requested button", function() { |
|
||||
var panel = obj.addPanel({id: 'test'}); |
|
||||
(obj.getButton('test', 'btn') == null).should.equal(true); |
|
||||
}); |
|
||||
|
|
||||
it("getButton returns correctly the button", function() { |
|
||||
var panel = obj.addPanel({id: 'test'}); |
|
||||
var btn = obj.addButton('test', {id:'btn'}); |
|
||||
obj.getButton('test', 'btn').should.deep.equal(btn); |
|
||||
}); |
|
||||
|
|
||||
it("Renders correctly", function() { |
|
||||
obj.render().should.be.ok; |
|
||||
}); |
|
||||
|
|
||||
it("Active correctly activable buttons", function() { |
|
||||
var spy = sinon.spy(); |
|
||||
var panel = obj.addPanel({id: 'test'}); |
|
||||
var btn = obj.addButton('test', {id:'btn', active: true}); |
|
||||
btn.on('updateActive', spy); |
|
||||
obj.active(); |
|
||||
spy.called.should.equal(true); |
|
||||
}); |
|
||||
|
|
||||
}); |
|
||||
|
|
||||
Models.run(); |
|
||||
PanelView.run(); |
|
||||
PanelsView.run(); |
|
||||
ButtonView.run(); |
|
||||
ButtonsView.run(); |
|
||||
e2e.run(); |
|
||||
}); |
|
||||
}); |
|
||||
@ -1,120 +1,119 @@ |
|||||
define(function(require, exports, module){ |
const Panels = require('panels'); |
||||
'use strict'; |
const Button = require('panels/model/Button'); |
||||
var Panels = require('undefined'); |
const Buttons = require('panels/model/Buttons'); |
||||
|
const Panel = require('panels/model/Panel'); |
||||
|
|
||||
module.exports = { |
module.exports = { |
||||
run : function(){ |
run() { |
||||
describe('Button', function() { |
describe('Button', () => { |
||||
|
|
||||
var obj; |
var obj; |
||||
|
|
||||
beforeEach(function () { |
beforeEach(() => { |
||||
obj = new Button(); |
obj = new Button(); |
||||
}); |
}); |
||||
|
|
||||
afterEach(function () { |
afterEach(() => { |
||||
delete obj; |
obj = null; |
||||
}); |
}); |
||||
|
|
||||
it('Has buttons instance', function() { |
it('Has buttons instance', () => { |
||||
obj.has('buttons').should.equal(true); |
expect(obj.has('buttons')).toEqual(true); |
||||
}); |
}); |
||||
|
|
||||
it('Has no buttons', function() { |
it('Has no buttons', () => { |
||||
obj.get('buttons').length.should.equal(0); |
expect(obj.get('buttons').length).toEqual(0); |
||||
}); |
}); |
||||
|
|
||||
it('Init with other buttons inside correctly', function() { |
|
||||
obj = new Button({ |
|
||||
buttons: [{}] |
|
||||
}); |
|
||||
obj.get('buttons').should.be.instanceOf(Buttons); |
|
||||
obj.get('buttons').length.should.equal(1); |
|
||||
}); |
|
||||
|
|
||||
}); |
|
||||
|
|
||||
describe('Buttons', function() { |
|
||||
var obj; |
|
||||
|
|
||||
beforeEach(function () { |
|
||||
obj = new Buttons(); |
|
||||
}); |
|
||||
|
|
||||
afterEach(function () { |
|
||||
delete obj; |
|
||||
}); |
|
||||
|
|
||||
it('Deactivates buttons', function() { |
|
||||
obj.add({ active: true }); |
|
||||
obj.deactivateAll(); |
|
||||
obj.at(0).get('active').should.equal(false); |
|
||||
}); |
|
||||
|
|
||||
it('Deactivates buttons with context', function() { |
|
||||
obj.add({ active: true }); |
|
||||
obj.deactivateAll('someContext'); |
|
||||
obj.at(0).get('active').should.equal(true); |
|
||||
}); |
|
||||
|
|
||||
it('Deactivates except one', function() { |
|
||||
var btn = obj.add({ active: true }); |
|
||||
obj.deactivateAllExceptOne(); |
|
||||
obj.at(0).get('active').should.equal(false); |
|
||||
}); |
|
||||
|
|
||||
it('Deactivates except one with model', function() { |
|
||||
var btn = obj.add({ active: true }); |
|
||||
obj.deactivateAllExceptOne(btn); |
|
||||
obj.at(0).get('active').should.equal(true); |
|
||||
}); |
|
||||
|
|
||||
|
it('Init with other buttons inside correctly', () => { |
||||
|
obj = new Button({ |
||||
|
buttons: [{}] |
||||
}); |
}); |
||||
|
expect(obj.get('buttons') instanceof Buttons).toEqual(true); |
||||
describe('Panel', function() { |
expect(obj.get('buttons').length).toEqual(1); |
||||
var obj; |
}); |
||||
|
|
||||
beforeEach(function () { |
}); |
||||
obj = new Panel(); |
|
||||
}); |
describe('Buttons', () => { |
||||
|
var obj; |
||||
afterEach(function () { |
|
||||
delete obj; |
beforeEach(() => { |
||||
}); |
obj = new Buttons(); |
||||
|
}); |
||||
it('Has buttons instance', function() { |
|
||||
obj.has('buttons').should.equal(true); |
afterEach(() => { |
||||
obj.get('buttons').should.be.instanceOf(Buttons); |
obj = null; |
||||
}); |
}); |
||||
|
|
||||
it('Has no buttons', function() { |
it('Deactivates buttons', () => { |
||||
obj.get('buttons').length.should.equal(0); |
obj.add({ active: true }); |
||||
}); |
obj.deactivateAll(); |
||||
|
expect(obj.at(0).get('active')).toEqual(false); |
||||
it('Init with buttons inside correctly', function() { |
}); |
||||
obj = new Panel({ |
|
||||
buttons: [{}] |
it('Deactivates buttons with context', () => { |
||||
}); |
obj.add({ active: true }); |
||||
obj.get('buttons').should.be.instanceOf(Buttons); |
obj.deactivateAll('someContext'); |
||||
obj.get('buttons').length.should.equal(1); |
expect(obj.at(0).get('active')).toEqual(true); |
||||
}); |
}); |
||||
|
|
||||
|
it('Deactivates except one', () => { |
||||
|
var btn = obj.add({ active: true }); |
||||
|
obj.deactivateAllExceptOne(); |
||||
|
expect(obj.at(0).get('active')).toEqual(false); |
||||
|
}); |
||||
|
|
||||
|
it('Deactivates except one with model', () => { |
||||
|
var btn = obj.add({ active: true }); |
||||
|
obj.deactivateAllExceptOne(btn); |
||||
|
expect(obj.at(0).get('active')).toEqual(true); |
||||
|
}); |
||||
|
|
||||
|
}); |
||||
|
|
||||
|
describe('Panel', () => { |
||||
|
var obj; |
||||
|
|
||||
|
beforeEach(() => { |
||||
|
obj = new Panel(); |
||||
|
}); |
||||
|
|
||||
|
afterEach(() => { |
||||
|
obj = null; |
||||
|
}); |
||||
|
|
||||
|
it('Has buttons instance', () => { |
||||
|
expect(obj.has('buttons')).toEqual(true); |
||||
|
expect(obj.get('buttons') instanceof Buttons).toEqual(true); |
||||
|
}); |
||||
|
|
||||
|
it('Has no buttons', () => { |
||||
|
expect(obj.get('buttons').length).toEqual(0); |
||||
|
}); |
||||
|
|
||||
|
it('Init with buttons inside correctly', () => { |
||||
|
obj = new Panel({ |
||||
|
buttons: [{}] |
||||
}); |
}); |
||||
|
expect(obj.get('buttons') instanceof Buttons).toEqual(true); |
||||
|
expect(obj.get('buttons').length).toEqual(1); |
||||
|
}); |
||||
|
|
||||
describe('Panels', function() { |
}); |
||||
var obj; |
|
||||
|
|
||||
beforeEach(function () { |
describe('Panels', () => { |
||||
obj = new Panel(); |
var obj; |
||||
}); |
|
||||
|
|
||||
afterEach(function () { |
beforeEach(() => { |
||||
delete obj; |
obj = new Panel(); |
||||
}); |
}); |
||||
|
|
||||
}); |
afterEach(() => { |
||||
|
obj = null; |
||||
|
}); |
||||
|
|
||||
} |
}); |
||||
}; |
|
||||
|
|
||||
}); |
} |
||||
|
}; |
||||
|
|||||
@ -1,77 +1,73 @@ |
|||||
define(function(require, exports, module){ |
const ButtonView = require('panels/view/ButtonView'); |
||||
'use strict'; |
const Button = require('panels/model/Button'); |
||||
var ButtonView = require('undefined'); |
|
||||
var Button = require('Panels/model/Button'); |
|
||||
|
|
||||
module.exports = { |
module.exports = { |
||||
run : function(){ |
run() { |
||||
|
|
||||
describe('ButtonView', function() { |
describe('ButtonView', () => { |
||||
|
|
||||
var $fixtures; |
var $fixtures; |
||||
var $fixture; |
var $fixture; |
||||
var model; |
var model; |
||||
var view; |
var view; |
||||
var btnClass = 'btn'; |
var btnClass = 'btn'; |
||||
|
|
||||
before(function () { |
before(() => { |
||||
$fixtures = $("#fixtures"); |
$fixtures = $("#fixtures"); |
||||
$fixture = $('<div class="cssrule-fixture"></div>'); |
$fixture = $('<div class="cssrule-fixture"></div>'); |
||||
}); |
}); |
||||
|
|
||||
beforeEach(function () { |
|
||||
model = new Button(); |
|
||||
view = new ButtonView({ |
|
||||
model: model |
|
||||
}); |
|
||||
$fixture.empty().appendTo($fixtures); |
|
||||
$fixture.html(view.render().el); |
|
||||
}); |
|
||||
|
|
||||
afterEach(function () { |
beforeEach(() => { |
||||
view.remove(); |
model = new Button(); |
||||
}); |
view = new ButtonView({ |
||||
|
model |
||||
|
}); |
||||
|
$fixture.empty().appendTo($fixtures); |
||||
|
$fixture.html(view.render().el); |
||||
|
}); |
||||
|
|
||||
after(function () { |
afterEach(() => { |
||||
$fixture.remove(); |
view.remove(); |
||||
}); |
}); |
||||
|
|
||||
it('Button empty', function() { |
after(() => { |
||||
$fixture.html().should.be.equal('<span class="' + btnClass+ '"></span>'); |
$fixture.remove(); |
||||
}); |
}); |
||||
|
|
||||
it('Update class', function() { |
it('Button empty', () => { |
||||
model.set('className','test'); |
expect($fixture.html()).toEqual('<span class="' + btnClass+ '"></span>'); |
||||
view.el.getAttribute('class').should.be.equal(btnClass + ' test'); |
}); |
||||
}); |
|
||||
|
|
||||
it('Update attributes', function() { |
it('Update class', () => { |
||||
model.set('attributes',{ |
model.set('className','test'); |
||||
'data-test': 'test-value' |
expect(view.el.getAttribute('class')).toEqual(btnClass + ' test'); |
||||
}); |
}); |
||||
view.el.getAttribute('data-test').should.be.equal('test-value'); |
|
||||
}); |
|
||||
|
|
||||
it('Check enable active', function() { |
it('Update attributes', () => { |
||||
model.set('active', true, {silent: true}); |
model.set('attributes',{ |
||||
view.checkActive(); |
'data-test': 'test-value' |
||||
view.el.getAttribute('class').should.be.equal(btnClass + ' active'); |
}); |
||||
}); |
expect(view.el.getAttribute('data-test')).toEqual('test-value'); |
||||
|
}); |
||||
|
|
||||
it('Check disable active', function() { |
it('Check enable active', () => { |
||||
model.set('active', true, {silent: true}); |
model.set('active', true, {silent: true}); |
||||
view.checkActive(); |
view.checkActive(); |
||||
model.set('active', false, {silent: true}); |
expect(view.el.getAttribute('class')).toEqual(btnClass + ' active'); |
||||
view.checkActive(); |
}); |
||||
view.el.getAttribute('class').should.be.equal(btnClass); |
|
||||
}); |
|
||||
|
|
||||
it('Renders correctly', function() { |
it('Check disable active', () => { |
||||
view.render().should.be.ok; |
model.set('active', true, {silent: true}); |
||||
}); |
view.checkActive(); |
||||
|
model.set('active', false, {silent: true}); |
||||
|
view.checkActive(); |
||||
|
expect(view.el.getAttribute('class')).toEqual(btnClass); |
||||
|
}); |
||||
|
|
||||
|
it('Renders correctly', () => { |
||||
|
expect(view.render()).toExist(); |
||||
}); |
}); |
||||
} |
|
||||
}; |
|
||||
|
|
||||
}); |
}); |
||||
|
} |
||||
|
}; |
||||
|
|||||
@ -1,56 +1,52 @@ |
|||||
define(function(require, exports, module){ |
const ButtonsView = require('panels/view/ButtonsView'); |
||||
'use strict'; |
const Buttons = require('panels/model/Buttons'); |
||||
var ButtonsView = require('undefined'); |
|
||||
var Buttons = require('Panels/model/Buttons'); |
|
||||
|
|
||||
module.exports = { |
|
||||
run : function(){ |
|
||||
describe('ButtonsView', function() { |
|
||||
|
|
||||
var $fixtures; |
|
||||
var $fixture; |
|
||||
var model; |
|
||||
var view; |
|
||||
|
|
||||
before(function () { |
|
||||
$fixtures = $("#fixtures"); |
|
||||
$fixture = $('<div class="cssrules-fixture"></div>'); |
|
||||
}); |
|
||||
|
|
||||
beforeEach(function () { |
|
||||
model = new Buttons([]); |
|
||||
view = new ButtonsView({ |
|
||||
collection: model |
|
||||
}); |
|
||||
$fixture.empty().appendTo($fixtures); |
|
||||
$fixture.html(view.render().el); |
|
||||
}); |
|
||||
|
|
||||
afterEach(function () { |
|
||||
view.collection.reset(); |
|
||||
}); |
|
||||
|
|
||||
after(function () { |
|
||||
$fixture.remove(); |
|
||||
}); |
|
||||
|
|
||||
it("Collection is empty", function (){ |
|
||||
view.$el.html().should.be.empty; |
|
||||
}); |
|
||||
|
|
||||
it("Add new button", function (){ |
|
||||
sinon.stub(view, "addToCollection"); |
|
||||
view.collection.add({}); |
|
||||
view.addToCollection.calledOnce.should.equal(true); |
|
||||
}); |
|
||||
|
|
||||
it("Render new button", function (){ |
|
||||
view.collection.add({}); |
|
||||
view.$el.html().should.not.be.empty; |
|
||||
}); |
|
||||
|
|
||||
|
module.exports = { |
||||
|
run() { |
||||
|
describe('ButtonsView', () => { |
||||
|
|
||||
|
var $fixtures; |
||||
|
var $fixture; |
||||
|
var model; |
||||
|
var view; |
||||
|
|
||||
|
before(() => { |
||||
|
$fixtures = $("#fixtures"); |
||||
|
$fixture = $('<div class="cssrules-fixture"></div>'); |
||||
|
}); |
||||
|
|
||||
|
beforeEach(() => { |
||||
|
model = new Buttons([]); |
||||
|
view = new ButtonsView({ |
||||
|
collection: model |
||||
|
}); |
||||
|
$fixture.empty().appendTo($fixtures); |
||||
|
$fixture.html(view.render().el); |
||||
|
}); |
||||
|
|
||||
|
afterEach(() => { |
||||
|
view.collection.reset(); |
||||
|
}); |
||||
|
|
||||
|
after(() => { |
||||
|
$fixture.remove(); |
||||
|
}); |
||||
|
|
||||
|
it("Collection is empty", () => { |
||||
|
expect(view.$el.html()).toEqual(''); |
||||
|
}); |
||||
|
|
||||
|
it("Add new button", () => { |
||||
|
sinon.stub(view, "addToCollection"); |
||||
|
view.collection.add({}); |
||||
|
expect(view.addToCollection.calledOnce).toEqual(true); |
||||
|
}); |
||||
|
|
||||
|
it("Render new button", () => { |
||||
|
view.collection.add({}); |
||||
|
expect(view.$el.html()).toExist(); |
||||
}); |
}); |
||||
} |
|
||||
}; |
|
||||
|
|
||||
}); |
}); |
||||
|
} |
||||
|
}; |
||||
|
|||||
@ -1,77 +1,73 @@ |
|||||
define(function(require, exports, module){ |
const PanelView = require('panels/view/PanelView'); |
||||
'use strict'; |
const Panel = require('panels/model/Panel'); |
||||
var PanelView = require('undefined'); |
|
||||
var Panel = require('Panels/model/Panel'); |
|
||||
|
|
||||
module.exports = { |
module.exports = { |
||||
run : function(){ |
run() { |
||||
|
|
||||
describe('PanelView', function() { |
describe('PanelView', () => { |
||||
|
|
||||
var $fixtures; |
var $fixtures; |
||||
var $fixture; |
var $fixture; |
||||
var model; |
var model; |
||||
var view; |
var view; |
||||
|
|
||||
before(function () { |
before(() => { |
||||
$fixtures = $("#fixtures"); |
$fixtures = $("#fixtures"); |
||||
$fixture = $('<div class="cssrule-fixture"></div>'); |
$fixture = $('<div class="cssrule-fixture"></div>'); |
||||
}); |
}); |
||||
|
|
||||
beforeEach(function () { |
|
||||
model = new Panel(); |
|
||||
view = new PanelView({ |
|
||||
model: model |
|
||||
}); |
|
||||
$fixture.empty().appendTo($fixtures); |
|
||||
$fixture.html(view.render().el); |
|
||||
}); |
|
||||
|
|
||||
afterEach(function () { |
|
||||
view.remove(); |
|
||||
}); |
|
||||
|
|
||||
after(function () { |
beforeEach(() => { |
||||
$fixture.remove(); |
model = new Panel(); |
||||
}); |
view = new PanelView({ |
||||
|
model |
||||
|
}); |
||||
|
$fixture.empty().appendTo($fixtures); |
||||
|
$fixture.html(view.render().el); |
||||
|
}); |
||||
|
|
||||
it('Panel empty', function() { |
afterEach(() => { |
||||
$fixture.html().should.be.equal('<div class="panel"></div>'); |
view.remove(); |
||||
}); |
}); |
||||
|
|
||||
it('Append content', function() { |
after(() => { |
||||
model.set('appendContent','test'); |
$fixture.remove(); |
||||
model.set('appendContent','test2'); |
}); |
||||
view.$el.html().should.be.equal('testtest2'); |
|
||||
}); |
|
||||
|
|
||||
it('Update content', function() { |
it('Panel empty', () => { |
||||
model.set('content','test'); |
expect($fixture.html()).toEqual('<div class="panel"></div>'); |
||||
model.set('content','test2'); |
}); |
||||
view.$el.html().should.be.equal('test2'); |
|
||||
}); |
|
||||
|
|
||||
describe('Init with options', function() { |
it('Append content', () => { |
||||
|
model.set('appendContent','test'); |
||||
|
model.set('appendContent','test2'); |
||||
|
expect(view.$el.html()).toEqual('testtest2'); |
||||
|
}); |
||||
|
|
||||
beforeEach(function () { |
it('Update content', () => { |
||||
model = new Panel({ |
model.set('content','test'); |
||||
buttons: [{}] |
model.set('content','test2'); |
||||
}); |
expect(view.$el.html()).toEqual('test2'); |
||||
view = new PanelView({ |
}); |
||||
model: model |
|
||||
}); |
|
||||
$fixture.empty().appendTo($fixtures); |
|
||||
$fixture.html(view.render().el); |
|
||||
}); |
|
||||
|
|
||||
afterEach(function () { |
describe('Init with options', () => { |
||||
view.remove(); |
|
||||
}); |
|
||||
|
|
||||
|
beforeEach(() => { |
||||
|
model = new Panel({ |
||||
|
buttons: [{}] |
||||
}); |
}); |
||||
|
view = new PanelView({ |
||||
|
model |
||||
|
}); |
||||
|
$fixture.empty().appendTo($fixtures); |
||||
|
$fixture.html(view.render().el); |
||||
|
}); |
||||
|
|
||||
|
afterEach(() => { |
||||
|
view.remove(); |
||||
|
}); |
||||
|
|
||||
}); |
}); |
||||
} |
|
||||
}; |
|
||||
|
|
||||
}); |
}); |
||||
|
} |
||||
|
}; |
||||
|
|||||
@ -1,56 +1,52 @@ |
|||||
define(function(require, exports, module){ |
const PanelsView = require('panels/view/PanelsView'); |
||||
'use strict'; |
const Panels = require('panels/model/Panels'); |
||||
var PanelsView = require('undefined'); |
|
||||
var Panels = require('Panels/model/Panels'); |
|
||||
|
|
||||
module.exports = { |
|
||||
run : function(){ |
|
||||
describe('PanelsView', function() { |
|
||||
|
|
||||
var $fixtures; |
|
||||
var $fixture; |
|
||||
var model; |
|
||||
var view; |
|
||||
|
|
||||
before(function () { |
|
||||
$fixtures = $("#fixtures"); |
|
||||
$fixture = $('<div class="cssrules-fixture"></div>'); |
|
||||
}); |
|
||||
|
|
||||
beforeEach(function () { |
|
||||
model = new Panels([]); |
|
||||
view = new PanelsView({ |
|
||||
collection: model |
|
||||
}); |
|
||||
$fixture.empty().appendTo($fixtures); |
|
||||
$fixture.html(view.render().el); |
|
||||
}); |
|
||||
|
|
||||
afterEach(function () { |
|
||||
view.collection.reset(); |
|
||||
}); |
|
||||
|
|
||||
after(function () { |
|
||||
$fixture.remove(); |
|
||||
}); |
|
||||
|
|
||||
it("Collection is empty", function (){ |
|
||||
view.$el.html().should.be.empty; |
|
||||
}); |
|
||||
|
|
||||
it("Add new panel", function (){ |
|
||||
sinon.stub(view, "addToCollection"); |
|
||||
view.collection.add({}); |
|
||||
view.addToCollection.calledOnce.should.equal(true); |
|
||||
}); |
|
||||
|
|
||||
it("Render new panel", function (){ |
|
||||
view.collection.add({}); |
|
||||
view.$el.html().should.not.be.empty; |
|
||||
}); |
|
||||
|
|
||||
|
module.exports = { |
||||
|
run() { |
||||
|
describe('PanelsView', () => { |
||||
|
|
||||
|
var $fixtures; |
||||
|
var $fixture; |
||||
|
var model; |
||||
|
var view; |
||||
|
|
||||
|
before(() => { |
||||
|
$fixtures = $("#fixtures"); |
||||
|
$fixture = $('<div class="cssrules-fixture"></div>'); |
||||
|
}); |
||||
|
|
||||
|
beforeEach(() => { |
||||
|
model = new Panels([]); |
||||
|
view = new PanelsView({ |
||||
|
collection: model |
||||
|
}); |
||||
|
$fixture.empty().appendTo($fixtures); |
||||
|
$fixture.html(view.render().el); |
||||
|
}); |
||||
|
|
||||
|
afterEach(() => { |
||||
|
view.collection.reset(); |
||||
|
}); |
||||
|
|
||||
|
after(() => { |
||||
|
$fixture.remove(); |
||||
|
}); |
||||
|
|
||||
|
it("Collection is empty", () => { |
||||
|
expect(view.$el.html()).toEqual(''); |
||||
|
}); |
||||
|
|
||||
|
it("Add new panel", () => { |
||||
|
sinon.stub(view, "addToCollection"); |
||||
|
view.collection.add({}); |
||||
|
expect(view.addToCollection.calledOnce).toEqual(true); |
||||
|
}); |
||||
|
|
||||
|
it("Render new panel", () => { |
||||
|
view.collection.add({}); |
||||
|
expect(view.$el.html()).toExist(); |
||||
}); |
}); |
||||
} |
|
||||
}; |
|
||||
|
|
||||
}); |
}); |
||||
|
} |
||||
|
}; |
||||
|
|||||
Loading…
Reference in new issue