editor: Update defaults in social block and use stored defaults for new social block

This commit is contained in:
Rostislav Wolny
2018-03-12 15:19:36 +01:00
parent 1df25aef76
commit f6374d0602
2 changed files with 26 additions and 24 deletions

View File

@@ -9,10 +9,17 @@ define([
describe('Social', function () {
describe('block model', function () {
var model;
var sandbox;
beforeEach(function () {
global.stubChannel(EditorApplication);
global.stubConfig(EditorApplication);
model = new (SocialBlock.SocialBlockModel)();
sandbox = sinon.sandbox.create();
});
afterEach(function () {
sandbox.restore();
});
it('has a social type', function () {
@@ -39,6 +46,22 @@ define([
expect(model.get('iconSet')).to.equal('customConfigIconSet');
});
it('updates blockDefaults.social when changed', function () {
var stub = sandbox.stub(EditorApplication.getConfig(), 'set');
model.trigger('change');
expect(stub.callCount).to.equal(1);
expect(stub.getCall(0).args[0]).to.equal('blockDefaults.social');
expect(stub.getCall(0).args[1]).to.deep.equal(model.toJSON());
});
it('updates blockDefaults.social when icons changed', function () {
var stub = sandbox.stub(EditorApplication.getConfig(), 'set');
model.get('icons').trigger('change');
expect(stub.callCount).to.equal(1);
expect(stub.getCall(0).args[0]).to.equal('blockDefaults.social');
expect(stub.getCall(0).args[1]).to.deep.equal(model.toJSON());
});
});
describe('icon model', function () {