Reindent code by 2 spaces, instead of 4
This commit is contained in:
@@ -4,12 +4,12 @@ define('test/newsletter_editor/components/config', [
|
||||
], function(EditorApplication) {
|
||||
|
||||
describe('Config', function () {
|
||||
it('loads and stores configuration', function() {
|
||||
EditorApplication.module('components.config').setConfig({
|
||||
testConfig: 'testValue',
|
||||
});
|
||||
var model = EditorApplication.module('components.config').getConfig();
|
||||
expect(model.get('testConfig')).to.equal('testValue');
|
||||
it('loads and stores configuration', function() {
|
||||
EditorApplication.module('components.config').setConfig({
|
||||
testConfig: 'testValue',
|
||||
});
|
||||
var model = EditorApplication.module('components.config').getConfig();
|
||||
expect(model.get('testConfig')).to.equal('testValue');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -4,85 +4,85 @@ define('test/newsletter_editor/components/content', [
|
||||
], function(EditorApplication) {
|
||||
|
||||
describe('Content', function() {
|
||||
describe('newsletter model', function() {
|
||||
var model;
|
||||
describe('newsletter model', function() {
|
||||
var model;
|
||||
|
||||
beforeEach(function() {
|
||||
model = new (EditorApplication.module('components.content').NewsletterModel)({
|
||||
styles: {
|
||||
style1: 'style1Value',
|
||||
style2: 'style2Value',
|
||||
},
|
||||
data: {
|
||||
data1: 'data1Value',
|
||||
data2: 'data2Value',
|
||||
},
|
||||
someField: 'someValue'
|
||||
});
|
||||
});
|
||||
|
||||
it('triggers autosave on change', function() {
|
||||
var mock = sinon.mock({ trigger: function() {} }).expects('trigger').once().withArgs('autoSave');
|
||||
global.stubChannel(EditorApplication, {
|
||||
trigger: mock,
|
||||
});
|
||||
model.set('someField', 'anotherValue');
|
||||
mock.verify();
|
||||
});
|
||||
|
||||
it('does not include styles and data attributes in its JSON', function() {
|
||||
var json = model.toJSON();
|
||||
expect(json).to.deep.equal({someField: 'someValue'});
|
||||
});
|
||||
beforeEach(function() {
|
||||
model = new (EditorApplication.module('components.content').NewsletterModel)({
|
||||
styles: {
|
||||
style1: 'style1Value',
|
||||
style2: 'style2Value',
|
||||
},
|
||||
data: {
|
||||
data1: 'data1Value',
|
||||
data2: 'data2Value',
|
||||
},
|
||||
someField: 'someValue'
|
||||
});
|
||||
});
|
||||
|
||||
describe('block types', function() {
|
||||
it('registers a block type view and model', function() {
|
||||
var blockModel = new Backbone.SuperModel(),
|
||||
blockView = new Backbone.View();
|
||||
EditorApplication.module('components.content').registerBlockType('testType', {
|
||||
blockModel: blockModel,
|
||||
blockView: blockView,
|
||||
});
|
||||
expect(EditorApplication.module('components.content').getBlockTypeModel('testType')).to.deep.equal(blockModel);
|
||||
expect(EditorApplication.module('components.content').getBlockTypeView('testType')).to.deep.equal(blockView);
|
||||
});
|
||||
it('triggers autosave on change', function() {
|
||||
var mock = sinon.mock({ trigger: function() {} }).expects('trigger').once().withArgs('autoSave');
|
||||
global.stubChannel(EditorApplication, {
|
||||
trigger: mock,
|
||||
});
|
||||
model.set('someField', 'anotherValue');
|
||||
mock.verify();
|
||||
});
|
||||
|
||||
describe('transformation to json', function() {
|
||||
it('includes data, styles and initial newsletter fields', function() {
|
||||
var dataField = {
|
||||
containerModelField: 'containerModelValue',
|
||||
}, stylesField = {
|
||||
globalStylesField: 'globalStylesValue',
|
||||
}, newsletterFields = {
|
||||
newsletter_subject: 'test newsletter subject',
|
||||
};
|
||||
EditorApplication._contentContainer = {
|
||||
toJSON: function() {
|
||||
return dataField;
|
||||
}
|
||||
};
|
||||
EditorApplication.getGlobalStyles = function() {
|
||||
return {
|
||||
toJSON: function() {
|
||||
return stylesField;
|
||||
},
|
||||
};
|
||||
};
|
||||
EditorApplication.getNewsletter = function() {
|
||||
return {
|
||||
toJSON: function() {
|
||||
return newsletterFields;
|
||||
},
|
||||
};
|
||||
};
|
||||
var json = EditorApplication.module('components.content').toJSON();
|
||||
expect(json).to.deep.equal(_.extend({
|
||||
data: dataField,
|
||||
styles: stylesField
|
||||
}, newsletterFields));
|
||||
});
|
||||
it('does not include styles and data attributes in its JSON', function() {
|
||||
var json = model.toJSON();
|
||||
expect(json).to.deep.equal({someField: 'someValue'});
|
||||
});
|
||||
});
|
||||
|
||||
describe('block types', function() {
|
||||
it('registers a block type view and model', function() {
|
||||
var blockModel = new Backbone.SuperModel(),
|
||||
blockView = new Backbone.View();
|
||||
EditorApplication.module('components.content').registerBlockType('testType', {
|
||||
blockModel: blockModel,
|
||||
blockView: blockView,
|
||||
});
|
||||
expect(EditorApplication.module('components.content').getBlockTypeModel('testType')).to.deep.equal(blockModel);
|
||||
expect(EditorApplication.module('components.content').getBlockTypeView('testType')).to.deep.equal(blockView);
|
||||
});
|
||||
});
|
||||
|
||||
describe('transformation to json', function() {
|
||||
it('includes data, styles and initial newsletter fields', function() {
|
||||
var dataField = {
|
||||
containerModelField: 'containerModelValue',
|
||||
}, stylesField = {
|
||||
globalStylesField: 'globalStylesValue',
|
||||
}, newsletterFields = {
|
||||
newsletter_subject: 'test newsletter subject',
|
||||
};
|
||||
EditorApplication._contentContainer = {
|
||||
toJSON: function() {
|
||||
return dataField;
|
||||
}
|
||||
};
|
||||
EditorApplication.getGlobalStyles = function() {
|
||||
return {
|
||||
toJSON: function() {
|
||||
return stylesField;
|
||||
},
|
||||
};
|
||||
};
|
||||
EditorApplication.getNewsletter = function() {
|
||||
return {
|
||||
toJSON: function() {
|
||||
return newsletterFields;
|
||||
},
|
||||
};
|
||||
};
|
||||
var json = EditorApplication.module('components.content').toJSON();
|
||||
expect(json).to.deep.equal(_.extend({
|
||||
data: dataField,
|
||||
styles: stylesField
|
||||
}, newsletterFields));
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -4,45 +4,44 @@ define('test/newsletter_editor/components/heading', [
|
||||
], function(EditorApplication) {
|
||||
|
||||
describe('Heading', function() {
|
||||
describe('view', function() {
|
||||
var view;
|
||||
beforeEach(function() {
|
||||
var model = new Backbone.SuperModel({
|
||||
newsletter_subject: 'a test subject',
|
||||
});
|
||||
view = new (EditorApplication.module("components.heading").HeadingView)({
|
||||
model: model,
|
||||
});
|
||||
});
|
||||
|
||||
it('renders', function() {
|
||||
expect(view.render).to.not.throw();
|
||||
});
|
||||
|
||||
describe('once rendered', function() {
|
||||
var view, model;
|
||||
beforeEach(function() {
|
||||
model = new Backbone.SuperModel({
|
||||
newsletter_subject: 'a test subject',
|
||||
newsletter_preheader: 'a test preheader',
|
||||
});
|
||||
view = new (EditorApplication.module("components.heading").HeadingView)({
|
||||
model: model,
|
||||
});
|
||||
view.render();
|
||||
});
|
||||
|
||||
it('changes the model when subject field is changed', function() {
|
||||
view.$('.mailpoet_input_title').val('a new testing subject').keyup();
|
||||
expect(model.get('newsletter_subject')).to.equal('a new testing subject');
|
||||
});
|
||||
|
||||
it('changes the model when preheader field is changed', function() {
|
||||
view.$('.mailpoet_input_preheader').val('a new testing preheader').keyup();
|
||||
expect(model.get('newsletter_preheader')).to.equal('a new testing preheader');
|
||||
});
|
||||
});
|
||||
describe('view', function() {
|
||||
var view;
|
||||
beforeEach(function() {
|
||||
var model = new Backbone.SuperModel({
|
||||
newsletter_subject: 'a test subject',
|
||||
});
|
||||
view = new (EditorApplication.module("components.heading").HeadingView)({
|
||||
model: model,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('renders', function() {
|
||||
expect(view.render).to.not.throw();
|
||||
});
|
||||
|
||||
describe('once rendered', function() {
|
||||
var view, model;
|
||||
beforeEach(function() {
|
||||
model = new Backbone.SuperModel({
|
||||
newsletter_subject: 'a test subject',
|
||||
newsletter_preheader: 'a test preheader',
|
||||
});
|
||||
view = new (EditorApplication.module("components.heading").HeadingView)({
|
||||
model: model,
|
||||
});
|
||||
view.render();
|
||||
});
|
||||
|
||||
it('changes the model when subject field is changed', function() {
|
||||
view.$('.mailpoet_input_title').val('a new testing subject').keyup();
|
||||
expect(model.get('newsletter_subject')).to.equal('a new testing subject');
|
||||
});
|
||||
|
||||
it('changes the model when preheader field is changed', function() {
|
||||
view.$('.mailpoet_input_preheader').val('a new testing preheader').keyup();
|
||||
expect(model.get('newsletter_preheader')).to.equal('a new testing preheader');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -4,78 +4,77 @@ define('test/newsletter_editor/components/save', [
|
||||
], function(EditorApplication) {
|
||||
|
||||
describe('Save', function() {
|
||||
describe('save method', function() {
|
||||
it('triggers beforeEditorSave event', function() {
|
||||
var spy = sinon.spy();
|
||||
global.stubChannel(EditorApplication, {
|
||||
trigger: spy,
|
||||
});
|
||||
global.mailpoet_post_wpi = sinon.stub();
|
||||
EditorApplication.toJSON = sinon.stub();
|
||||
EditorApplication.module("components.save").save();
|
||||
expect(spy.withArgs('beforeEditorSave').calledOnce).to.be.true;
|
||||
});
|
||||
|
||||
it.skip('triggers afterEditorSave event', function() {
|
||||
var stub = sinon.stub().callsArgWith(2, { success: true }),
|
||||
spy = sinon.spy();
|
||||
global.mailpoet_post_wpi = stub;
|
||||
global.stubChannel(EditorApplication, {
|
||||
trigger: spy,
|
||||
});
|
||||
EditorApplication.toJSON = sinon.stub();
|
||||
EditorApplication.module("components.save").save();
|
||||
expect(spy.withArgs('afterEditorSave').calledOnce).to.be.true;
|
||||
});
|
||||
|
||||
it.skip('sends newsletter json to server for saving', function() {
|
||||
var mock = sinon.mock({ mailpoet_post_wpi: function() {} }).expects('mailpoet_post_wpi').once();
|
||||
global.stubChannel(EditorApplication);
|
||||
global.mailpoet_post_wpi = mock;
|
||||
|
||||
EditorApplication.toJSON = sinon.stub().returns({});
|
||||
EditorApplication.module("components.save").save();
|
||||
|
||||
mock.verify();
|
||||
});
|
||||
describe('save method', function() {
|
||||
it('triggers beforeEditorSave event', function() {
|
||||
var spy = sinon.spy();
|
||||
global.stubChannel(EditorApplication, {
|
||||
trigger: spy,
|
||||
});
|
||||
global.mailpoet_post_wpi = sinon.stub();
|
||||
EditorApplication.toJSON = sinon.stub();
|
||||
EditorApplication.module("components.save").save();
|
||||
expect(spy.withArgs('beforeEditorSave').calledOnce).to.be.true;
|
||||
});
|
||||
|
||||
describe('view', function() {
|
||||
var view;
|
||||
before(function() {
|
||||
EditorApplication._contentContainer = { isValid: sinon.stub().returns(true) };
|
||||
global.stubConfig(EditorApplication);
|
||||
view = new (EditorApplication.module('components.save').SaveView)();
|
||||
});
|
||||
|
||||
it('renders', function() {
|
||||
expect(view.render).to.not.throw();
|
||||
});
|
||||
|
||||
describe('once rendered', function() {
|
||||
var view;
|
||||
beforeEach(function() {
|
||||
EditorApplication._contentContainer = { isValid: sinon.stub().returns(true) };
|
||||
view = new (EditorApplication.module('components.save').SaveView)();
|
||||
view.render();
|
||||
});
|
||||
|
||||
it('triggers newsletter saving when clicked on save button', function() {
|
||||
var mock = sinon.mock({ trigger: function() {} }).expects('trigger').once().withArgs('save');
|
||||
global.stubChannel(EditorApplication, {
|
||||
trigger: mock,
|
||||
});
|
||||
view.$('.mailpoet_save_button').click();
|
||||
|
||||
mock.verify();
|
||||
});
|
||||
|
||||
it('displays saving options when clicked on save options button', function() {
|
||||
view.$('.mailpoet_save_show_options').click();
|
||||
expect(view.$('.mailpoet_save_options')).to.not.have.$class('mailpoet_hidden');
|
||||
});
|
||||
});
|
||||
it.skip('triggers afterEditorSave event', function() {
|
||||
var stub = sinon.stub().callsArgWith(2, { success: true }),
|
||||
spy = sinon.spy();
|
||||
global.mailpoet_post_wpi = stub;
|
||||
global.stubChannel(EditorApplication, {
|
||||
trigger: spy,
|
||||
});
|
||||
EditorApplication.toJSON = sinon.stub();
|
||||
EditorApplication.module("components.save").save();
|
||||
expect(spy.withArgs('afterEditorSave').calledOnce).to.be.true;
|
||||
});
|
||||
|
||||
it.skip('sends newsletter json to server for saving', function() {
|
||||
var mock = sinon.mock({ mailpoet_post_wpi: function() {} }).expects('mailpoet_post_wpi').once();
|
||||
global.stubChannel(EditorApplication);
|
||||
global.mailpoet_post_wpi = mock;
|
||||
|
||||
EditorApplication.toJSON = sinon.stub().returns({});
|
||||
EditorApplication.module("components.save").save();
|
||||
|
||||
mock.verify();
|
||||
});
|
||||
});
|
||||
|
||||
describe('view', function() {
|
||||
var view;
|
||||
before(function() {
|
||||
EditorApplication._contentContainer = { isValid: sinon.stub().returns(true) };
|
||||
global.stubConfig(EditorApplication);
|
||||
view = new (EditorApplication.module('components.save').SaveView)();
|
||||
});
|
||||
|
||||
it('renders', function() {
|
||||
expect(view.render).to.not.throw();
|
||||
});
|
||||
|
||||
describe('once rendered', function() {
|
||||
var view;
|
||||
beforeEach(function() {
|
||||
EditorApplication._contentContainer = { isValid: sinon.stub().returns(true) };
|
||||
view = new (EditorApplication.module('components.save').SaveView)();
|
||||
view.render();
|
||||
});
|
||||
|
||||
it('triggers newsletter saving when clicked on save button', function() {
|
||||
var mock = sinon.mock({ trigger: function() {} }).expects('trigger').once().withArgs('save');
|
||||
global.stubChannel(EditorApplication, {
|
||||
trigger: mock,
|
||||
});
|
||||
view.$('.mailpoet_save_button').click();
|
||||
|
||||
mock.verify();
|
||||
});
|
||||
|
||||
it('displays saving options when clicked on save options button', function() {
|
||||
view.$('.mailpoet_save_show_options').click();
|
||||
expect(view.$('.mailpoet_save_options')).to.not.have.$class('mailpoet_hidden');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
@@ -4,186 +4,184 @@ define('test/newsletter_editor/components/sidebar', [
|
||||
], function(EditorApplication) {
|
||||
|
||||
describe('Sidebar', function() {
|
||||
|
||||
describe('content view', function() {
|
||||
var view;
|
||||
beforeEach(function() {
|
||||
view = new (EditorApplication.module('components.sidebar').SidebarWidgetsView)({
|
||||
collection: new Backbone.Collection([]),
|
||||
});
|
||||
});
|
||||
|
||||
it('renders', function() {
|
||||
expect(view.render).to.not.throw();
|
||||
});
|
||||
describe('content view', function() {
|
||||
var view;
|
||||
beforeEach(function() {
|
||||
view = new (EditorApplication.module('components.sidebar').SidebarWidgetsView)({
|
||||
collection: new Backbone.Collection([]),
|
||||
});
|
||||
});
|
||||
|
||||
describe('layout view', function() {
|
||||
var view;
|
||||
beforeEach(function() {
|
||||
view = new (EditorApplication.module('components.sidebar').SidebarLayoutWidgetsView)({
|
||||
collection: new Backbone.Collection([]),
|
||||
});
|
||||
});
|
||||
it('renders', function() {
|
||||
expect(view.render).to.not.throw();
|
||||
});
|
||||
});
|
||||
|
||||
it('renders', function() {
|
||||
expect(view.render).to.not.throw();
|
||||
});
|
||||
describe('layout view', function() {
|
||||
var view;
|
||||
beforeEach(function() {
|
||||
view = new (EditorApplication.module('components.sidebar').SidebarLayoutWidgetsView)({
|
||||
collection: new Backbone.Collection([]),
|
||||
});
|
||||
});
|
||||
|
||||
describe('styles view', function() {
|
||||
var view;
|
||||
beforeEach(function() {
|
||||
view = new (EditorApplication.module('components.sidebar').SidebarStylesView)({
|
||||
model: new Backbone.SuperModel({}),
|
||||
availableStyles: new Backbone.SuperModel({}),
|
||||
});
|
||||
});
|
||||
it('renders', function() {
|
||||
expect(view.render).to.not.throw();
|
||||
});
|
||||
});
|
||||
|
||||
it('renders', function() {
|
||||
expect(view.render).to.not.throw();
|
||||
});
|
||||
|
||||
describe('once rendered', function() {
|
||||
var model, availableStyles, view;
|
||||
before(function() {
|
||||
model = new Backbone.SuperModel({
|
||||
text: {
|
||||
fontColor: '#000000',
|
||||
fontFamily: 'Arial',
|
||||
},
|
||||
h1: {
|
||||
fontColor: '#000001',
|
||||
fontFamily: 'Arial',
|
||||
},
|
||||
h2: {
|
||||
fontColor: '#000002',
|
||||
fontFamily: 'Arial',
|
||||
},
|
||||
h3: {
|
||||
fontColor: '#000003',
|
||||
fontFamily: 'Arial',
|
||||
},
|
||||
link: {
|
||||
fontColor: '#000005',
|
||||
textDecoration: 'none',
|
||||
},
|
||||
newsletter: {
|
||||
backgroundColor: '#090909',
|
||||
},
|
||||
background: {
|
||||
backgroundColor: '#020202',
|
||||
},
|
||||
});
|
||||
availableStyles = new Backbone.SuperModel({
|
||||
fonts: ['Arial', 'Times New Roman', 'Tahoma', 'Comic Sans', 'Lucida'],
|
||||
textSizes: [
|
||||
'9px', '10px',
|
||||
],
|
||||
headingSizes: [
|
||||
'10px', '12px', '14px', '16px', '18px',
|
||||
],
|
||||
});
|
||||
view = new (EditorApplication.module('components.sidebar').SidebarStylesView)({
|
||||
model: model,
|
||||
availableStyles: availableStyles,
|
||||
});
|
||||
|
||||
view.render();
|
||||
});
|
||||
|
||||
it('changes model if text font color field changes', function() {
|
||||
view.$('#mailpoet_text_font_color').val('#123456').change();
|
||||
expect(model.get('text.fontColor')).to.equal('#123456');
|
||||
});
|
||||
|
||||
it('changes model if h1 font color field changes', function() {
|
||||
view.$('#mailpoet_h1_font_color').val('#123457').change();
|
||||
expect(model.get('h1.fontColor')).to.equal('#123457');
|
||||
});
|
||||
|
||||
it('changes model if h2 font color field changes', function() {
|
||||
view.$('#mailpoet_h2_font_color').val('#123458').change();
|
||||
expect(model.get('h2.fontColor')).to.equal('#123458');
|
||||
});
|
||||
|
||||
it('changes model if h3 font color field changes', function() {
|
||||
view.$('#mailpoet_h3_font_color').val('#123426').change();
|
||||
expect(model.get('h3.fontColor')).to.equal('#123426');
|
||||
});
|
||||
|
||||
it('changes model if link font color field changes', function() {
|
||||
view.$('#mailpoet_a_font_color').val('#323232').change();
|
||||
expect(model.get('link.fontColor')).to.equal('#323232');
|
||||
});
|
||||
|
||||
it('changes model if newsletter background color field changes', function() {
|
||||
view.$('#mailpoet_newsletter_background_color').val('#636237').change();
|
||||
expect(model.get('newsletter.backgroundColor')).to.equal('#636237');
|
||||
});
|
||||
|
||||
it('changes model if background color field changes', function() {
|
||||
view.$('#mailpoet_background_color').val('#878587').change();
|
||||
expect(model.get('background.backgroundColor')).to.equal('#878587');
|
||||
});
|
||||
|
||||
it('changes model if text font family field changes', function() {
|
||||
view.$('#mailpoet_text_font_family').val('Times New Roman').change();
|
||||
expect(model.get('text.fontFamily')).to.equal('Times New Roman');
|
||||
});
|
||||
|
||||
it('changes model if h1 font family field changes', function() {
|
||||
view.$('#mailpoet_h1_font_family').val('Comic Sans').change();
|
||||
expect(model.get('h1.fontFamily')).to.equal('Comic Sans');
|
||||
});
|
||||
|
||||
it('changes model if h2 font family field changes', function() {
|
||||
view.$('#mailpoet_h2_font_family').val('Tahoma').change();
|
||||
expect(model.get('h2.fontFamily')).to.equal('Tahoma');
|
||||
});
|
||||
|
||||
it('changes model if h3 font family field changes', function() {
|
||||
view.$('#mailpoet_h3_font_family').val('Lucida').change();
|
||||
expect(model.get('h3.fontFamily')).to.equal('Lucida');
|
||||
});
|
||||
|
||||
it('changes model if text font size field changes', function() {
|
||||
view.$('#mailpoet_text_font_size').val('9px').change();
|
||||
expect(model.get('text.fontSize')).to.equal('9px');
|
||||
});
|
||||
|
||||
it('changes model if h1 font size field changes', function() {
|
||||
view.$('#mailpoet_h1_font_size').val('12px').change();
|
||||
expect(model.get('h1.fontSize')).to.equal('12px');
|
||||
});
|
||||
|
||||
it('changes model if h2 font size field changes', function() {
|
||||
view.$('#mailpoet_h2_font_size').val('14px').change();
|
||||
expect(model.get('h2.fontSize')).to.equal('14px');
|
||||
});
|
||||
|
||||
it('changes model if h3 font size field changes', function() {
|
||||
view.$('#mailpoet_h3_font_size').val('16px').change();
|
||||
expect(model.get('h3.fontSize')).to.equal('16px');
|
||||
});
|
||||
|
||||
it('changes model if link underline field changes', function() {
|
||||
view.$('#mailpoet_a_font_underline').prop('checked', true).change();
|
||||
expect(model.get('link.textDecoration')).to.equal('underline');
|
||||
});
|
||||
});
|
||||
describe('styles view', function() {
|
||||
var view;
|
||||
beforeEach(function() {
|
||||
view = new (EditorApplication.module('components.sidebar').SidebarStylesView)({
|
||||
model: new Backbone.SuperModel({}),
|
||||
availableStyles: new Backbone.SuperModel({}),
|
||||
});
|
||||
});
|
||||
|
||||
describe('preview view', function() {
|
||||
var view;
|
||||
beforeEach(function() {
|
||||
view = new (EditorApplication.module('components.sidebar').SidebarPreviewView)();
|
||||
it('renders', function() {
|
||||
expect(view.render).to.not.throw();
|
||||
});
|
||||
|
||||
describe('once rendered', function() {
|
||||
var model, availableStyles, view;
|
||||
before(function() {
|
||||
model = new Backbone.SuperModel({
|
||||
text: {
|
||||
fontColor: '#000000',
|
||||
fontFamily: 'Arial',
|
||||
},
|
||||
h1: {
|
||||
fontColor: '#000001',
|
||||
fontFamily: 'Arial',
|
||||
},
|
||||
h2: {
|
||||
fontColor: '#000002',
|
||||
fontFamily: 'Arial',
|
||||
},
|
||||
h3: {
|
||||
fontColor: '#000003',
|
||||
fontFamily: 'Arial',
|
||||
},
|
||||
link: {
|
||||
fontColor: '#000005',
|
||||
textDecoration: 'none',
|
||||
},
|
||||
newsletter: {
|
||||
backgroundColor: '#090909',
|
||||
},
|
||||
background: {
|
||||
backgroundColor: '#020202',
|
||||
},
|
||||
});
|
||||
availableStyles = new Backbone.SuperModel({
|
||||
fonts: ['Arial', 'Times New Roman', 'Tahoma', 'Comic Sans', 'Lucida'],
|
||||
textSizes: [
|
||||
'9px', '10px',
|
||||
],
|
||||
headingSizes: [
|
||||
'10px', '12px', '14px', '16px', '18px',
|
||||
],
|
||||
});
|
||||
view = new (EditorApplication.module('components.sidebar').SidebarStylesView)({
|
||||
model: model,
|
||||
availableStyles: availableStyles,
|
||||
});
|
||||
|
||||
it('renders', function() {
|
||||
expect(view.render).to.not.throw();
|
||||
});
|
||||
view.render();
|
||||
});
|
||||
|
||||
it('changes model if text font color field changes', function() {
|
||||
view.$('#mailpoet_text_font_color').val('#123456').change();
|
||||
expect(model.get('text.fontColor')).to.equal('#123456');
|
||||
});
|
||||
|
||||
it('changes model if h1 font color field changes', function() {
|
||||
view.$('#mailpoet_h1_font_color').val('#123457').change();
|
||||
expect(model.get('h1.fontColor')).to.equal('#123457');
|
||||
});
|
||||
|
||||
it('changes model if h2 font color field changes', function() {
|
||||
view.$('#mailpoet_h2_font_color').val('#123458').change();
|
||||
expect(model.get('h2.fontColor')).to.equal('#123458');
|
||||
});
|
||||
|
||||
it('changes model if h3 font color field changes', function() {
|
||||
view.$('#mailpoet_h3_font_color').val('#123426').change();
|
||||
expect(model.get('h3.fontColor')).to.equal('#123426');
|
||||
});
|
||||
|
||||
it('changes model if link font color field changes', function() {
|
||||
view.$('#mailpoet_a_font_color').val('#323232').change();
|
||||
expect(model.get('link.fontColor')).to.equal('#323232');
|
||||
});
|
||||
|
||||
it('changes model if newsletter background color field changes', function() {
|
||||
view.$('#mailpoet_newsletter_background_color').val('#636237').change();
|
||||
expect(model.get('newsletter.backgroundColor')).to.equal('#636237');
|
||||
});
|
||||
|
||||
it('changes model if background color field changes', function() {
|
||||
view.$('#mailpoet_background_color').val('#878587').change();
|
||||
expect(model.get('background.backgroundColor')).to.equal('#878587');
|
||||
});
|
||||
|
||||
it('changes model if text font family field changes', function() {
|
||||
view.$('#mailpoet_text_font_family').val('Times New Roman').change();
|
||||
expect(model.get('text.fontFamily')).to.equal('Times New Roman');
|
||||
});
|
||||
|
||||
it('changes model if h1 font family field changes', function() {
|
||||
view.$('#mailpoet_h1_font_family').val('Comic Sans').change();
|
||||
expect(model.get('h1.fontFamily')).to.equal('Comic Sans');
|
||||
});
|
||||
|
||||
it('changes model if h2 font family field changes', function() {
|
||||
view.$('#mailpoet_h2_font_family').val('Tahoma').change();
|
||||
expect(model.get('h2.fontFamily')).to.equal('Tahoma');
|
||||
});
|
||||
|
||||
it('changes model if h3 font family field changes', function() {
|
||||
view.$('#mailpoet_h3_font_family').val('Lucida').change();
|
||||
expect(model.get('h3.fontFamily')).to.equal('Lucida');
|
||||
});
|
||||
|
||||
it('changes model if text font size field changes', function() {
|
||||
view.$('#mailpoet_text_font_size').val('9px').change();
|
||||
expect(model.get('text.fontSize')).to.equal('9px');
|
||||
});
|
||||
|
||||
it('changes model if h1 font size field changes', function() {
|
||||
view.$('#mailpoet_h1_font_size').val('12px').change();
|
||||
expect(model.get('h1.fontSize')).to.equal('12px');
|
||||
});
|
||||
|
||||
it('changes model if h2 font size field changes', function() {
|
||||
view.$('#mailpoet_h2_font_size').val('14px').change();
|
||||
expect(model.get('h2.fontSize')).to.equal('14px');
|
||||
});
|
||||
|
||||
it('changes model if h3 font size field changes', function() {
|
||||
view.$('#mailpoet_h3_font_size').val('16px').change();
|
||||
expect(model.get('h3.fontSize')).to.equal('16px');
|
||||
});
|
||||
|
||||
it('changes model if link underline field changes', function() {
|
||||
view.$('#mailpoet_a_font_underline').prop('checked', true).change();
|
||||
expect(model.get('link.textDecoration')).to.equal('underline');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('preview view', function() {
|
||||
var view;
|
||||
beforeEach(function() {
|
||||
view = new (EditorApplication.module('components.sidebar').SidebarPreviewView)();
|
||||
});
|
||||
|
||||
it('renders', function() {
|
||||
expect(view.render).to.not.throw();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
@@ -4,43 +4,42 @@ define('test/newsletter_editor/components/config', [
|
||||
], function(EditorApplication) {
|
||||
|
||||
describe('Styles', function () {
|
||||
it('loads and stores globally available styles', function() {
|
||||
EditorApplication.module('components.styles').setGlobalStyles({
|
||||
testStyle: 'testValue',
|
||||
});
|
||||
var model = EditorApplication.module('components.styles').getGlobalStyles();
|
||||
expect(model.get('testStyle')).to.equal('testValue');
|
||||
it('loads and stores globally available styles', function() {
|
||||
EditorApplication.module('components.styles').setGlobalStyles({
|
||||
testStyle: 'testValue',
|
||||
});
|
||||
var model = EditorApplication.module('components.styles').getGlobalStyles();
|
||||
expect(model.get('testStyle')).to.equal('testValue');
|
||||
});
|
||||
|
||||
describe('model', function() {
|
||||
var model;
|
||||
beforeEach(function() {
|
||||
model = new (EditorApplication.module('components.styles').StylesModel)();
|
||||
});
|
||||
|
||||
describe('model', function() {
|
||||
var model;
|
||||
beforeEach(function() {
|
||||
model = new (EditorApplication.module('components.styles').StylesModel)();
|
||||
});
|
||||
it('triggers autoSave when changed', function() {
|
||||
var mock = sinon.mock({ trigger: function(){}}).expects('trigger').once().withExactArgs('autoSave');
|
||||
EditorApplication.getChannel = function() {
|
||||
return {
|
||||
trigger: mock,
|
||||
};
|
||||
};
|
||||
model.set('text.fontColor', '#123456');
|
||||
mock.verify();
|
||||
});
|
||||
});
|
||||
|
||||
it('triggers autoSave when changed', function() {
|
||||
var mock = sinon.mock({ trigger: function(){}}).expects('trigger').once().withExactArgs('autoSave');
|
||||
EditorApplication.getChannel = function() {
|
||||
return {
|
||||
trigger: mock,
|
||||
};
|
||||
};
|
||||
model.set('text.fontColor', '#123456');
|
||||
mock.verify();
|
||||
});
|
||||
describe('view', function() {
|
||||
var model, view;
|
||||
beforeEach(function() {
|
||||
model = new (EditorApplication.module('components.styles').StylesModel)();
|
||||
view = new (EditorApplication.module('components.styles').StylesView)({ model: model });
|
||||
});
|
||||
|
||||
describe('view', function() {
|
||||
var model, view;
|
||||
beforeEach(function() {
|
||||
model = new (EditorApplication.module('components.styles').StylesModel)();
|
||||
view = new (EditorApplication.module('components.styles').StylesView)({ model: model });
|
||||
});
|
||||
|
||||
it('renders', function() {
|
||||
expect(view.render).to.not.throw();
|
||||
});
|
||||
it('renders', function() {
|
||||
expect(view.render).to.not.throw();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
Reference in New Issue
Block a user