Tests vars-on-top
This commit is contained in:
@ -20,7 +20,6 @@
|
|||||||
"no-underscore-dangle": 0,
|
"no-underscore-dangle": 0,
|
||||||
"no-shadow": 0,
|
"no-shadow": 0,
|
||||||
"padded-blocks": 0,
|
"padded-blocks": 0,
|
||||||
"vars-on-top": 0,
|
|
||||||
"space-before-blocks": 0,
|
"space-before-blocks": 0,
|
||||||
"object-curly-spacing": 0,
|
"object-curly-spacing": 0,
|
||||||
"func-names": 0,
|
"func-names": 0,
|
||||||
|
@ -3,6 +3,7 @@ var sinon = require('sinon');
|
|||||||
var sinonChai = require('sinon-chai');
|
var sinonChai = require('sinon-chai');
|
||||||
var chaiJq = require('chai-jq');
|
var chaiJq = require('chai-jq');
|
||||||
var _ = require('underscore');
|
var _ = require('underscore');
|
||||||
|
var jsdom = require('jsdom').jsdom;
|
||||||
|
|
||||||
chai.use(sinonChai);
|
chai.use(sinonChai);
|
||||||
chai.use(chaiJq);
|
chai.use(chaiJq);
|
||||||
@ -11,7 +12,6 @@ global.expect = chai.expect;
|
|||||||
global.sinon = sinon;
|
global.sinon = sinon;
|
||||||
|
|
||||||
if (!global.document || !global.window) {
|
if (!global.document || !global.window) {
|
||||||
var jsdom = require('jsdom').jsdom;
|
|
||||||
|
|
||||||
global.document = jsdom('<html><head><script></script></head><body></body></html>', {}, {
|
global.document = jsdom('<html><head><script></script></head><body></body></html>', {}, {
|
||||||
FetchExternalResources: ['script'],
|
FetchExternalResources: ['script'],
|
||||||
|
@ -21,6 +21,8 @@ define([
|
|||||||
|
|
||||||
describe('Automated Latest Content Supervisor', function() {
|
describe('Automated Latest Content Supervisor', function() {
|
||||||
var model;
|
var model;
|
||||||
|
var mock;
|
||||||
|
var module;
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
model = new AutomatedLatestContentBlock.ALCSupervisor();
|
model = new AutomatedLatestContentBlock.ALCSupervisor();
|
||||||
});
|
});
|
||||||
@ -29,16 +31,16 @@ define([
|
|||||||
global.stubChannel(EditorApplication);
|
global.stubChannel(EditorApplication);
|
||||||
EditorApplication.findModels = sinon.stub().returns([new Backbone.SuperModel()]);
|
EditorApplication.findModels = sinon.stub().returns([new Backbone.SuperModel()]);
|
||||||
|
|
||||||
var mock = sinon.mock({ getBulkTransformedPosts: function() {} })
|
mock = sinon.mock({ getBulkTransformedPosts: function() {} })
|
||||||
.expects('getBulkTransformedPosts').once().returns(jQuery.Deferred());
|
.expects('getBulkTransformedPosts').once().returns(jQuery.Deferred());
|
||||||
|
|
||||||
var module = AutomatedLatestContentInjector({
|
module = AutomatedLatestContentInjector({
|
||||||
'newsletter_editor/components/communication': {
|
'newsletter_editor/components/communication': {
|
||||||
getBulkTransformedPosts: mock
|
getBulkTransformedPosts: mock
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var model = new module.ALCSupervisor();
|
model = new module.ALCSupervisor();
|
||||||
model.refresh();
|
model.refresh();
|
||||||
|
|
||||||
mock.verify();
|
mock.verify();
|
||||||
@ -173,6 +175,7 @@ define([
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('uses defaults from config when they are set', function () {
|
it('uses defaults from config when they are set', function () {
|
||||||
|
var model;
|
||||||
global.stubConfig(EditorApplication, {
|
global.stubConfig(EditorApplication, {
|
||||||
blockDefaults: {
|
blockDefaults: {
|
||||||
automatedLatestContent: {
|
automatedLatestContent: {
|
||||||
@ -220,7 +223,7 @@ define([
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
var model = new (module.AutomatedLatestContentBlockModel)();
|
model = new (module.AutomatedLatestContentBlockModel)();
|
||||||
|
|
||||||
expect(model.get('amount')).to.equal('17');
|
expect(model.get('amount')).to.equal('17');
|
||||||
expect(model.get('contentType')).to.equal('mailpoet_page');
|
expect(model.get('contentType')).to.equal('mailpoet_page');
|
||||||
@ -252,8 +255,9 @@ define([
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('accepts displayable posts', function() {
|
it('accepts displayable posts', function() {
|
||||||
|
var model;
|
||||||
EditorApplication.getBlockTypeModel = sinon.stub().returns(ContainerBlock.ContainerBlockModel);
|
EditorApplication.getBlockTypeModel = sinon.stub().returns(ContainerBlock.ContainerBlockModel);
|
||||||
var model = new (module.AutomatedLatestContentBlockModel)();
|
model = new (module.AutomatedLatestContentBlockModel)();
|
||||||
|
|
||||||
model.updatePosts([{
|
model.updatePosts([{
|
||||||
type: 'someCustomType'
|
type: 'someCustomType'
|
||||||
@ -293,8 +297,8 @@ define([
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('replaceAllButtonStyles', function () {
|
describe('replaceAllButtonStyles', function () {
|
||||||
var model;
|
|
||||||
var onStub;
|
var onStub;
|
||||||
|
var view;
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
onStub = sinon.stub();
|
onStub = sinon.stub();
|
||||||
@ -302,8 +306,7 @@ define([
|
|||||||
global.stubConfig(EditorApplication);
|
global.stubConfig(EditorApplication);
|
||||||
EditorApplication.getBlockTypeModel = sinon.stub().returns(Backbone.Model);
|
EditorApplication.getBlockTypeModel = sinon.stub().returns(Backbone.Model);
|
||||||
EditorApplication.getBlockTypeView = sinon.stub().returns(Backbone.View);
|
EditorApplication.getBlockTypeView = sinon.stub().returns(Backbone.View);
|
||||||
model = {set: sinon.stub()};
|
view = new (AutomatedLatestContentBlock.AutomatedLatestContentBlockView)({model: {set: sinon.stub()}});
|
||||||
new (AutomatedLatestContentBlock.AutomatedLatestContentBlockView)({model: model});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('listens to the event', function () {
|
it('listens to the event', function () {
|
||||||
@ -321,8 +324,8 @@ define([
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
callback(data);
|
callback(data);
|
||||||
expect(model.set).to.have.been.callCount(1);
|
expect(view.model.set).to.have.been.callCount(1);
|
||||||
expect(model.set).to.have.been.calledWithMatch(sinon.match.has('readMoreButton', data));
|
expect(view.model.set).to.have.been.calledWithMatch(sinon.match.has('readMoreButton', data));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -108,6 +108,7 @@ define([
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('uses defaults from config when they are set', function () {
|
it('uses defaults from config when they are set', function () {
|
||||||
|
var model;
|
||||||
global.stubConfig(EditorApplication, {
|
global.stubConfig(EditorApplication, {
|
||||||
blockDefaults: {
|
blockDefaults: {
|
||||||
button: {
|
button: {
|
||||||
@ -131,7 +132,7 @@ define([
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
var model = new (ButtonBlock.ButtonBlockModel)();
|
model = new (ButtonBlock.ButtonBlockModel)();
|
||||||
|
|
||||||
expect(model.get('text')).to.equal('Some new text');
|
expect(model.get('text')).to.equal('Some new text');
|
||||||
expect(model.get('url')).to.equal('http://somenewurl.com');
|
expect(model.get('url')).to.equal('http://somenewurl.com');
|
||||||
|
@ -13,8 +13,9 @@ define([
|
|||||||
|
|
||||||
describe('model', function () {
|
describe('model', function () {
|
||||||
describe('by default', function () {
|
describe('by default', function () {
|
||||||
|
var model;
|
||||||
global.stubConfig(EditorApplication);
|
global.stubConfig(EditorApplication);
|
||||||
var model = new ModelClass();
|
model = new ModelClass();
|
||||||
|
|
||||||
it('has container type', function () {
|
it('has container type', function () {
|
||||||
expect(model.get('type')).to.equal('container');
|
expect(model.get('type')).to.equal('container');
|
||||||
@ -33,6 +34,7 @@ define([
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('uses defaults from config when they are set', function () {
|
it('uses defaults from config when they are set', function () {
|
||||||
|
var model;
|
||||||
global.stubConfig(EditorApplication, {
|
global.stubConfig(EditorApplication, {
|
||||||
blockDefaults: {
|
blockDefaults: {
|
||||||
container: {
|
container: {
|
||||||
@ -44,7 +46,7 @@ define([
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
var model = new (ContainerBlock.ContainerBlockModel)();
|
model = new (ContainerBlock.ContainerBlockModel)();
|
||||||
|
|
||||||
expect(model.get('styles.block.backgroundColor')).to.equal('#123456');
|
expect(model.get('styles.block.backgroundColor')).to.equal('#123456');
|
||||||
});
|
});
|
||||||
@ -107,10 +109,12 @@ define([
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('block view', function () {
|
describe('block view', function () {
|
||||||
|
var model;
|
||||||
|
var view;
|
||||||
global.stubChannel(EditorApplication);
|
global.stubChannel(EditorApplication);
|
||||||
global.stubAvailableStyles(EditorApplication);
|
global.stubAvailableStyles(EditorApplication);
|
||||||
var model = new (ContainerBlock.ContainerBlockModel)();
|
model = new (ContainerBlock.ContainerBlockModel)();
|
||||||
var view = new (ContainerBlock.ContainerBlockView)({model: model});
|
view = new (ContainerBlock.ContainerBlockView)({model: model});
|
||||||
|
|
||||||
it('renders', function () {
|
it('renders', function () {
|
||||||
expect(view.render).to.not.throw();
|
expect(view.render).to.not.throw();
|
||||||
@ -187,10 +191,12 @@ define([
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('settings view', function () {
|
describe('settings view', function () {
|
||||||
|
var model;
|
||||||
|
var view;
|
||||||
global.stubChannel(EditorApplication);
|
global.stubChannel(EditorApplication);
|
||||||
global.stubAvailableStyles(EditorApplication);
|
global.stubAvailableStyles(EditorApplication);
|
||||||
var model = new (ContainerBlock.ContainerBlockModel)();
|
model = new (ContainerBlock.ContainerBlockModel)();
|
||||||
var view = new (ContainerBlock.ContainerBlockSettingsView)({model: model});
|
view = new (ContainerBlock.ContainerBlockSettingsView)({model: model});
|
||||||
|
|
||||||
it('renders', function () {
|
it('renders', function () {
|
||||||
expect(view.render).to.not.throw();
|
expect(view.render).to.not.throw();
|
||||||
|
@ -70,6 +70,7 @@ define([
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('uses defaults from config when they are set', function () {
|
it('uses defaults from config when they are set', function () {
|
||||||
|
var model;
|
||||||
global.stubConfig(EditorApplication, {
|
global.stubConfig(EditorApplication, {
|
||||||
blockDefaults: {
|
blockDefaults: {
|
||||||
divider: {
|
divider: {
|
||||||
@ -85,7 +86,7 @@ define([
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
var model = new (DividerBlock.DividerBlockModel)();
|
model = new (DividerBlock.DividerBlockModel)();
|
||||||
|
|
||||||
expect(model.get('styles.block.backgroundColor')).to.equal('#123456');
|
expect(model.get('styles.block.backgroundColor')).to.equal('#123456');
|
||||||
expect(model.get('styles.block.padding')).to.equal('37px');
|
expect(model.get('styles.block.padding')).to.equal('37px');
|
||||||
@ -137,13 +138,15 @@ define([
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('settings view', function () {
|
describe('settings view', function () {
|
||||||
|
var model;
|
||||||
|
var view;
|
||||||
global.stubChannel(EditorApplication);
|
global.stubChannel(EditorApplication);
|
||||||
global.stubConfig(EditorApplication);
|
global.stubConfig(EditorApplication);
|
||||||
global.stubAvailableStyles(EditorApplication, {
|
global.stubAvailableStyles(EditorApplication, {
|
||||||
dividers: ['solid', 'inset']
|
dividers: ['solid', 'inset']
|
||||||
});
|
});
|
||||||
var model = new (DividerBlock.DividerBlockModel)();
|
model = new (DividerBlock.DividerBlockModel)();
|
||||||
var view = new (DividerBlock.DividerBlockSettingsView)({model: model});
|
view = new (DividerBlock.DividerBlockSettingsView)({model: model});
|
||||||
|
|
||||||
it('renders', function () {
|
it('renders', function () {
|
||||||
expect(view.render).to.not.throw();
|
expect(view.render).to.not.throw();
|
||||||
|
@ -79,6 +79,7 @@ define([
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('uses defaults from config when they are set', function () {
|
it('uses defaults from config when they are set', function () {
|
||||||
|
var model;
|
||||||
global.stubConfig(EditorApplication, {
|
global.stubConfig(EditorApplication, {
|
||||||
blockDefaults: {
|
blockDefaults: {
|
||||||
footer: {
|
footer: {
|
||||||
@ -101,7 +102,7 @@ define([
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
var model = new (FooterBlock.FooterBlockModel)();
|
model = new (FooterBlock.FooterBlockModel)();
|
||||||
|
|
||||||
expect(model.get('text')).to.equal('some custom config text');
|
expect(model.get('text')).to.equal('some custom config text');
|
||||||
expect(model.get('styles.block.backgroundColor')).to.equal('#123456');
|
expect(model.get('styles.block.backgroundColor')).to.equal('#123456');
|
||||||
@ -116,11 +117,12 @@ define([
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('block view', function () {
|
describe('block view', function () {
|
||||||
|
var model;
|
||||||
|
var view;
|
||||||
global.stubChannel(EditorApplication);
|
global.stubChannel(EditorApplication);
|
||||||
global.stubConfig(EditorApplication);
|
global.stubConfig(EditorApplication);
|
||||||
global.stubAvailableStyles(EditorApplication);
|
global.stubAvailableStyles(EditorApplication);
|
||||||
var model = new (FooterBlock.FooterBlockModel)();
|
model = new (FooterBlock.FooterBlockModel)();
|
||||||
var view;
|
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
global.stubChannel(EditorApplication);
|
global.stubChannel(EditorApplication);
|
||||||
@ -134,13 +136,15 @@ define([
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('settings view', function () {
|
describe('settings view', function () {
|
||||||
|
var model;
|
||||||
|
var view;
|
||||||
global.stubChannel(EditorApplication);
|
global.stubChannel(EditorApplication);
|
||||||
global.stubAvailableStyles(EditorApplication, {
|
global.stubAvailableStyles(EditorApplication, {
|
||||||
fonts: ['Arial', 'Tahoma'],
|
fonts: ['Arial', 'Tahoma'],
|
||||||
textSizes: ['16px', '20px']
|
textSizes: ['16px', '20px']
|
||||||
});
|
});
|
||||||
var model = new (FooterBlock.FooterBlockModel)();
|
model = new (FooterBlock.FooterBlockModel)();
|
||||||
var view = new (FooterBlock.FooterBlockSettingsView)({model: model});
|
view = new (FooterBlock.FooterBlockSettingsView)({model: model});
|
||||||
|
|
||||||
it('renders', function () {
|
it('renders', function () {
|
||||||
expect(view.render).to.not.throw();
|
expect(view.render).to.not.throw();
|
||||||
|
@ -79,6 +79,7 @@ define([
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('uses defaults from config when they are set', function () {
|
it('uses defaults from config when they are set', function () {
|
||||||
|
var model;
|
||||||
global.stubConfig(EditorApplication, {
|
global.stubConfig(EditorApplication, {
|
||||||
blockDefaults: {
|
blockDefaults: {
|
||||||
header: {
|
header: {
|
||||||
@ -101,7 +102,7 @@ define([
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
var model = new (HeaderBlock.HeaderBlockModel)();
|
model = new (HeaderBlock.HeaderBlockModel)();
|
||||||
|
|
||||||
expect(model.get('text')).to.equal('some custom config text');
|
expect(model.get('text')).to.equal('some custom config text');
|
||||||
expect(model.get('styles.block.backgroundColor')).to.equal('#123456');
|
expect(model.get('styles.block.backgroundColor')).to.equal('#123456');
|
||||||
@ -115,11 +116,12 @@ define([
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('block view', function () {
|
describe('block view', function () {
|
||||||
|
var model;
|
||||||
|
var view;
|
||||||
global.stubChannel(EditorApplication);
|
global.stubChannel(EditorApplication);
|
||||||
global.stubConfig(EditorApplication);
|
global.stubConfig(EditorApplication);
|
||||||
global.stubAvailableStyles(EditorApplication);
|
global.stubAvailableStyles(EditorApplication);
|
||||||
var model = new (HeaderBlock.HeaderBlockModel)();
|
model = new (HeaderBlock.HeaderBlockModel)();
|
||||||
var view;
|
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
global.stubChannel(EditorApplication);
|
global.stubChannel(EditorApplication);
|
||||||
@ -133,14 +135,16 @@ define([
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('settings view', function () {
|
describe('settings view', function () {
|
||||||
|
var model;
|
||||||
|
var view;
|
||||||
global.stubChannel(EditorApplication);
|
global.stubChannel(EditorApplication);
|
||||||
global.stubConfig(EditorApplication);
|
global.stubConfig(EditorApplication);
|
||||||
global.stubAvailableStyles(EditorApplication, {
|
global.stubAvailableStyles(EditorApplication, {
|
||||||
fonts: ['Arial', 'Tahoma'],
|
fonts: ['Arial', 'Tahoma'],
|
||||||
textSizes: ['16px', '20px']
|
textSizes: ['16px', '20px']
|
||||||
});
|
});
|
||||||
var model = new (HeaderBlock.HeaderBlockModel)();
|
model = new (HeaderBlock.HeaderBlockModel)();
|
||||||
var view = new (HeaderBlock.HeaderBlockSettingsView)({model: model});
|
view = new (HeaderBlock.HeaderBlockSettingsView)({model: model});
|
||||||
|
|
||||||
it('renders', function () {
|
it('renders', function () {
|
||||||
expect(view.render).to.not.throw();
|
expect(view.render).to.not.throw();
|
||||||
|
@ -74,6 +74,7 @@ define([
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('uses defaults from config when they are set', function () {
|
it('uses defaults from config when they are set', function () {
|
||||||
|
var model;
|
||||||
global.stubConfig(EditorApplication, {
|
global.stubConfig(EditorApplication, {
|
||||||
blockDefaults: {
|
blockDefaults: {
|
||||||
image: {
|
image: {
|
||||||
@ -91,7 +92,7 @@ define([
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
var model = new (ImageBlock.ImageBlockModel)();
|
model = new (ImageBlock.ImageBlockModel)();
|
||||||
|
|
||||||
expect(model.get('link')).to.equal('http://example.org/customConfigPage');
|
expect(model.get('link')).to.equal('http://example.org/customConfigPage');
|
||||||
expect(model.get('src')).to.equal('http://example.org/someCustomConfigImage.png');
|
expect(model.get('src')).to.equal('http://example.org/someCustomConfigImage.png');
|
||||||
@ -104,11 +105,12 @@ define([
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('block view', function () {
|
describe('block view', function () {
|
||||||
|
var model;
|
||||||
|
var view;
|
||||||
global.stubChannel(EditorApplication);
|
global.stubChannel(EditorApplication);
|
||||||
global.stubConfig(EditorApplication);
|
global.stubConfig(EditorApplication);
|
||||||
global.stubAvailableStyles(EditorApplication);
|
global.stubAvailableStyles(EditorApplication);
|
||||||
var model = new (ImageBlock.ImageBlockModel)();
|
model = new (ImageBlock.ImageBlockModel)();
|
||||||
var view;
|
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
view = new (ImageBlock.ImageBlockView)({model: model});
|
view = new (ImageBlock.ImageBlockView)({model: model});
|
||||||
|
@ -132,6 +132,7 @@ define([
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('uses defaults from config when they are set', function () {
|
it('uses defaults from config when they are set', function () {
|
||||||
|
var model;
|
||||||
global.stubConfig(EditorApplication, {
|
global.stubConfig(EditorApplication, {
|
||||||
blockDefaults: {
|
blockDefaults: {
|
||||||
posts: {
|
posts: {
|
||||||
@ -179,7 +180,7 @@ define([
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
var model = new (PostsBlock.PostsBlockModel)();
|
model = new (PostsBlock.PostsBlockModel)();
|
||||||
|
|
||||||
expect(model.get('amount')).to.equal('17');
|
expect(model.get('amount')).to.equal('17');
|
||||||
expect(model.get('contentType')).to.equal('mailpoet_page');
|
expect(model.get('contentType')).to.equal('mailpoet_page');
|
||||||
|
@ -29,6 +29,7 @@ define([
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('uses defaults from config when they are set', function () {
|
it('uses defaults from config when they are set', function () {
|
||||||
|
var model;
|
||||||
global.stubConfig(EditorApplication, {
|
global.stubConfig(EditorApplication, {
|
||||||
blockDefaults: {
|
blockDefaults: {
|
||||||
social: {
|
social: {
|
||||||
@ -36,7 +37,7 @@ define([
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
var model = new (SocialBlock.SocialBlockModel)();
|
model = new (SocialBlock.SocialBlockModel)();
|
||||||
|
|
||||||
expect(model.get('iconSet')).to.equal('customConfigIconSet');
|
expect(model.get('iconSet')).to.equal('customConfigIconSet');
|
||||||
});
|
});
|
||||||
|
@ -55,6 +55,7 @@ define([
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('uses defaults from config when they are set', function () {
|
it('uses defaults from config when they are set', function () {
|
||||||
|
var model;
|
||||||
global.stubConfig(EditorApplication, {
|
global.stubConfig(EditorApplication, {
|
||||||
blockDefaults: {
|
blockDefaults: {
|
||||||
spacer: {
|
spacer: {
|
||||||
@ -67,7 +68,7 @@ define([
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
var model = new (SpacerBlock.SpacerBlockModel)();
|
model = new (SpacerBlock.SpacerBlockModel)();
|
||||||
|
|
||||||
expect(model.get('styles.block.backgroundColor')).to.equal('#567890');
|
expect(model.get('styles.block.backgroundColor')).to.equal('#567890');
|
||||||
expect(model.get('styles.block.height')).to.equal('19px');
|
expect(model.get('styles.block.height')).to.equal('19px');
|
||||||
@ -119,11 +120,12 @@ define([
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('settings view', function () {
|
describe('settings view', function () {
|
||||||
|
var model;
|
||||||
|
var view;
|
||||||
global.stubChannel(EditorApplication);
|
global.stubChannel(EditorApplication);
|
||||||
global.stubConfig(EditorApplication);
|
global.stubConfig(EditorApplication);
|
||||||
|
|
||||||
var model = new (SpacerBlock.SpacerBlockModel)();
|
model = new (SpacerBlock.SpacerBlockModel)();
|
||||||
var view;
|
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
global.stubChannel(EditorApplication);
|
global.stubChannel(EditorApplication);
|
||||||
|
@ -23,6 +23,7 @@ define([
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('uses defaults from config when they are set', function () {
|
it('uses defaults from config when they are set', function () {
|
||||||
|
var model;
|
||||||
global.stubConfig(EditorApplication, {
|
global.stubConfig(EditorApplication, {
|
||||||
blockDefaults: {
|
blockDefaults: {
|
||||||
text: {
|
text: {
|
||||||
@ -30,16 +31,18 @@ define([
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
var model = new (TextBlock.TextBlockModel)();
|
model = new (TextBlock.TextBlockModel)();
|
||||||
|
|
||||||
expect(model.get('text')).to.equal('some custom config text');
|
expect(model.get('text')).to.equal('some custom config text');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('block view', function () {
|
describe('block view', function () {
|
||||||
|
var model;
|
||||||
|
var view;
|
||||||
global.stubConfig(EditorApplication);
|
global.stubConfig(EditorApplication);
|
||||||
var model = new (TextBlock.TextBlockModel)();
|
model = new (TextBlock.TextBlockModel)();
|
||||||
var view = new (TextBlock.TextBlockView)({model: model});
|
view = new (TextBlock.TextBlockView)({model: model});
|
||||||
|
|
||||||
it('renders', function () {
|
it('renders', function () {
|
||||||
expect(view.render).to.not.throw();
|
expect(view.render).to.not.throw();
|
||||||
|
@ -7,10 +7,11 @@ define([
|
|||||||
|
|
||||||
describe('Config', function () {
|
describe('Config', function () {
|
||||||
it('loads and stores configuration', function() {
|
it('loads and stores configuration', function() {
|
||||||
|
var model;
|
||||||
ConfigComponent.setConfig({
|
ConfigComponent.setConfig({
|
||||||
testConfig: 'testValue'
|
testConfig: 'testValue'
|
||||||
});
|
});
|
||||||
var model = ConfigComponent.getConfig();
|
model = ConfigComponent.getConfig();
|
||||||
expect(model.get('testConfig')).to.equal('testValue');
|
expect(model.get('testConfig')).to.equal('testValue');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -78,6 +78,7 @@ define([
|
|||||||
|
|
||||||
describe('transformation to json', function() {
|
describe('transformation to json', function() {
|
||||||
it('includes content, globalStyles and initial newsletter fields', function() {
|
it('includes content, globalStyles and initial newsletter fields', function() {
|
||||||
|
var json;
|
||||||
var dataField = {
|
var dataField = {
|
||||||
containerModelField: 'containerModelValue'
|
containerModelField: 'containerModelValue'
|
||||||
};
|
};
|
||||||
@ -106,7 +107,7 @@ define([
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
var json = ContentComponent.toJSON();
|
json = ContentComponent.toJSON();
|
||||||
expect(json).to.deep.equal(_.extend({
|
expect(json).to.deep.equal(_.extend({
|
||||||
body: {
|
body: {
|
||||||
content: dataField,
|
content: dataField,
|
||||||
|
@ -38,6 +38,7 @@ define([
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('triggers afterEditorSave event', function() {
|
it('triggers afterEditorSave event', function() {
|
||||||
|
var module;
|
||||||
var spy = sinon.spy();
|
var spy = sinon.spy();
|
||||||
var promise = jQuery.Deferred();
|
var promise = jQuery.Deferred();
|
||||||
global.stubChannel(EditorApplication, {
|
global.stubChannel(EditorApplication, {
|
||||||
@ -48,7 +49,7 @@ define([
|
|||||||
type: 'container'
|
type: 'container'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
var module = SaveInjector({
|
module = SaveInjector({
|
||||||
'newsletter_editor/components/communication': {
|
'newsletter_editor/components/communication': {
|
||||||
saveNewsletter: sinon.stub().returns(promise)
|
saveNewsletter: sinon.stub().returns(promise)
|
||||||
}
|
}
|
||||||
@ -74,6 +75,7 @@ define([
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('encodes newsletter body in JSON format', function() {
|
it('encodes newsletter body in JSON format', function() {
|
||||||
|
var module;
|
||||||
var body = {type: 'testType'};
|
var body = {type: 'testType'};
|
||||||
var mock = sinon.mock()
|
var mock = sinon.mock()
|
||||||
.once()
|
.once()
|
||||||
@ -86,7 +88,7 @@ define([
|
|||||||
EditorApplication.toJSON = sinon.stub().returns({
|
EditorApplication.toJSON = sinon.stub().returns({
|
||||||
body: body
|
body: body
|
||||||
});
|
});
|
||||||
var module = SaveInjector({
|
module = SaveInjector({
|
||||||
'newsletter_editor/components/communication': {
|
'newsletter_editor/components/communication': {
|
||||||
saveNewsletter: mock
|
saveNewsletter: mock
|
||||||
}
|
}
|
||||||
@ -136,13 +138,15 @@ define([
|
|||||||
it('triggers template saving when clicked on "save as template" button', function() {
|
it('triggers template saving when clicked on "save as template" button', function() {
|
||||||
var mock = sinon.mock({ post: function() {} }).expects('post').once().returns(jQuery.Deferred());
|
var mock = sinon.mock({ post: function() {} }).expects('post').once().returns(jQuery.Deferred());
|
||||||
var html2canvasMock = jQuery.Deferred();
|
var html2canvasMock = jQuery.Deferred();
|
||||||
|
var module;
|
||||||
|
var view;
|
||||||
|
|
||||||
html2canvasMock.resolve({
|
html2canvasMock.resolve({
|
||||||
toDataURL: function() { return 'somedataurl'; }
|
toDataURL: function() { return 'somedataurl'; }
|
||||||
});
|
});
|
||||||
|
|
||||||
EditorApplication.getBody = sinon.stub();
|
EditorApplication.getBody = sinon.stub();
|
||||||
var module = SaveInjector({
|
module = SaveInjector({
|
||||||
mailpoet: {
|
mailpoet: {
|
||||||
Ajax: {
|
Ajax: {
|
||||||
post: mock
|
post: mock
|
||||||
@ -163,7 +167,7 @@ define([
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
var view = new (module.SaveView)();
|
view = new (module.SaveView)();
|
||||||
view.render();
|
view.render();
|
||||||
|
|
||||||
view.$('.mailpoet_save_as_template_name').val('A sample template');
|
view.$('.mailpoet_save_as_template_name').val('A sample template');
|
||||||
@ -175,6 +179,7 @@ define([
|
|||||||
|
|
||||||
it('saves newsletter when clicked on "next" button', function() {
|
it('saves newsletter when clicked on "next" button', function() {
|
||||||
var spy = sinon.spy();
|
var spy = sinon.spy();
|
||||||
|
var view;
|
||||||
var module = SaveInjector({
|
var module = SaveInjector({
|
||||||
'newsletter_editor/components/communication': {
|
'newsletter_editor/components/communication': {
|
||||||
saveNewsletter: function() {
|
saveNewsletter: function() {
|
||||||
@ -185,7 +190,7 @@ define([
|
|||||||
global.stubChannel(EditorApplication, {
|
global.stubChannel(EditorApplication, {
|
||||||
trigger: spy
|
trigger: spy
|
||||||
});
|
});
|
||||||
var view = new (module.SaveView)();
|
view = new (module.SaveView)();
|
||||||
view.render();
|
view.render();
|
||||||
|
|
||||||
view.$('.mailpoet_save_next').click();
|
view.$('.mailpoet_save_next').click();
|
||||||
|
@ -9,10 +9,11 @@ define([
|
|||||||
|
|
||||||
describe('Styles', function () {
|
describe('Styles', function () {
|
||||||
it('loads and stores globally available styles', function() {
|
it('loads and stores globally available styles', function() {
|
||||||
|
var model;
|
||||||
StylesComponent.setGlobalStyles({
|
StylesComponent.setGlobalStyles({
|
||||||
testStyle: 'testValue'
|
testStyle: 'testValue'
|
||||||
});
|
});
|
||||||
var model = StylesComponent.getGlobalStyles();
|
model = StylesComponent.getGlobalStyles();
|
||||||
expect(model.get('testStyle')).to.equal('testValue');
|
expect(model.get('testStyle')).to.equal('testValue');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user