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){ |
|||
'use strict'; |
|||
var GrapesJS = require('GrapesJS'); |
|||
module.exports = { |
|||
run() { |
|||
|
|||
module.exports = { |
|||
run : function(){ |
|||
describe('E2E tests', () => { |
|||
|
|||
describe('E2E tests', function() { |
|||
var fixtures; |
|||
var fixture; |
|||
var obj; |
|||
var config; |
|||
var editorName = 'panel-fixture'; |
|||
|
|||
var fixtures; |
|||
var fixture; |
|||
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); |
|||
}); |
|||
before(() => { |
|||
fixtures = $("#fixtures"); |
|||
}); |
|||
|
|||
afterEach(function () { |
|||
delete obj; |
|||
delete config; |
|||
fixture.remove(); |
|||
}); |
|||
beforeEach(() => { |
|||
obj = grapesjs; |
|||
config = { |
|||
container: '#' + editorName, |
|||
storageManager: { autoload: 0, type:'none' }, |
|||
}; |
|||
fixture = $('<div id="' + editorName + '"></div>'); |
|||
fixture.empty().appendTo(fixtures); |
|||
}); |
|||
|
|||
after(function () { |
|||
fixture.remove(); |
|||
}); |
|||
afterEach(() => { |
|||
obj = null; |
|||
config = null; |
|||
fixture.remove(); |
|||
}); |
|||
|
|||
it('Command is correctly executed on button click', function() { |
|||
var commandId = 'command-test'; |
|||
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); |
|||
}); |
|||
after(() => { |
|||
//fixture.remove();
|
|||
}); |
|||
|
|||
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){ |
|||
'use strict'; |
|||
var Panels = require('undefined'); |
|||
const Panels = require('panels'); |
|||
const Button = require('panels/model/Button'); |
|||
const Buttons = require('panels/model/Buttons'); |
|||
const Panel = require('panels/model/Panel'); |
|||
|
|||
module.exports = { |
|||
run : function(){ |
|||
describe('Button', function() { |
|||
module.exports = { |
|||
run() { |
|||
describe('Button', () => { |
|||
|
|||
var obj; |
|||
var obj; |
|||
|
|||
beforeEach(function () { |
|||
obj = new Button(); |
|||
}); |
|||
beforeEach(() => { |
|||
obj = new Button(); |
|||
}); |
|||
|
|||
afterEach(function () { |
|||
delete obj; |
|||
}); |
|||
afterEach(() => { |
|||
obj = null; |
|||
}); |
|||
|
|||
it('Has buttons instance', function() { |
|||
obj.has('buttons').should.equal(true); |
|||
}); |
|||
it('Has buttons instance', () => { |
|||
expect(obj.has('buttons')).toEqual(true); |
|||
}); |
|||
|
|||
it('Has no buttons', function() { |
|||
obj.get('buttons').length.should.equal(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('Has no buttons', () => { |
|||
expect(obj.get('buttons').length).toEqual(0); |
|||
}); |
|||
|
|||
it('Init with other buttons inside correctly', () => { |
|||
obj = new Button({ |
|||
buttons: [{}] |
|||
}); |
|||
|
|||
describe('Panel', function() { |
|||
var obj; |
|||
|
|||
beforeEach(function () { |
|||
obj = new Panel(); |
|||
}); |
|||
|
|||
afterEach(function () { |
|||
delete obj; |
|||
}); |
|||
|
|||
it('Has buttons instance', function() { |
|||
obj.has('buttons').should.equal(true); |
|||
obj.get('buttons').should.be.instanceOf(Buttons); |
|||
}); |
|||
|
|||
it('Has no buttons', function() { |
|||
obj.get('buttons').length.should.equal(0); |
|||
}); |
|||
|
|||
it('Init with buttons inside correctly', function() { |
|||
obj = new Panel({ |
|||
buttons: [{}] |
|||
}); |
|||
obj.get('buttons').should.be.instanceOf(Buttons); |
|||
obj.get('buttons').length.should.equal(1); |
|||
}); |
|||
|
|||
expect(obj.get('buttons') instanceof Buttons).toEqual(true); |
|||
expect(obj.get('buttons').length).toEqual(1); |
|||
}); |
|||
|
|||
}); |
|||
|
|||
describe('Buttons', () => { |
|||
var obj; |
|||
|
|||
beforeEach(() => { |
|||
obj = new Buttons(); |
|||
}); |
|||
|
|||
afterEach(() => { |
|||
obj = null; |
|||
}); |
|||
|
|||
it('Deactivates buttons', () => { |
|||
obj.add({ active: true }); |
|||
obj.deactivateAll(); |
|||
expect(obj.at(0).get('active')).toEqual(false); |
|||
}); |
|||
|
|||
it('Deactivates buttons with context', () => { |
|||
obj.add({ active: true }); |
|||
obj.deactivateAll('someContext'); |
|||
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 () { |
|||
obj = new Panel(); |
|||
}); |
|||
describe('Panels', () => { |
|||
var obj; |
|||
|
|||
afterEach(function () { |
|||
delete obj; |
|||
}); |
|||
beforeEach(() => { |
|||
obj = new Panel(); |
|||
}); |
|||
|
|||
}); |
|||
afterEach(() => { |
|||
obj = null; |
|||
}); |
|||
|
|||
} |
|||
}; |
|||
}); |
|||
|
|||
}); |
|||
} |
|||
}; |
|||
|
|||
@ -1,77 +1,73 @@ |
|||
define(function(require, exports, module){ |
|||
'use strict'; |
|||
var ButtonView = require('undefined'); |
|||
var Button = require('Panels/model/Button'); |
|||
const ButtonView = require('panels/view/ButtonView'); |
|||
const Button = require('panels/model/Button'); |
|||
|
|||
module.exports = { |
|||
run : function(){ |
|||
module.exports = { |
|||
run() { |
|||
|
|||
describe('ButtonView', function() { |
|||
describe('ButtonView', () => { |
|||
|
|||
var $fixtures; |
|||
var $fixture; |
|||
var model; |
|||
var view; |
|||
var btnClass = 'btn'; |
|||
var $fixtures; |
|||
var $fixture; |
|||
var model; |
|||
var view; |
|||
var btnClass = 'btn'; |
|||
|
|||
before(function () { |
|||
$fixtures = $("#fixtures"); |
|||
$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); |
|||
}); |
|||
before(() => { |
|||
$fixtures = $("#fixtures"); |
|||
$fixture = $('<div class="cssrule-fixture"></div>'); |
|||
}); |
|||
|
|||
afterEach(function () { |
|||
view.remove(); |
|||
}); |
|||
beforeEach(() => { |
|||
model = new Button(); |
|||
view = new ButtonView({ |
|||
model |
|||
}); |
|||
$fixture.empty().appendTo($fixtures); |
|||
$fixture.html(view.render().el); |
|||
}); |
|||
|
|||
after(function () { |
|||
$fixture.remove(); |
|||
}); |
|||
afterEach(() => { |
|||
view.remove(); |
|||
}); |
|||
|
|||
it('Button empty', function() { |
|||
$fixture.html().should.be.equal('<span class="' + btnClass+ '"></span>'); |
|||
}); |
|||
after(() => { |
|||
$fixture.remove(); |
|||
}); |
|||
|
|||
it('Update class', function() { |
|||
model.set('className','test'); |
|||
view.el.getAttribute('class').should.be.equal(btnClass + ' test'); |
|||
}); |
|||
it('Button empty', () => { |
|||
expect($fixture.html()).toEqual('<span class="' + btnClass+ '"></span>'); |
|||
}); |
|||
|
|||
it('Update attributes', function() { |
|||
model.set('attributes',{ |
|||
'data-test': 'test-value' |
|||
}); |
|||
view.el.getAttribute('data-test').should.be.equal('test-value'); |
|||
}); |
|||
it('Update class', () => { |
|||
model.set('className','test'); |
|||
expect(view.el.getAttribute('class')).toEqual(btnClass + ' test'); |
|||
}); |
|||
|
|||
it('Check enable active', function() { |
|||
model.set('active', true, {silent: true}); |
|||
view.checkActive(); |
|||
view.el.getAttribute('class').should.be.equal(btnClass + ' active'); |
|||
}); |
|||
it('Update attributes', () => { |
|||
model.set('attributes',{ |
|||
'data-test': 'test-value' |
|||
}); |
|||
expect(view.el.getAttribute('data-test')).toEqual('test-value'); |
|||
}); |
|||
|
|||
it('Check disable active', function() { |
|||
model.set('active', true, {silent: true}); |
|||
view.checkActive(); |
|||
model.set('active', false, {silent: true}); |
|||
view.checkActive(); |
|||
view.el.getAttribute('class').should.be.equal(btnClass); |
|||
}); |
|||
it('Check enable active', () => { |
|||
model.set('active', true, {silent: true}); |
|||
view.checkActive(); |
|||
expect(view.el.getAttribute('class')).toEqual(btnClass + ' active'); |
|||
}); |
|||
|
|||
it('Renders correctly', function() { |
|||
view.render().should.be.ok; |
|||
}); |
|||
it('Check disable active', () => { |
|||
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){ |
|||
'use strict'; |
|||
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; |
|||
}); |
|||
const ButtonsView = require('panels/view/ButtonsView'); |
|||
const Buttons = require('panels/model/Buttons'); |
|||
|
|||
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){ |
|||
'use strict'; |
|||
var PanelView = require('undefined'); |
|||
var Panel = require('Panels/model/Panel'); |
|||
const PanelView = require('panels/view/PanelView'); |
|||
const Panel = require('panels/model/Panel'); |
|||
|
|||
module.exports = { |
|||
run : function(){ |
|||
module.exports = { |
|||
run() { |
|||
|
|||
describe('PanelView', function() { |
|||
describe('PanelView', () => { |
|||
|
|||
var $fixtures; |
|||
var $fixture; |
|||
var model; |
|||
var view; |
|||
var $fixtures; |
|||
var $fixture; |
|||
var model; |
|||
var view; |
|||
|
|||
before(function () { |
|||
$fixtures = $("#fixtures"); |
|||
$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(); |
|||
}); |
|||
before(() => { |
|||
$fixtures = $("#fixtures"); |
|||
$fixture = $('<div class="cssrule-fixture"></div>'); |
|||
}); |
|||
|
|||
after(function () { |
|||
$fixture.remove(); |
|||
}); |
|||
beforeEach(() => { |
|||
model = new Panel(); |
|||
view = new PanelView({ |
|||
model |
|||
}); |
|||
$fixture.empty().appendTo($fixtures); |
|||
$fixture.html(view.render().el); |
|||
}); |
|||
|
|||
it('Panel empty', function() { |
|||
$fixture.html().should.be.equal('<div class="panel"></div>'); |
|||
}); |
|||
afterEach(() => { |
|||
view.remove(); |
|||
}); |
|||
|
|||
it('Append content', function() { |
|||
model.set('appendContent','test'); |
|||
model.set('appendContent','test2'); |
|||
view.$el.html().should.be.equal('testtest2'); |
|||
}); |
|||
after(() => { |
|||
$fixture.remove(); |
|||
}); |
|||
|
|||
it('Update content', function() { |
|||
model.set('content','test'); |
|||
model.set('content','test2'); |
|||
view.$el.html().should.be.equal('test2'); |
|||
}); |
|||
it('Panel empty', () => { |
|||
expect($fixture.html()).toEqual('<div class="panel"></div>'); |
|||
}); |
|||
|
|||
describe('Init with options', function() { |
|||
it('Append content', () => { |
|||
model.set('appendContent','test'); |
|||
model.set('appendContent','test2'); |
|||
expect(view.$el.html()).toEqual('testtest2'); |
|||
}); |
|||
|
|||
beforeEach(function () { |
|||
model = new Panel({ |
|||
buttons: [{}] |
|||
}); |
|||
view = new PanelView({ |
|||
model: model |
|||
}); |
|||
$fixture.empty().appendTo($fixtures); |
|||
$fixture.html(view.render().el); |
|||
}); |
|||
it('Update content', () => { |
|||
model.set('content','test'); |
|||
model.set('content','test2'); |
|||
expect(view.$el.html()).toEqual('test2'); |
|||
}); |
|||
|
|||
afterEach(function () { |
|||
view.remove(); |
|||
}); |
|||
describe('Init with options', () => { |
|||
|
|||
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){ |
|||
'use strict'; |
|||
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; |
|||
}); |
|||
const PanelsView = require('panels/view/PanelsView'); |
|||
const Panels = require('panels/model/Panels'); |
|||
|
|||
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