Fix tests comma-dangle eslint rule [MAILPOET-1028]

This commit is contained in:
stoletniy
2017-07-27 18:14:30 +03:00
committed by pavel-mailpoet
parent 66c6f52646
commit f0c59ff635
21 changed files with 267 additions and 268 deletions

View File

@ -35,7 +35,6 @@
"quote-props": 0,
"no-shadow": 0,
"padded-blocks": 0,
"comma-dangle": 0,
"vars-on-top": 0,
"space-before-blocks": 0,
"object-curly-spacing": 0,

View File

@ -23,5 +23,5 @@ module.exports = {
options.type = "text/x-handlebars-template";
this.loadScript("views/newsletter/templates/" + path, w, options);
},
}
};

View File

@ -57,7 +57,7 @@ global.stubChannel = function (EditorApplication, returnObject) {
trigger: function () {
},
on: function () {
},
}
}));
};
global.stubConfig = function (EditorApplication, config) {
@ -83,7 +83,7 @@ global.stubImage = function(defaultWidth, defaultHeight) {
"set": function(src) {
this.address = src;
this.onload();
},
}
});
};
}
@ -225,5 +225,5 @@ global.templates = {
textBlock: Handlebars.compile(jQuery('#newsletter_editor_template_text_block').html()),
textInsertion: Handlebars.compile(jQuery('#newsletter_editor_template_text_widget').html()),
textBlockSettings: Handlebars.compile(jQuery('#newsletter_editor_template_text_settings').html()),
textBlockSettings: Handlebars.compile(jQuery('#newsletter_editor_template_text_settings').html())
};

View File

@ -3,7 +3,7 @@ define([
'newsletter_editor/blocks/automatedLatestContent',
'newsletter_editor/blocks/container',
'amd-inject-loader!newsletter_editor/blocks/automatedLatestContent',
'newsletter_editor/components/communication',
'newsletter_editor/components/communication'
], function(
EditorApplication,
AutomatedLatestContentBlock,
@ -28,7 +28,7 @@ define([
var module = AutomatedLatestContentInjector({
'newsletter_editor/components/communication': {
getBulkTransformedPosts: mock
},
}
});
var model = new module.ALCSupervisor();
@ -41,11 +41,11 @@ define([
var block1 = new Backbone.SuperModel(),
block2 = new Backbone.SuperModel(),
postsSet1 = [
{ type: 'customTypeOne' },
{ type: 'customTypeOne' }
],
postsSet2 = [
{ type: 'customTypeTwo' },
{ type: 'customTypeTwo' },
{ type: 'customTypeTwo' }
],
mock1 = sinon.mock(block1),
mock2 = sinon.mock(block2);
@ -189,14 +189,14 @@ define([
styles: {
block: {
backgroundColor: '#123456',
borderColor: '#234567',
borderColor: '#234567'
},
link: {
fontColor: '#345678',
fontFamily: 'Tahoma',
fontSize: '37px',
},
},
fontSize: '37px'
}
}
},
sortBy: 'oldest', // 'newest'|'oldest',
showDivider: true, // true|false
@ -205,12 +205,12 @@ define([
styles: {
block: {
backgroundColor: '#456789',
padding: '38px',
},
},
},
},
},
padding: '38px'
}
}
}
}
}
});
var model = new (module.AutomatedLatestContentBlockModel)();
@ -248,7 +248,7 @@ define([
var model = new (module.AutomatedLatestContentBlockModel)();
model.updatePosts([{
type: 'someCustomType',
type: 'someCustomType'
}]);
expect(model.get('_container.blocks').size()).to.equal(1);
@ -309,9 +309,9 @@ define([
const data = {
styles: {
block: {
borderRadius: "14px",
},
},
borderRadius: "14px"
}
}
};
callback(data);
expect(model.set).to.have.been.calledOnce;
@ -328,7 +328,7 @@ define([
getPostTypes: function() {
return jQuery.Deferred();
}
},
}
});
});
@ -339,28 +339,28 @@ define([
{
name: 'post',
labels: {
singular_name: 'Post',
},
singular_name: 'Post'
}
},
{
name: 'page',
labels: {
singular_name: 'Page',
},
singular_name: 'Page'
}
},
{
name: 'mailpoet_page',
labels: {
singular_name: 'Mailpoet page',
},
},
singular_name: 'Mailpoet page'
}
}
]);
return deferred;
};
global.stubChannel(EditorApplication);
global.stubConfig(EditorApplication, {
blockDefaults: {},
blockDefaults: {}
});
EditorApplication.getBlockTypeModel = sinon.stub().returns(Backbone.Model);
EditorApplication.getBlockTypeView = sinon.stub().returns(Backbone.View);

View File

@ -10,7 +10,7 @@ define([
beforeEach(function () {
global.stubChannel(EditorApplication);
global.stubConfig(EditorApplication, {
blockDefaults: {},
blockDefaults: {}
});
model = new (ButtonBlock.ButtonBlockModel)();
});
@ -86,7 +86,7 @@ define([
it("triggers autosave if any attribute changes", function () {
var mock = sinon.mock().exactly(12).withArgs('autoSave');
EditorApplication.getChannel = sinon.stub().returns({
trigger: mock,
trigger: mock
});
model.set('text', 'some other text');
model.set('url', 'some url');
@ -121,11 +121,11 @@ define([
fontColor: '#345678',
fontFamily: 'Tahoma',
fontSize: '30px',
fontWeight: 'bold',
},
},
},
},
fontWeight: 'bold'
}
}
}
}
});
var model = new (ButtonBlock.ButtonBlockModel)();
@ -188,9 +188,9 @@ define([
fontColor: '#345678',
fontFamily: 'Arial',
fontSize: '12px',
fontWeight: 'bold',
},
},
fontWeight: 'bold'
}
}
});
view = new (ButtonBlock.ButtonBlockView)({model: model});
view.render();
@ -281,9 +281,9 @@ define([
const data = {
styles: {
block: {
borderRadius: "14px",
},
},
borderRadius: "14px"
}
}
};
callback(data);
expect(model.set).to.have.been.calledOnce;
@ -298,12 +298,12 @@ define([
global.stubChannel(EditorApplication);
global.stubAvailableStyles(EditorApplication, {
fonts: ['Arial', 'Tahoma'],
headingSizes: ['16px', '20px'],
headingSizes: ['16px', '20px']
});
model = new (ButtonBlock.ButtonBlockModel)({
type: 'button',
text: 'Some random text',
text: 'Some random text'
});
});
@ -319,14 +319,14 @@ define([
global.stubConfig(EditorApplication);
global.stubAvailableStyles(EditorApplication, {
fonts: ['Arial', 'Tahoma'],
headingSizes: ['16px', '20px'],
headingSizes: ['16px', '20px']
});
});
beforeEach(function() {
model = new (ButtonBlock.ButtonBlockModel)({
type: 'button',
text: 'Some random text',
text: 'Some random text'
});
view = new (ButtonBlock.ButtonBlockSettingsView)({model: model});
@ -449,8 +449,8 @@ define([
view = new (ButtonBlock.ButtonBlockSettingsView)({
model: model,
renderOptions: {
hideLink: true,
},
hideLink: true
}
});
view.render();
expect(view.$('.mailpoet_field_button_url').length).to.equal(0);
@ -460,8 +460,8 @@ define([
view = new (ButtonBlock.ButtonBlockSettingsView)({
model: model,
renderOptions: {
hideApplyToAll: true,
},
hideApplyToAll: true
}
});
view.render();
expect(view.$('.mailpoet_field_button_replace_all_styles').length).to.equal(0);

View File

@ -33,11 +33,11 @@ define([
container: {
styles: {
block: {
backgroundColor: '#123456',
},
},
},
},
backgroundColor: '#123456'
}
}
}
}
});
var model = new (ContainerBlock.ContainerBlockModel)();
@ -48,7 +48,7 @@ define([
describe('when creating with children', function () {
var testModel = {
type: 'sampleType',
someField: 'Some Content',
someField: 'Some Content'
},
model;
@ -57,7 +57,7 @@ define([
model = new (ContainerBlock.ContainerBlockModel)({
type: 'container',
blocks: [testModel],
blocks: [testModel]
}, {parse: true});
expect(model.get('blocks')).to.have.length(1);
@ -79,15 +79,15 @@ define([
blocks: [
{
type: 'someType',
someField: 'some text',
someField: 'some text'
},
{
type: 'someType',
someField: 'some text 2',
},
],
someField: 'some text 2'
}
],
]
}
]
}, {parse: true});
expect(model.get('blocks')).to.have.length(1);
@ -119,8 +119,8 @@ define([
view = new (ContainerBlock.ContainerBlockView)({
model: model,
renderOptions: {
depth: 0,
},
depth: 0
}
});
view.render();
});
@ -151,8 +151,8 @@ define([
view = new (ContainerBlock.ContainerBlockView)({
model: model,
renderOptions: {
depth: 1,
},
depth: 1
}
});
view.render();
});

View File

@ -10,7 +10,7 @@ define([
beforeEach(function () {
global.stubChannel(EditorApplication);
global.stubConfig(EditorApplication, {
blockDefaults: {},
blockDefaults: {}
});
global.stubAvailableStyles(EditorApplication);
model = new (DividerBlock.DividerBlockModel)();
@ -53,7 +53,7 @@ define([
it("triggers autosave if any attribute changes", function () {
var mock = sinon.mock().exactly(5).withArgs('autoSave');
EditorApplication.getChannel = sinon.stub().returns({
trigger: mock,
trigger: mock
});
model.set('styles.block.backgroundColor', '#000000');
@ -75,11 +75,11 @@ define([
padding: '37px',
borderStyle: 'inset',
borderWidth: '7px',
borderColor: '#345678',
},
},
},
},
borderColor: '#345678'
}
}
}
}
});
var model = new (DividerBlock.DividerBlockModel)();
@ -136,7 +136,7 @@ define([
global.stubChannel(EditorApplication);
global.stubConfig(EditorApplication);
global.stubAvailableStyles(EditorApplication, {
dividers: ['solid', 'inset'],
dividers: ['solid', 'inset']
});
var model = new (DividerBlock.DividerBlockModel)(),
view = new (DividerBlock.DividerBlockSettingsView)({model: model});
@ -152,7 +152,7 @@ define([
before(function() {
global.stubChannel(EditorApplication);
global.stubAvailableStyles(EditorApplication, {
dividers: ['solid', 'inset'],
dividers: ['solid', 'inset']
});
});
@ -202,8 +202,8 @@ define([
view = new (DividerBlock.DividerBlockSettingsView)({
model: model,
renderOptions: {
hideApplyToAll: true,
},
hideApplyToAll: true
}
});
view.render();
expect(view.$('.mailpoet_button_divider_apply_to_all').length).to.equal(0);

View File

@ -9,7 +9,7 @@ define([
beforeEach(function () {
global.stubChannel(EditorApplication);
global.stubConfig(EditorApplication, {
blockDefaults: {},
blockDefaults: {}
});
model = new (FooterBlock.FooterBlockModel)();
});
@ -59,7 +59,7 @@ define([
it('triggers autosave when any of the attributes change', function () {
var mock = sinon.mock().exactly(8).withArgs('autoSave');
EditorApplication.getChannel = sinon.stub().returns({
trigger: mock,
trigger: mock
});
model.set('text', 'Some new text');
@ -81,21 +81,21 @@ define([
text: 'some custom config text',
styles: {
block: {
backgroundColor: '#123456',
backgroundColor: '#123456'
},
text: {
fontColor: '#234567',
fontFamily: 'Tahoma',
fontSize: '37px',
textAlign: 'right',
textAlign: 'right'
},
link: {
fontColor: '#345678',
textDecoration: 'underline',
},
},
textDecoration: 'underline'
}
}
}
}
},
});
var model = new (FooterBlock.FooterBlockModel)();
@ -133,7 +133,7 @@ define([
global.stubChannel(EditorApplication);
global.stubAvailableStyles(EditorApplication, {
fonts: ['Arial', 'Tahoma'],
textSizes: ['16px', '20px'],
textSizes: ['16px', '20px']
});
var model = new (FooterBlock.FooterBlockModel)(),
view = new (FooterBlock.FooterBlockSettingsView)({model: model});
@ -150,7 +150,7 @@ define([
global.stubChannel(EditorApplication);
global.stubAvailableStyles(EditorApplication, {
fonts: ['Arial', 'Tahoma'],
textSizes: ['16px', '20px'],
textSizes: ['16px', '20px']
});
model = new (FooterBlock.FooterBlockModel)({});
view = new (FooterBlock.FooterBlockSettingsView)({model: model});

View File

@ -9,7 +9,7 @@ define([
beforeEach(function () {
global.stubChannel(EditorApplication);
global. stubConfig(EditorApplication, {
blockDefaults: {},
blockDefaults: {}
});
model = new (HeaderBlock.HeaderBlockModel)();
});
@ -59,7 +59,7 @@ define([
it("triggers autosave if any attribute changes", function () {
var mock = sinon.mock().exactly(8).withArgs('autoSave');
EditorApplication.getChannel = sinon.stub().returns({
trigger: mock,
trigger: mock
});
model.set('text', 'Some new text');
@ -81,21 +81,21 @@ define([
text: 'some custom config text',
styles: {
block: {
backgroundColor: '#123456',
backgroundColor: '#123456'
},
text: {
fontColor: '#234567',
fontFamily: 'Tahoma',
fontSize: '37px',
textAlign: 'right',
textAlign: 'right'
},
link: {
fontColor: '#345678',
textDecoration: 'underline',
},
},
},
},
textDecoration: 'underline'
}
}
}
}
});
var model = new (HeaderBlock.HeaderBlockModel)();
@ -133,7 +133,7 @@ define([
global.stubConfig(EditorApplication);
global.stubAvailableStyles(EditorApplication, {
fonts: ['Arial', 'Tahoma'],
textSizes: ['16px', '20px'],
textSizes: ['16px', '20px']
});
var model = new (HeaderBlock.HeaderBlockModel)(),
view = new (HeaderBlock.HeaderBlockSettingsView)({model: model});
@ -150,7 +150,7 @@ define([
global.stubChannel(EditorApplication);
global.stubAvailableStyles(EditorApplication, {
fonts: ['Arial', 'Tahoma'],
textSizes: ['16px', '20px'],
textSizes: ['16px', '20px']
});
model = new (HeaderBlock.HeaderBlockModel)({});
view = new (HeaderBlock.HeaderBlockSettingsView)({model: model});

View File

@ -9,7 +9,7 @@ define([
beforeEach(function () {
global.stubChannel(EditorApplication);
global.stubConfig(EditorApplication, {
blockDefaults: {},
blockDefaults: {}
});
model = new (ImageBlock.ImageBlockModel)();
});
@ -55,7 +55,7 @@ define([
it('triggers autosave when any of the attributes change', function () {
var mock = sinon.mock().exactly(7).withArgs('autoSave');
EditorApplication.getChannel = sinon.stub().returns({
trigger: mock,
trigger: mock
});
model.set('link', 'http://example.net');
@ -81,11 +81,11 @@ define([
height: '2345px',
styles: {
block: {
textAlign: 'right',
},
},
textAlign: 'right'
}
}
}
}
},
});
var model = new (ImageBlock.ImageBlockModel)();
@ -125,7 +125,7 @@ define([
model = new (ImageBlock.ImageBlockModel)({
link: 'http://example.org/somepath',
src: 'http://example.org/someimage.png',
alt: 'some alt',
alt: 'some alt'
});
view = new (ImageBlock.ImageBlockView)({model: model});
view.render();
@ -163,7 +163,7 @@ define([
before(function () {
global.stubChannel(EditorApplication);
global.stubConfig(EditorApplication, {
blockDefaults: {},
blockDefaults: {}
});
global.stubImage(newWidth, newHeight);
model = new (ImageBlock.ImageBlockModel)();

View File

@ -10,8 +10,8 @@ define([
Requests: {
request: function () {
}, reply: function () {
},
},
}
}
};
describe('model', function () {
var model;
@ -148,14 +148,14 @@ define([
styles: {
block: {
backgroundColor: '#123456',
borderColor: '#234567',
borderColor: '#234567'
},
link: {
fontColor: '#345678',
fontFamily: 'Tahoma',
fontSize: '37px',
},
},
fontSize: '37px'
}
}
},
sortBy: 'oldest', // 'newest'|'oldest',
showDivider: true, // true|false
@ -164,12 +164,12 @@ define([
styles: {
block: {
backgroundColor: '#456789',
padding: '38px',
},
},
},
},
},
padding: '38px'
}
}
}
}
}
});
var model = new (PostsBlock.PostsBlockModel)();
@ -286,28 +286,28 @@ define([
{
name: 'post',
labels: {
singular_name: 'Post',
},
singular_name: 'Post'
}
},
{
name: 'page',
labels: {
singular_name: 'Page',
},
singular_name: 'Page'
}
},
{
name: 'mailpoet_page',
labels: {
singular_name: 'Mailpoet page',
},
},
singular_name: 'Mailpoet page'
}
}
]);
return deferred;
};
global.stubChannel(EditorApplication);
global.stubConfig(EditorApplication, {
blockDefaults: {},
blockDefaults: {}
});
EditorApplication.getBlockTypeModel = sinon.stub().returns(ContainerBlock.ContainerBlockModel);
model = new (PostsBlock.PostsBlockModel)();

View File

@ -1,7 +1,7 @@
define([
'newsletter_editor/App',
'newsletter_editor/blocks/social',
'backbone',
'backbone'
], function(EditorApplication, SocialBlock, Backbone) {
describe('Social', function () {
@ -29,9 +29,9 @@ define([
global.stubConfig(EditorApplication, {
blockDefaults: {
social: {
iconSet: 'customConfigIconSet',
},
},
iconSet: 'customConfigIconSet'
}
}
});
var model = new (SocialBlock.SocialBlockModel)();
@ -44,15 +44,15 @@ define([
before(function () {
global.stubChannel(EditorApplication);
global.stubAvailableStyles(EditorApplication, {
'socialIconSets.default.custom': 'someimage.jpg',
'socialIconSets.default.custom': 'someimage.jpg'
});
global.stubConfig(EditorApplication, {
socialIcons: {
custom: {
defaultLink: 'http://example.org',
title: 'sometitle',
title: 'sometitle'
}
}
},
});
model = new (SocialBlock.SocialIconModel)();
});
@ -91,19 +91,19 @@ define([
global.stubAvailableStyles(EditorApplication, {
socialIconSets: {
'default': {
'custom': 'http://www.sott.net/images/icons/big_x.png',
'custom': 'http://www.sott.net/images/icons/big_x.png'
},
'light': {
'custom': 'http://content.indiainfoline.com/wc/news/ImageGallery/css/close_32x32.png',
},
'custom': 'http://content.indiainfoline.com/wc/news/ImageGallery/css/close_32x32.png'
}
},
socialIcons: {
'custom': {
title: 'Custom',
linkFieldName: 'Page URL',
defaultLink: 'http://example.org',
},
},
defaultLink: 'http://example.org'
}
}
});
model = new (SocialBlock.SocialBlockModel)({
type: 'social',
@ -114,9 +114,9 @@ define([
iconType: 'custom',
link: 'somelink.htm',
image: 'someimage.png',
text: 'some text',
text: 'some text'
}
],
]
});
});
@ -140,16 +140,16 @@ define([
iconType: 'custom',
link: 'http://example.org/',
image: 'http://example.org/someimage.png',
text: 'some text',
text: 'some text'
},
{
type: 'socialIcon',
iconType: 'facebook',
link: 'http://facebook.com/',
image: 'http://facebook.com/icon.png',
text: 'Facebook icon',
},
],
text: 'Facebook icon'
}
]
});
view = new (SocialBlock.SocialBlockView)({model: model});
view.render();
@ -175,19 +175,19 @@ define([
global.stubAvailableStyles(EditorApplication, {
socialIconSets: {
'default': {
'custom': 'someimage.png',
'custom': 'someimage.png'
},
'light': {
'custom': 'http://content.indiainfoline.com/wc/news/ImageGallery/css/close_32x32.png',
},
'custom': 'http://content.indiainfoline.com/wc/news/ImageGallery/css/close_32x32.png'
}
},
socialIcons: {
'custom': {
title: 'Custom',
linkFieldName: 'Page URL',
defaultLink: 'http://example.org',
},
},
defaultLink: 'http://example.org'
}
}
});
model = new (SocialBlock.SocialBlockModel)({
type: 'social',
@ -200,9 +200,9 @@ define([
image: 'someimage.png',
height: '32px',
width: '32px',
text: 'some text',
text: 'some text'
}
],
]
});
});
@ -218,19 +218,19 @@ define([
global.stubAvailableStyles(EditorApplication, {
socialIconSets: {
'default': {
'custom': 'http://www.sott.net/images/icons/big_x.png',
'custom': 'http://www.sott.net/images/icons/big_x.png'
},
'light': {
'custom': 'http://content.indiainfoline.com/wc/news/ImageGallery/css/close_32x32.png',
},
'custom': 'http://content.indiainfoline.com/wc/news/ImageGallery/css/close_32x32.png'
}
},
socialIcons: {
'custom': {
title: 'Custom',
linkFieldName: 'Page URL',
defaultLink: 'http://example.org',
},
},
defaultLink: 'http://example.org'
}
}
});
model = new (SocialBlock.SocialBlockModel)({
type: 'social',
@ -243,9 +243,9 @@ define([
image: 'someimage.png',
height: '32px',
width: '32px',
text: 'some text',
text: 'some text'
}
],
]
});
view = new (SocialBlock.SocialBlockSettingsView)({model: model});
view.render();

View File

@ -10,7 +10,7 @@ define([
beforeEach(function () {
global.stubChannel(EditorApplication);
global.stubConfig(EditorApplication, {
blockDefaults: {},
blockDefaults: {}
});
global.stubAvailableStyles(EditorApplication);
model = new (SpacerBlock.SpacerBlockModel)();
@ -41,7 +41,7 @@ define([
it("triggers autosave if any attribute changes", function () {
var mock = sinon.mock().exactly(2).withArgs('autoSave');
EditorApplication.getChannel = sinon.stub().returns({
trigger: mock,
trigger: mock
});
model.set('styles.block.backgroundColor', '#000000');
@ -57,11 +57,11 @@ define([
styles: {
block: {
backgroundColor: '#567890',
height: '19px',
},
},
},
},
height: '19px'
}
}
}
}
});
var model = new (SpacerBlock.SpacerBlockModel)();

View File

@ -24,9 +24,9 @@ define([
global.stubConfig(EditorApplication, {
blockDefaults: {
text: {
text: 'some custom config text',
},
},
text: 'some custom config text'
}
}
});
var model = new (TextBlock.TextBlockModel)();

View File

@ -14,13 +14,13 @@ define([
deferred.resolve({
data: {
'post': 'val1',
'page': 'val2',
'page': 'val2'
}
});
return deferred;
}
},
},
}
}
});
module.getPostTypes().done(function(types) {
expect(types).to.eql(['val1', 'val2']);
@ -33,13 +33,13 @@ define([
module = CommunicationInjector({
"mailpoet": {
Ajax: {
post: mock,
},
},
post: mock
}
}
});
deferred.resolve({
'post': 'val1',
'page': 'val2',
'page': 'val2'
});
module.getPostTypes();
module.getPostTypes();
@ -55,7 +55,7 @@ define([
var deferred = jQuery.Deferred();
deferred.resolve({
'category': 'val1',
'post_tag': 'val2',
'post_tag': 'val2'
});
return deferred;
},
@ -64,9 +64,9 @@ define([
module = CommunicationInjector({
"mailpoet": {
Ajax: {
post: spy,
},
},
post: spy
}
}
});
module.getTaxonomies('post');
@ -86,8 +86,8 @@ define([
});
return deferred;
}
},
},
}
}
});
module.getTaxonomies('page').done(function(types) {
expect(types).to.eql({ 'category': 'val1' });
@ -100,9 +100,9 @@ define([
module = CommunicationInjector({
"mailpoet": {
Ajax: {
post: mock,
},
},
post: mock
}
}
});
deferred.resolve({ 'category': 'val1' });
module.getTaxonomies('page');
@ -125,13 +125,13 @@ define([
module = CommunicationInjector({
"mailpoet": {
Ajax: {
post: spy,
},
},
post: spy
}
}
});
module.getTerms({
taxonomies: ['category', 'post_tag'],
taxonomies: ['category', 'post_tag']
});
expect(spy.args[0][0].data.taxonomies).to.eql(['category', 'post_tag']);
});
@ -150,8 +150,8 @@ define([
});
return deferred;
}
},
},
}
}
});
module.getTerms({ taxonomies: ['category'] }).done(function(types) {
expect(types).to.eql({ 'term1': 'term1val1', 'term2': 'term2val2' });
@ -164,9 +164,9 @@ define([
module = CommunicationInjector({
"mailpoet": {
Ajax: {
post: mock,
},
},
post: mock
}
}
});
deferred.resolve({ 'term1': 'term1val1', 'term2': 'term2val2' });
module.getTerms({ taxonomies: ['category'] });
@ -189,9 +189,9 @@ define([
module = CommunicationInjector({
"mailpoet": {
Ajax: {
post: spy,
},
},
post: spy
}
}
});
module.getPosts({
@ -218,8 +218,8 @@ define([
});
return deferred;
}
},
},
}
}
});
module.getPosts().done(function(posts) {
expect(posts).to.eql([{post_title: 'title 1'}, {post_title: 'post title 2'}]);
@ -232,9 +232,9 @@ define([
module = CommunicationInjector({
"mailpoet": {
Ajax: {
post: mock,
},
},
post: mock
}
}
});
deferred.resolve({
type: 'posts',
@ -260,9 +260,9 @@ define([
module = CommunicationInjector({
"mailpoet": {
Ajax: {
post: spy,
},
},
post: spy
}
}
});
module.getTransformedPosts({
@ -271,7 +271,7 @@ define([
});
expect(spy.args[0][0].data).to.eql({
type: 'posts',
posts: [1, 2],
posts: [1, 2]
});
});
@ -289,8 +289,8 @@ define([
});
return deferred;
}
},
},
}
}
});
module.getTransformedPosts().done(function(posts) {
expect(posts).to.eql([{type: 'text', text: 'something'}, {type: 'text', text: 'something else'}]);
@ -303,13 +303,13 @@ define([
module = CommunicationInjector({
"mailpoet": {
Ajax: {
post: mock,
},
},
post: mock
}
}
});
deferred.resolve({
type: 'posts',
posts: [1, 3],
posts: [1, 3]
});
module.getTransformedPosts({});
module.getTransformedPosts({});

View File

@ -6,7 +6,7 @@ define([
describe('Config', function () {
it('loads and stores configuration', function() {
ConfigComponent.setConfig({
testConfig: 'testValue',
testConfig: 'testValue'
});
var model = ConfigComponent.getConfig();
expect(model.get('testConfig')).to.equal('testValue');

View File

@ -12,12 +12,12 @@ define([
body: {
globalStyles: {
style1: 'style1Value',
style2: 'style2Value',
style2: 'style2Value'
},
content: {
data1: 'data1Value',
data2: 'data2Value',
},
data2: 'data2Value'
}
},
subject: 'my test subject'
});
@ -26,7 +26,7 @@ define([
it('triggers autosave on change', function() {
var mock = sinon.mock({ trigger: function() {} }).expects('trigger').once().withArgs('autoSave');
global.stubChannel(EditorApplication, {
trigger: mock,
trigger: mock
});
model.set('subject', 'another test subject');
mock.verify();
@ -63,7 +63,7 @@ define([
blockView = new Backbone.View();
ContentComponent.registerBlockType('testType', {
blockModel: blockModel,
blockView: blockView,
blockView: blockView
});
expect(ContentComponent.getBlockTypeModel('testType')).to.deep.equal(blockModel);
expect(ContentComponent.getBlockTypeView('testType')).to.deep.equal(blockView);
@ -73,11 +73,11 @@ define([
describe('transformation to json', function() {
it('includes content, globalStyles and initial newsletter fields', function() {
var dataField = {
containerModelField: 'containerModelValue',
containerModelField: 'containerModelValue'
}, stylesField = {
globalStylesField: 'globalStylesValue',
globalStylesField: 'globalStylesValue'
}, newsletterFields = {
subject: 'test newsletter subject',
subject: 'test newsletter subject'
};
EditorApplication._contentContainer = {
toJSON: function() {
@ -88,14 +88,14 @@ define([
return {
toJSON: function() {
return stylesField;
},
}
};
};
EditorApplication.getNewsletter = function() {
return {
toJSON: function() {
return newsletterFields;
},
}
};
};
var json = ContentComponent.toJSON();
@ -103,7 +103,7 @@ define([
body: {
content: dataField,
globalStyles: stylesField
},
}
}, newsletterFields));
});
});

View File

@ -8,10 +8,10 @@ define([
var view;
beforeEach(function() {
var model = new Backbone.SuperModel({
subject: 'a test subject',
subject: 'a test subject'
});
view = new (HeadingComponent.HeadingView)({
model: model,
model: model
});
});
@ -24,10 +24,10 @@ define([
beforeEach(function() {
model = new Backbone.SuperModel({
subject: 'a test subject',
preheader: 'a test preheader',
preheader: 'a test preheader'
});
view = new (HeadingComponent.HeadingView)({
model: model,
model: model
});
view.render();
});

View File

@ -21,12 +21,12 @@ define([
it('triggers beforeEditorSave event', function() {
var spy = sinon.spy();
global.stubChannel(EditorApplication, {
trigger: spy,
trigger: spy
});
EditorApplication.toJSON = sinon.stub().returns({
body: {
type: 'container',
},
type: 'container'
}
});
module.save();
expect(spy.withArgs('beforeEditorSave').calledOnce).to.be.true;
@ -36,16 +36,16 @@ define([
var spy = sinon.spy(),
promise = jQuery.Deferred();
global.stubChannel(EditorApplication, {
trigger: spy,
trigger: spy
});
EditorApplication.toJSON = sinon.stub().returns({
body: {
type: 'container',
},
type: 'container'
}
});
var module = SaveInjector({
'newsletter_editor/components/communication': {
saveNewsletter: sinon.stub().returns(promise),
saveNewsletter: sinon.stub().returns(promise)
}
});
promise.resolve({ success: true });
@ -57,7 +57,7 @@ define([
var mock = sinon.mock().once().returns(jQuery.Deferred());
var module = SaveInjector({
'newsletter_editor/components/communication': {
saveNewsletter: mock,
saveNewsletter: mock
}
});
global.stubChannel(EditorApplication);
@ -73,17 +73,17 @@ define([
mock = sinon.mock()
.once()
.withArgs({
body: JSON.stringify(body),
body: JSON.stringify(body)
})
.returns(jQuery.Deferred());
global.stubChannel(EditorApplication);
EditorApplication.toJSON = sinon.stub().returns({
body: body,
body: body
});
var module = SaveInjector({
'newsletter_editor/components/communication': {
saveNewsletter: mock,
saveNewsletter: mock
}
});
module.save();
@ -125,7 +125,7 @@ define([
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,
trigger: mock
});
view.$('.mailpoet_save_button').click();
@ -142,29 +142,29 @@ define([
html2canvasMock = jQuery.Deferred();
html2canvasMock.resolve({
toDataURL: function() { return 'somedataurl'; },
toDataURL: function() { return 'somedataurl'; }
});
EditorApplication.getBody = sinon.stub();
var module = SaveInjector({
'mailpoet': {
Ajax: {
post: mock,
post: mock
},
I18n: {
t: function() { return ''; },
t: function() { return ''; }
},
Notice: {
success: function() {},
error: function() {},
},
error: function() {}
}
},
'newsletter_editor/App': EditorApplication,
'html2canvas': function() {
return {
then: function() { return html2canvasMock; }
};
},
}
});
var view = new (module.SaveView)();
view.render();

View File

@ -8,7 +8,7 @@ define([
var view;
beforeEach(function() {
view = new (SidebarComponent.SidebarWidgetsView)({
collection: new Backbone.Collection([]),
collection: new Backbone.Collection([])
});
});
@ -21,7 +21,7 @@ define([
var view;
beforeEach(function() {
view = new (SidebarComponent.SidebarLayoutWidgetsView)({
collection: new Backbone.Collection([]),
collection: new Backbone.Collection([])
});
});
@ -35,7 +35,7 @@ define([
beforeEach(function() {
view = new (SidebarComponent.SidebarStylesView)({
model: new Backbone.SuperModel({}),
availableStyles: new Backbone.SuperModel({}),
availableStyles: new Backbone.SuperModel({})
});
});
@ -49,43 +49,43 @@ define([
model = new Backbone.SuperModel({
text: {
fontColor: '#000000',
fontFamily: 'Arial',
fontFamily: 'Arial'
},
h1: {
fontColor: '#000001',
fontFamily: 'Arial',
fontFamily: 'Arial'
},
h2: {
fontColor: '#000002',
fontFamily: 'Arial',
fontFamily: 'Arial'
},
h3: {
fontColor: '#000003',
fontFamily: 'Arial',
fontFamily: 'Arial'
},
link: {
fontColor: '#000005',
textDecoration: 'none',
textDecoration: 'none'
},
wrapper: {
backgroundColor: '#090909',
backgroundColor: '#090909'
},
body: {
backgroundColor: '#020202',
},
backgroundColor: '#020202'
}
});
availableStyles = new Backbone.SuperModel({
fonts: ['Arial', 'Times New Roman', 'Tahoma', 'Comic Sans', 'Lucida'],
textSizes: [
'9px', '10px',
'9px', '10px'
],
headingSizes: [
'10px', '12px', '14px', '16px', '18px',
],
'10px', '12px', '14px', '16px', '18px'
]
});
view = new (SidebarComponent.SidebarStylesView)({
model: model,
availableStyles: availableStyles,
availableStyles: availableStyles
});
view.render();

View File

@ -6,7 +6,7 @@ define([
describe('Styles', function () {
it('loads and stores globally available styles', function() {
StylesComponent.setGlobalStyles({
testStyle: 'testValue',
testStyle: 'testValue'
});
var model = StylesComponent.getGlobalStyles();
expect(model.get('testStyle')).to.equal('testValue');
@ -22,7 +22,7 @@ define([
var mock = sinon.mock({ trigger: function(){}}).expects('trigger').once().withExactArgs('autoSave');
EditorApplication.getChannel = function() {
return {
trigger: mock,
trigger: mock
};
};
model.set('text.fontColor', '#123456');