Tests: no-shaddow

This commit is contained in:
Amine Ben hammou
2017-10-25 14:52:53 +00:00
parent 2ac32484e1
commit 4dc9004303
16 changed files with 156 additions and 178 deletions

View File

@ -10,9 +10,9 @@
"rules": {
// Exceptions
"func-names": 0,
// To add
// Temporary
"no-underscore-dangle": 0,
"no-shadow": 0,
// To add
"padded-blocks": 0
}
}

View File

@ -175,7 +175,6 @@ define([
});
it('uses defaults from config when they are set', function () {
var model;
global.stubConfig(EditorApplication, {
blockDefaults: {
automatedLatestContent: {
@ -255,7 +254,6 @@ define([
});
it('accepts displayable posts', function () {
var model;
EditorApplication.getBlockTypeModel = sinon.stub()
.returns(ContainerBlock.ContainerBlockModel);
model = new (module.AutomatedLatestContentBlockModel)();
@ -504,8 +502,6 @@ define([
});
describe('when "title only" display type is selected', function () {
var model;
var view;
beforeEach(function () {
model = new (module.AutomatedLatestContentBlockModel)();
view = new (module.AutomatedLatestContentBlockSettingsView)({ model: model });
@ -518,8 +514,6 @@ define([
});
describe('when "title as list" is selected', function () {
var model;
var view;
beforeEach(function () {
model = new (module.AutomatedLatestContentBlockModel)();
view = new (module.AutomatedLatestContentBlockSettingsView)({ model: model });

View File

@ -108,7 +108,6 @@ define([
});
it('uses defaults from config when they are set', function () {
var model;
global.stubConfig(EditorApplication, {
blockDefaults: {
button: {
@ -174,12 +173,12 @@ define([
});
describe('once rendered', function () {
var model;
var innerModel;
var view;
before(function () {
global.stubChannel(EditorApplication);
model = new (ButtonBlock.ButtonBlockModel)({
innerModel = new (ButtonBlock.ButtonBlockModel)({
text: 'Some button',
url: 'http://example.org',
styles: {
@ -198,16 +197,16 @@ define([
}
}
});
view = new (ButtonBlock.ButtonBlockView)({ model: model });
view = new (ButtonBlock.ButtonBlockView)({ model: innerModel });
view.render();
});
it('has a specified text', function () {
expect(view.$('.mailpoet_editor_button').text()).to.equal(model.get('text'));
expect(view.$('.mailpoet_editor_button').text()).to.equal(innerModel.get('text'));
});
it('has a specified button url', function () {
expect(view.$('.mailpoet_editor_button').attr('href')).to.equal(model.get('url'));
expect(view.$('.mailpoet_editor_button').attr('href')).to.equal(innerModel.get('url'));
});
it('has a specified background color', function () {
@ -216,27 +215,27 @@ define([
});
it('has a specified border color', function () {
expect(view.$('.mailpoet_editor_button').css('border-color')).to.equal(model.get('styles.block.borderColor'));
expect(view.$('.mailpoet_editor_button').css('border-color')).to.equal(innerModel.get('styles.block.borderColor'));
});
it('has a specified border width', function () {
expect(view.$('.mailpoet_editor_button').css('border-width')).to.equal(model.get('styles.block.borderWidth'));
expect(view.$('.mailpoet_editor_button').css('border-width')).to.equal(innerModel.get('styles.block.borderWidth'));
});
it('has a specified border radius', function () {
expect(view.$('.mailpoet_editor_button').css('border-radius')).to.equal(model.get('styles.block.borderRadius'));
expect(view.$('.mailpoet_editor_button').css('border-radius')).to.equal(innerModel.get('styles.block.borderRadius'));
});
it('has a specified border style', function () {
expect(view.$('.mailpoet_editor_button').css('border-style')).to.equal(model.get('styles.block.borderStyle'));
expect(view.$('.mailpoet_editor_button').css('border-style')).to.equal(innerModel.get('styles.block.borderStyle'));
});
it('has a specified width', function () {
expect(view.$('.mailpoet_editor_button').css('width')).to.equal(model.get('styles.block.width'));
expect(view.$('.mailpoet_editor_button').css('width')).to.equal(innerModel.get('styles.block.width'));
});
it('has a specified line height', function () {
expect(view.$('.mailpoet_editor_button').css('lineHeight')).to.equal(model.get('styles.block.lineHeight'));
expect(view.$('.mailpoet_editor_button').css('lineHeight')).to.equal(innerModel.get('styles.block.lineHeight'));
});
it('has a specified font color', function () {
@ -245,20 +244,20 @@ define([
});
it('has a specified font family', function () {
expect(view.$('.mailpoet_editor_button').css('font-family')).to.contain(model.get('styles.block.fontFamily'));
expect(view.$('.mailpoet_editor_button').css('font-family')).to.contain(innerModel.get('styles.block.fontFamily'));
});
it('has a specified font size', function () {
expect(view.$('.mailpoet_editor_button').css('font-size')).to.equal(model.get('styles.block.fontSize'));
expect(view.$('.mailpoet_editor_button').css('font-size')).to.equal(innerModel.get('styles.block.fontSize'));
});
it('has a specified font weight', function () {
expect(view.$('.mailpoet_editor_button').css('font-weight')).to.equal(model.get('styles.block.fontWeight'));
expect(view.$('.mailpoet_editor_button').css('font-weight')).to.equal(innerModel.get('styles.block.fontWeight'));
});
it('opens settings if clicked', function () {
var mock = sinon.mock().once();
model.on('startEditing', mock);
innerModel.on('startEditing', mock);
view.$('.mailpoet_editor_button').click();
mock.verify();
});
@ -320,7 +319,6 @@ define([
});
describe('once rendered', function () {
var model;
var view;
before(function () {
global.stubChannel(EditorApplication);

View File

@ -34,7 +34,7 @@ define([
});
it('uses defaults from config when they are set', function () {
var model;
var innerModel;
global.stubConfig(EditorApplication, {
blockDefaults: {
container: {
@ -46,9 +46,9 @@ define([
}
}
});
model = new (ContainerBlock.ContainerBlockModel)();
innerModel = new (ContainerBlock.ContainerBlockModel)();
expect(model.get('styles.block.backgroundColor')).to.equal('#123456');
expect(innerModel.get('styles.block.backgroundColor')).to.equal('#123456');
});
});
@ -109,14 +109,14 @@ define([
});
describe('block view', function () {
var model;
var view;
global.stubChannel(EditorApplication);
global.stubAvailableStyles(EditorApplication);
model = new (ContainerBlock.ContainerBlockModel)();
view = new (ContainerBlock.ContainerBlockView)({ model: model });
it('renders', function () {
var model;
var view;
model = new (ContainerBlock.ContainerBlockModel)();
view = new (ContainerBlock.ContainerBlockView)({ model: model });
expect(view.render).to.not.throw();
});
@ -191,14 +191,14 @@ define([
});
describe('settings view', function () {
var model;
var view;
global.stubChannel(EditorApplication);
global.stubAvailableStyles(EditorApplication);
model = new (ContainerBlock.ContainerBlockModel)();
view = new (ContainerBlock.ContainerBlockSettingsView)({ model: model });
it('renders', function () {
var model;
var view;
model = new (ContainerBlock.ContainerBlockModel)();
view = new (ContainerBlock.ContainerBlockSettingsView)({ model: model });
expect(view.render).to.not.throw();
});

View File

@ -70,7 +70,7 @@ define([
});
it('uses defaults from config when they are set', function () {
var model;
var innerModel;
global.stubConfig(EditorApplication, {
blockDefaults: {
divider: {
@ -86,13 +86,13 @@ define([
}
}
});
model = new (DividerBlock.DividerBlockModel)();
innerModel = new (DividerBlock.DividerBlockModel)();
expect(model.get('styles.block.backgroundColor')).to.equal('#123456');
expect(model.get('styles.block.padding')).to.equal('37px');
expect(model.get('styles.block.borderStyle')).to.equal('inset');
expect(model.get('styles.block.borderWidth')).to.equal('7px');
expect(model.get('styles.block.borderColor')).to.equal('#345678');
expect(innerModel.get('styles.block.backgroundColor')).to.equal('#123456');
expect(innerModel.get('styles.block.padding')).to.equal('37px');
expect(innerModel.get('styles.block.borderStyle')).to.equal('inset');
expect(innerModel.get('styles.block.borderWidth')).to.equal('7px');
expect(innerModel.get('styles.block.borderColor')).to.equal('#345678');
});
});
@ -138,17 +138,17 @@ define([
});
describe('settings view', function () {
var model;
var view;
global.stubChannel(EditorApplication);
global.stubConfig(EditorApplication);
global.stubAvailableStyles(EditorApplication, {
dividers: ['solid', 'inset']
});
model = new (DividerBlock.DividerBlockModel)();
view = new (DividerBlock.DividerBlockSettingsView)({ model: model });
it('renders', function () {
var model;
var view;
model = new (DividerBlock.DividerBlockModel)();
view = new (DividerBlock.DividerBlockSettingsView)({ model: model });
expect(view.render).to.not.throw();
expect(view.$('.mailpoet_divider_selector')).to.have.length(1);
});

View File

@ -79,7 +79,7 @@ define([
});
it('uses defaults from config when they are set', function () {
var model;
var innerModel;
global.stubConfig(EditorApplication, {
blockDefaults: {
footer: {
@ -102,16 +102,16 @@ define([
}
}
});
model = new (FooterBlock.FooterBlockModel)();
innerModel = new (FooterBlock.FooterBlockModel)();
expect(model.get('text')).to.equal('some custom config text');
expect(model.get('styles.block.backgroundColor')).to.equal('#123456');
expect(model.get('styles.text.fontColor')).to.equal('#234567');
expect(model.get('styles.text.fontFamily')).to.equal('Tahoma');
expect(model.get('styles.text.fontSize')).to.equal('37px');
expect(model.get('styles.text.textAlign')).to.equal('right');
expect(model.get('styles.link.fontColor')).to.equal('#345678');
expect(model.get('styles.link.textDecoration')).to.equal('underline');
expect(innerModel.get('text')).to.equal('some custom config text');
expect(innerModel.get('styles.block.backgroundColor')).to.equal('#123456');
expect(innerModel.get('styles.text.fontColor')).to.equal('#234567');
expect(innerModel.get('styles.text.fontFamily')).to.equal('Tahoma');
expect(innerModel.get('styles.text.fontSize')).to.equal('37px');
expect(innerModel.get('styles.text.textAlign')).to.equal('right');
expect(innerModel.get('styles.link.fontColor')).to.equal('#345678');
expect(innerModel.get('styles.link.textDecoration')).to.equal('underline');
});
});
@ -136,17 +136,17 @@ define([
});
describe('settings view', function () {
var model;
var view;
global.stubChannel(EditorApplication);
global.stubAvailableStyles(EditorApplication, {
fonts: ['Arial', 'Tahoma'],
textSizes: ['16px', '20px']
});
model = new (FooterBlock.FooterBlockModel)();
view = new (FooterBlock.FooterBlockSettingsView)({ model: model });
it('renders', function () {
var model;
var view;
model = new (FooterBlock.FooterBlockModel)();
view = new (FooterBlock.FooterBlockSettingsView)({ model: model });
expect(view.render).to.not.throw();
expect(view.$('.mailpoet_field_footer_text_color')).to.have.length(1);
});

View File

@ -79,7 +79,7 @@ define([
});
it('uses defaults from config when they are set', function () {
var model;
var innerModel;
global.stubConfig(EditorApplication, {
blockDefaults: {
header: {
@ -102,16 +102,16 @@ define([
}
}
});
model = new (HeaderBlock.HeaderBlockModel)();
innerModel = new (HeaderBlock.HeaderBlockModel)();
expect(model.get('text')).to.equal('some custom config text');
expect(model.get('styles.block.backgroundColor')).to.equal('#123456');
expect(model.get('styles.text.fontColor')).to.equal('#234567');
expect(model.get('styles.text.fontFamily')).to.equal('Tahoma');
expect(model.get('styles.text.fontSize')).to.equal('37px');
expect(model.get('styles.text.textAlign')).to.equal('right');
expect(model.get('styles.link.fontColor')).to.equal('#345678');
expect(model.get('styles.link.textDecoration')).to.equal('underline');
expect(innerModel.get('text')).to.equal('some custom config text');
expect(innerModel.get('styles.block.backgroundColor')).to.equal('#123456');
expect(innerModel.get('styles.text.fontColor')).to.equal('#234567');
expect(innerModel.get('styles.text.fontFamily')).to.equal('Tahoma');
expect(innerModel.get('styles.text.fontSize')).to.equal('37px');
expect(innerModel.get('styles.text.textAlign')).to.equal('right');
expect(innerModel.get('styles.link.fontColor')).to.equal('#345678');
expect(innerModel.get('styles.link.textDecoration')).to.equal('underline');
});
});
@ -135,18 +135,18 @@ define([
});
describe('settings view', function () {
var model;
var view;
global.stubChannel(EditorApplication);
global.stubConfig(EditorApplication);
global.stubAvailableStyles(EditorApplication, {
fonts: ['Arial', 'Tahoma'],
textSizes: ['16px', '20px']
});
model = new (HeaderBlock.HeaderBlockModel)();
view = new (HeaderBlock.HeaderBlockSettingsView)({ model: model });
it('renders', function () {
var model;
var view;
model = new (HeaderBlock.HeaderBlockModel)();
view = new (HeaderBlock.HeaderBlockSettingsView)({ model: model });
expect(view.render).to.not.throw();
expect(view.$('.mailpoet_field_header_text_color')).to.have.length(1);
});

View File

@ -74,7 +74,7 @@ define([
});
it('uses defaults from config when they are set', function () {
var model;
var innerModel;
global.stubConfig(EditorApplication, {
blockDefaults: {
image: {
@ -92,31 +92,28 @@ define([
}
}
});
model = new (ImageBlock.ImageBlockModel)();
innerModel = new (ImageBlock.ImageBlockModel)();
expect(model.get('link')).to.equal('http://example.org/customConfigPage');
expect(model.get('src')).to.equal('http://example.org/someCustomConfigImage.png');
expect(model.get('alt')).to.equal('Custom config alt');
expect(model.get('fullWidth')).to.equal(false);
expect(model.get('width')).to.equal('1234px');
expect(model.get('height')).to.equal('2345px');
expect(model.get('styles.block.textAlign')).to.equal('right');
expect(innerModel.get('link')).to.equal('http://example.org/customConfigPage');
expect(innerModel.get('src')).to.equal('http://example.org/someCustomConfigImage.png');
expect(innerModel.get('alt')).to.equal('Custom config alt');
expect(innerModel.get('fullWidth')).to.equal(false);
expect(innerModel.get('width')).to.equal('1234px');
expect(innerModel.get('height')).to.equal('2345px');
expect(innerModel.get('styles.block.textAlign')).to.equal('right');
});
});
describe('block view', function () {
var model;
var view;
global.stubChannel(EditorApplication);
global.stubConfig(EditorApplication);
global.stubAvailableStyles(EditorApplication);
model = new (ImageBlock.ImageBlockModel)();
beforeEach(function () {
view = new (ImageBlock.ImageBlockView)({ model: model });
});
it('renders', function () {
var view;
var model;
model = new (ImageBlock.ImageBlockModel)();
view = new (ImageBlock.ImageBlockView)({ model: model });
expect(view.render).to.not.throw();
expect(view.$('.mailpoet_content')).to.have.length(1);
});

View File

@ -132,7 +132,7 @@ define([
});
it('uses defaults from config when they are set', function () {
var model;
var innerModel;
global.stubConfig(EditorApplication, {
blockDefaults: {
posts: {
@ -180,35 +180,35 @@ define([
}
}
});
model = new (PostsBlock.PostsBlockModel)();
innerModel = new (PostsBlock.PostsBlockModel)();
expect(model.get('amount')).to.equal('17');
expect(model.get('contentType')).to.equal('mailpoet_page');
expect(model.get('inclusionType')).to.equal('exclude');
expect(model.get('displayType')).to.equal('full');
expect(model.get('titleFormat')).to.equal('h3');
expect(model.get('titleAlignment')).to.equal('right');
expect(model.get('titleIsLink')).to.equal(true);
expect(model.get('imageFullWidth')).to.equal(false);
expect(model.get('featuredImagePosition')).to.equal('aboveTitle');
expect(model.get('showAuthor')).to.equal('belowText');
expect(model.get('authorPrecededBy')).to.equal('Custom config author preceded by');
expect(model.get('showCategories')).to.equal('belowText');
expect(model.get('categoriesPrecededBy')).to.equal('Custom config categories preceded by');
expect(model.get('readMoreType')).to.equal('button');
expect(model.get('readMoreText')).to.equal('Custom Config read more text');
expect(model.get('readMoreButton.text')).to.equal('Custom config read more');
expect(model.get('readMoreButton.url')).to.equal('[postLink]');
expect(model.get('readMoreButton.styles.block.backgroundColor')).to.equal('#123456');
expect(model.get('readMoreButton.styles.block.borderColor')).to.equal('#234567');
expect(model.get('readMoreButton.styles.link.fontColor')).to.equal('#345678');
expect(model.get('readMoreButton.styles.link.fontFamily')).to.equal('Tahoma');
expect(model.get('readMoreButton.styles.link.fontSize')).to.equal('37px');
expect(model.get('sortBy')).to.equal('oldest');
expect(model.get('showDivider')).to.equal(true);
expect(model.get('divider.src')).to.equal('http://example.org/someConfigDividerImage.png');
expect(model.get('divider.styles.block.backgroundColor')).to.equal('#456789');
expect(model.get('divider.styles.block.padding')).to.equal('38px');
expect(innerModel.get('amount')).to.equal('17');
expect(innerModel.get('contentType')).to.equal('mailpoet_page');
expect(innerModel.get('inclusionType')).to.equal('exclude');
expect(innerModel.get('displayType')).to.equal('full');
expect(innerModel.get('titleFormat')).to.equal('h3');
expect(innerModel.get('titleAlignment')).to.equal('right');
expect(innerModel.get('titleIsLink')).to.equal(true);
expect(innerModel.get('imageFullWidth')).to.equal(false);
expect(innerModel.get('featuredImagePosition')).to.equal('aboveTitle');
expect(innerModel.get('showAuthor')).to.equal('belowText');
expect(innerModel.get('authorPrecededBy')).to.equal('Custom config author preceded by');
expect(innerModel.get('showCategories')).to.equal('belowText');
expect(innerModel.get('categoriesPrecededBy')).to.equal('Custom config categories preceded by');
expect(innerModel.get('readMoreType')).to.equal('button');
expect(innerModel.get('readMoreText')).to.equal('Custom Config read more text');
expect(innerModel.get('readMoreButton.text')).to.equal('Custom config read more');
expect(innerModel.get('readMoreButton.url')).to.equal('[postLink]');
expect(innerModel.get('readMoreButton.styles.block.backgroundColor')).to.equal('#123456');
expect(innerModel.get('readMoreButton.styles.block.borderColor')).to.equal('#234567');
expect(innerModel.get('readMoreButton.styles.link.fontColor')).to.equal('#345678');
expect(innerModel.get('readMoreButton.styles.link.fontFamily')).to.equal('Tahoma');
expect(innerModel.get('readMoreButton.styles.link.fontSize')).to.equal('37px');
expect(innerModel.get('sortBy')).to.equal('oldest');
expect(innerModel.get('showDivider')).to.equal(true);
expect(innerModel.get('divider.src')).to.equal('http://example.org/someConfigDividerImage.png');
expect(innerModel.get('divider.styles.block.backgroundColor')).to.equal('#456789');
expect(innerModel.get('divider.styles.block.padding')).to.equal('38px');
});
it('resets offset when fetching posts', function () {
@ -425,46 +425,46 @@ define([
});
describe('when "title only" display type is selected', function () {
var model;
var view;
var innerModel;
var innerView;
beforeEach(function () {
model = new (PostsBlock.PostsBlockModel)();
model.request = sinon.stub().returns({ $el: {} });
view = new (PostsBlock.PostsBlockSettingsView)({ model: model });
view.render();
view.$('.mailpoet_posts_display_type').val('titleOnly').change();
innerModel = new (PostsBlock.PostsBlockModel)();
innerModel.request = sinon.stub().returns({ $el: {} });
innerView = new (PostsBlock.PostsBlockSettingsView)({ model: innerModel });
innerView.render();
innerView.$('.mailpoet_posts_display_type').val('titleOnly').change();
});
it('shows "title as list" option', function () {
expect(view.$('.mailpoet_posts_title_as_list')).to.not.have.$class('mailpoet_hidden');
expect(innerView.$('.mailpoet_posts_title_as_list')).to.not.have.$class('mailpoet_hidden');
});
describe('when "title as list" is selected', function () {
beforeEach(function () {
view.$('.mailpoet_posts_display_type').val('titleOnly').change();
view.$('.mailpoet_posts_title_format').val('ul').change();
innerView.$('.mailpoet_posts_display_type').val('titleOnly').change();
innerView.$('.mailpoet_posts_title_format').val('ul').change();
});
describe('"title is link" option', function () {
it('is hidden', function () {
expect(view.$('.mailpoet_posts_title_as_link')).to.have.$class('mailpoet_hidden');
expect(innerView.$('.mailpoet_posts_title_as_link')).to.have.$class('mailpoet_hidden');
});
it('is set to "yes"', function () {
expect(model.get('titleIsLink')).to.equal(true);
expect(innerModel.get('titleIsLink')).to.equal(true);
});
});
});
describe('when "title as list" is deselected', function () {
before(function () {
view.$('.mailpoet_posts_title_format').val('ul').change();
view.$('.mailpoet_posts_title_format').val('h3').change();
innerView.$('.mailpoet_posts_title_format').val('ul').change();
innerView.$('.mailpoet_posts_title_format').val('h3').change();
});
describe('"title is link" option', function () {
it('is visible', function () {
expect(view.$('.mailpoet_posts_title_as_link')).to.not.have.$class('mailpoet_hidden');
expect(innerView.$('.mailpoet_posts_title_as_link')).to.not.have.$class('mailpoet_hidden');
});
});
});

View File

@ -29,7 +29,6 @@ define([
});
it('uses defaults from config when they are set', function () {
var model;
global.stubConfig(EditorApplication, {
blockDefaults: {
social: {
@ -131,7 +130,6 @@ define([
});
describe('once rendered', function () {
var model;
var view;
before(function () {
@ -217,7 +215,6 @@ define([
});
describe('once rendered', function () {
var model;
var view;
beforeEach(function () {
global.stubChannel(EditorApplication);

View File

@ -55,7 +55,6 @@ define([
});
it('uses defaults from config when they are set', function () {
var model;
global.stubConfig(EditorApplication, {
blockDefaults: {
spacer: {
@ -137,8 +136,6 @@ define([
});
describe('once rendered', function () {
var view;
var model;
beforeEach(function () {
global.stubChannel(EditorApplication);
global.stubConfig(EditorApplication);

View File

@ -23,7 +23,6 @@ define([
});
it('uses defaults from config when they are set', function () {
var model;
global.stubConfig(EditorApplication, {
blockDefaults: {
text: {
@ -50,8 +49,7 @@ define([
});
describe('once rendered', function () {
var model = new (TextBlock.TextBlockModel)();
var view;
model = new (TextBlock.TextBlockModel)();
beforeEach(function () {
global.stubConfig(EditorApplication);

View File

@ -45,7 +45,8 @@ define([
describe('toJSON()', function () {
it('will only contain properties modifiable by the editor', function () {
var model = new (ContentComponent.NewsletterModel)({
var json;
model = new (ContentComponent.NewsletterModel)({
id: 19,
subject: 'some subject',
preheader: 'some preheader',
@ -54,7 +55,7 @@ define([
someField: 'someValue'
});
var json = model.toJSON();
json = model.toJSON();
expect(json.id).to.equal(19);
expect(json.subject).to.equal('some subject');
expect(json.preheader).to.equal('some preheader');

View File

@ -23,7 +23,6 @@ define([
});
describe('once rendered', function () {
var view;
var model;
beforeEach(function () {
model = new Backbone.SuperModel({

View File

@ -38,7 +38,7 @@ define([
});
it('triggers afterEditorSave event', function () {
var module;
var innerModule;
var spy = sinon.spy();
var promise = jQuery.Deferred();
global.stubChannel(EditorApplication, {
@ -49,19 +49,19 @@ define([
type: 'container'
}
});
module = SaveInjector({
innerModule = SaveInjector({
'newsletter_editor/components/communication': {
saveNewsletter: sinon.stub().returns(promise)
}
});
promise.resolve({ success: true });
module.save();
innerModule.save();
expect(spy.withArgs('afterEditorSave').calledOnce).to.be.true;// eslint-disable-line no-unused-expressions
});
it('sends newsletter json to server for saving', function () {
var mock = sinon.mock().once().returns(jQuery.Deferred());
var module = SaveInjector({
var innerModule = SaveInjector({
'newsletter_editor/components/communication': {
saveNewsletter: mock
}
@ -69,13 +69,13 @@ define([
global.stubChannel(EditorApplication);
EditorApplication.toJSON = sinon.stub().returns({});
module.save();
innerModule.save();
mock.verify();
});
it('encodes newsletter body in JSON format', function () {
var module;
var innerModule;
var body = { type: 'testType' };
var mock = sinon.mock()
.once()
@ -88,12 +88,12 @@ define([
EditorApplication.toJSON = sinon.stub().returns({
body: body
});
module = SaveInjector({
innerModule = SaveInjector({
'newsletter_editor/components/communication': {
saveNewsletter: mock
}
});
module.save();
innerModule.save();
mock.verify();
});
@ -101,14 +101,13 @@ define([
});
describe('view', function () {
var view;
before(function () {
EditorApplication._contentContainer = { isValid: sinon.stub().returns(true) };
global.stubConfig(EditorApplication);
view = new (SaveComponent.SaveView)();
});
it('renders', function () {
var view = new (SaveComponent.SaveView)();
expect(view.render).to.not.throw();
});
@ -139,7 +138,6 @@ define([
var mock = sinon.mock({ post: function () {} }).expects('post').once().returns(jQuery.Deferred());
var html2canvasMock = jQuery.Deferred();
var module;
var view;
html2canvasMock.resolve({
toDataURL: function () { return 'somedataurl'; }
@ -179,7 +177,6 @@ define([
it('saves newsletter when clicked on "next" button', function () {
var spy = sinon.spy();
var view;
var module = SaveInjector({
'newsletter_editor/components/communication': {
saveNewsletter: function () {

View File

@ -49,7 +49,7 @@ define([
describe('once rendered', function () {
var model;
var availableStyles;
var view;
var innerView;
before(function () {
model = new Backbone.SuperModel({
text: {
@ -88,91 +88,91 @@ define([
'10px', '12px', '14px', '16px', '18px'
]
});
view = new (SidebarComponent.SidebarStylesView)({
innerView = new (SidebarComponent.SidebarStylesView)({
model: model,
availableStyles: availableStyles
});
view.render();
innerView.render();
});
it('changes model if text font color field changes', function () {
view.$('#mailpoet_text_font_color').val('#123456').change();
innerView.$('#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();
innerView.$('#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();
innerView.$('#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();
innerView.$('#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();
innerView.$('#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();
innerView.$('#mailpoet_newsletter_background_color').val('#636237').change();
expect(model.get('wrapper.backgroundColor')).to.equal('#636237');
});
it('changes model if background color field changes', function () {
view.$('#mailpoet_background_color').val('#878587').change();
innerView.$('#mailpoet_background_color').val('#878587').change();
expect(model.get('body.backgroundColor')).to.equal('#878587');
});
it('changes model if text font family field changes', function () {
view.$('#mailpoet_text_font_family').val('Times New Roman').change();
innerView.$('#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();
innerView.$('#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();
innerView.$('#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();
innerView.$('#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();
innerView.$('#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();
innerView.$('#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();
innerView.$('#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();
innerView.$('#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();
innerView.$('#mailpoet_a_font_underline').prop('checked', true).change();
expect(model.get('link.textDecoration')).to.equal('underline');
});
});