Merge pull request #927 from mailpoet/fix-alc-buttons-settings
Fix ALC buttons settings when updating all buttons [MAILPOET-896]
This commit is contained in:
@@ -129,6 +129,12 @@ define([
|
|||||||
|
|
||||||
Module.AutomatedLatestContentBlockView = base.BlockView.extend({
|
Module.AutomatedLatestContentBlockView = base.BlockView.extend({
|
||||||
className: "mailpoet_block mailpoet_automated_latest_content_block mailpoet_droppable_block",
|
className: "mailpoet_block mailpoet_automated_latest_content_block mailpoet_droppable_block",
|
||||||
|
initialize: function() {
|
||||||
|
function replaceButtonStylesHandler(data) {
|
||||||
|
this.model.set({"readMoreButton": data});
|
||||||
|
}
|
||||||
|
App.getChannel().on("replaceAllButtonStyles", replaceButtonStylesHandler.bind(this));
|
||||||
|
},
|
||||||
getTemplate: function() { return templates.automatedLatestContentBlock; },
|
getTemplate: function() { return templates.automatedLatestContentBlock; },
|
||||||
regions: {
|
regions: {
|
||||||
toolsRegion: '.mailpoet_tools',
|
toolsRegion: '.mailpoet_tools',
|
||||||
|
@@ -282,6 +282,43 @@ define([
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('replaceAllButtonStyles', function () {
|
||||||
|
var model, view, module, onStub;
|
||||||
|
|
||||||
|
before(function() {
|
||||||
|
module = AutomatedLatestContentBlock;
|
||||||
|
});
|
||||||
|
|
||||||
|
beforeEach(function () {
|
||||||
|
onStub = sinon.stub()
|
||||||
|
global.stubChannel(EditorApplication, {on: onStub})
|
||||||
|
global.stubConfig(EditorApplication);
|
||||||
|
EditorApplication.getBlockTypeModel = sinon.stub().returns(Backbone.Model);
|
||||||
|
EditorApplication.getBlockTypeView = sinon.stub().returns(Backbone.View);
|
||||||
|
model = {set: sinon.stub()}
|
||||||
|
view = new (module.AutomatedLatestContentBlockView)({model: model});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("listens to the event", function () {
|
||||||
|
expect(onStub).to.have.been.calledOnce;
|
||||||
|
expect(onStub).to.have.been.calledWith("replaceAllButtonStyles", sinon.match.func);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("updates the model", function () {
|
||||||
|
const callback = onStub.getCall(0).args[1];
|
||||||
|
const data = {
|
||||||
|
styles: {
|
||||||
|
block: {
|
||||||
|
borderRadius: "14px",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
callback(data);
|
||||||
|
expect(model.set).to.have.been.calledOnce;
|
||||||
|
expect(model.set).to.have.been.calledWithMatch(sinon.match.has("readMoreButton", data));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('block settings view', function () {
|
describe('block settings view', function () {
|
||||||
var model, view, module;
|
var model, view, module;
|
||||||
|
|
||||||
@@ -510,3 +547,4 @@ define([
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -259,6 +259,38 @@ define([
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('replaceAllButtonStyles', function () {
|
||||||
|
var model, view, onStub;
|
||||||
|
|
||||||
|
|
||||||
|
beforeEach(function () {
|
||||||
|
onStub = sinon.stub()
|
||||||
|
global.stubChannel(EditorApplication, {on: onStub})
|
||||||
|
model = {set: sinon.stub(), toJSON: sinon.stub()}
|
||||||
|
view = new (ButtonBlock.ButtonBlockView)({model: model});
|
||||||
|
view.render();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("listens to the event", function () {
|
||||||
|
expect(onStub).to.have.been.calledOnce;
|
||||||
|
expect(onStub).to.have.been.calledWith("replaceAllButtonStyles", sinon.match.func);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("updates the model", function () {
|
||||||
|
const callback = onStub.getCall(0).args[1];
|
||||||
|
const data = {
|
||||||
|
styles: {
|
||||||
|
block: {
|
||||||
|
borderRadius: "14px",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
callback(data);
|
||||||
|
expect(model.set).to.have.been.calledOnce;
|
||||||
|
expect(model.set).to.have.been.calledWithExactly(data);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('block settings view', function () {
|
describe('block settings view', function () {
|
||||||
var model;
|
var model;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user