Tests one-var
This commit is contained in:
@ -9,7 +9,6 @@
|
||||
},
|
||||
"rules": {
|
||||
"import/no-amd": 0,
|
||||
"one-var": 0,
|
||||
"no-whitespace-before-property": 0,
|
||||
"global-require": 0,
|
||||
"keyword-spacing": 0,
|
||||
|
@ -1,8 +1,8 @@
|
||||
var fs = require('fs');
|
||||
module.exports = {
|
||||
loadFileToContainer: function (path, window, containerTagName, opts) {
|
||||
var contents = fs.readFileSync(path),
|
||||
container = window.document.createElement(containerTagName);
|
||||
var contents = fs.readFileSync(path);
|
||||
var container = window.document.createElement(containerTagName);
|
||||
var options = opts || {};
|
||||
container.innerHTML = contents;
|
||||
|
||||
|
@ -45,17 +45,17 @@ define([
|
||||
});
|
||||
|
||||
it('refreshes posts for given blocks', function() {
|
||||
var block1 = new Backbone.SuperModel(),
|
||||
block2 = new Backbone.SuperModel(),
|
||||
postsSet1 = [
|
||||
var block1 = new Backbone.SuperModel();
|
||||
var block2 = new Backbone.SuperModel();
|
||||
var postsSet1 = [
|
||||
{ type: 'customTypeOne' }
|
||||
],
|
||||
postsSet2 = [
|
||||
];
|
||||
var postsSet2 = [
|
||||
{ type: 'customTypeTwo' },
|
||||
{ type: 'customTypeTwo' }
|
||||
],
|
||||
mock1 = sinon.mock(block1),
|
||||
mock2 = sinon.mock(block2);
|
||||
];
|
||||
var mock1 = sinon.mock(block1);
|
||||
var mock2 = sinon.mock(block2);
|
||||
|
||||
mock1.expects('trigger').once().withArgs('refreshPosts', postsSet1);
|
||||
mock2.expects('trigger').once().withArgs('refreshPosts', postsSet2);
|
||||
@ -69,7 +69,8 @@ define([
|
||||
|
||||
describe('Automated latest content', function () {
|
||||
describe('model', function () {
|
||||
var model, module;
|
||||
var model;
|
||||
var module;
|
||||
|
||||
before(function() {
|
||||
module = AutomatedLatestContentBlock;
|
||||
@ -264,7 +265,9 @@ define([
|
||||
});
|
||||
|
||||
describe('block view', function () {
|
||||
var model, view, module;
|
||||
var model;
|
||||
var view;
|
||||
var module;
|
||||
|
||||
before(function() {
|
||||
module = AutomatedLatestContentBlock;
|
||||
@ -290,7 +293,10 @@ define([
|
||||
});
|
||||
|
||||
describe('replaceAllButtonStyles', function () {
|
||||
var model, view, module, onStub;
|
||||
var model;
|
||||
var view;
|
||||
var module;
|
||||
var onStub;
|
||||
|
||||
before(function() {
|
||||
module = AutomatedLatestContentBlock;
|
||||
@ -327,7 +333,9 @@ define([
|
||||
});
|
||||
|
||||
describe('block settings view', function () {
|
||||
var model, view, module;
|
||||
var model;
|
||||
var view;
|
||||
var module;
|
||||
|
||||
before(function() {
|
||||
module = AutomatedLatestContentInjector({
|
||||
@ -496,7 +504,8 @@ define([
|
||||
});
|
||||
|
||||
describe('when "title only" display type is selected', function() {
|
||||
var model, view;
|
||||
var model;
|
||||
var view;
|
||||
beforeEach(function() {
|
||||
model = new (module.AutomatedLatestContentBlockModel)();
|
||||
view = new (module.AutomatedLatestContentBlockSettingsView)({model: model});
|
||||
@ -509,7 +518,8 @@ define([
|
||||
});
|
||||
|
||||
describe('when "title as list" is selected', function() {
|
||||
var model, view;
|
||||
var model;
|
||||
var view;
|
||||
beforeEach(function() {
|
||||
model = new (module.AutomatedLatestContentBlockModel)();
|
||||
view = new (module.AutomatedLatestContentBlockSettingsView)({model: model});
|
||||
|
@ -173,7 +173,8 @@ define([
|
||||
});
|
||||
|
||||
describe('once rendered', function () {
|
||||
var model, view;
|
||||
var model;
|
||||
var view;
|
||||
|
||||
before(function () {
|
||||
global.stubChannel(EditorApplication);
|
||||
@ -264,8 +265,9 @@ define([
|
||||
});
|
||||
|
||||
describe('replaceAllButtonStyles', function () {
|
||||
var model, view, onStub;
|
||||
|
||||
var model;
|
||||
var view;
|
||||
var onStub;
|
||||
|
||||
beforeEach(function () {
|
||||
onStub = sinon.stub();
|
||||
@ -317,7 +319,8 @@ define([
|
||||
});
|
||||
|
||||
describe('once rendered', function () {
|
||||
var model, view;
|
||||
var model;
|
||||
var view;
|
||||
before(function() {
|
||||
global.stubChannel(EditorApplication);
|
||||
global.stubConfig(EditorApplication);
|
||||
|
@ -54,8 +54,8 @@ define([
|
||||
var testModel = {
|
||||
type: 'sampleType',
|
||||
someField: 'Some Content'
|
||||
},
|
||||
model;
|
||||
};
|
||||
var model;
|
||||
|
||||
it('will recursively create children', function () {
|
||||
EditorApplication.getBlockTypeModel = sinon.stub().returns(Backbone.Model);
|
||||
@ -109,8 +109,8 @@ define([
|
||||
describe('block view', function () {
|
||||
global.stubChannel(EditorApplication);
|
||||
global.stubAvailableStyles(EditorApplication);
|
||||
var model = new (ContainerBlock.ContainerBlockModel)(),
|
||||
view = new (ContainerBlock.ContainerBlockView)({model: model});
|
||||
var model = new (ContainerBlock.ContainerBlockModel)();
|
||||
var view = new (ContainerBlock.ContainerBlockView)({model: model});
|
||||
|
||||
it('renders', function () {
|
||||
expect(view.render).to.not.throw();
|
||||
@ -119,8 +119,8 @@ define([
|
||||
describe('once rendered', function () {
|
||||
|
||||
describe('on root level', function () {
|
||||
var model = new (ContainerBlock.ContainerBlockModel)(),
|
||||
view;
|
||||
var model = new (ContainerBlock.ContainerBlockModel)();
|
||||
var view;
|
||||
|
||||
beforeEach(function () {
|
||||
global.stubChannel(EditorApplication);
|
||||
@ -151,8 +151,8 @@ define([
|
||||
});
|
||||
|
||||
describe.skip('on non-root levels', function () {
|
||||
var model = new (ContainerBlock.ContainerBlockModel)(),
|
||||
view;
|
||||
var model = new (ContainerBlock.ContainerBlockModel)();
|
||||
var view;
|
||||
|
||||
beforeEach(function () {
|
||||
global.stubChannel(EditorApplication);
|
||||
@ -189,15 +189,16 @@ define([
|
||||
describe('settings view', function () {
|
||||
global.stubChannel(EditorApplication);
|
||||
global.stubAvailableStyles(EditorApplication);
|
||||
var model = new (ContainerBlock.ContainerBlockModel)(),
|
||||
view = new (ContainerBlock.ContainerBlockSettingsView)({model: model});
|
||||
var model = new (ContainerBlock.ContainerBlockModel)();
|
||||
var view = new (ContainerBlock.ContainerBlockSettingsView)({model: model});
|
||||
|
||||
it('renders', function () {
|
||||
expect(view.render).to.not.throw();
|
||||
});
|
||||
|
||||
describe('once rendered', function () {
|
||||
var model, view;
|
||||
var model;
|
||||
var view;
|
||||
beforeEach(function() {
|
||||
global.stubChannel(EditorApplication);
|
||||
global.stubAvailableStyles(EditorApplication);
|
||||
|
@ -142,8 +142,8 @@ define([
|
||||
global.stubAvailableStyles(EditorApplication, {
|
||||
dividers: ['solid', 'inset']
|
||||
});
|
||||
var model = new (DividerBlock.DividerBlockModel)(),
|
||||
view = new (DividerBlock.DividerBlockSettingsView)({model: model});
|
||||
var model = new (DividerBlock.DividerBlockModel)();
|
||||
var view = new (DividerBlock.DividerBlockSettingsView)({model: model});
|
||||
|
||||
it('renders', function () {
|
||||
expect(view.render).to.not.throw();
|
||||
@ -151,7 +151,8 @@ define([
|
||||
});
|
||||
|
||||
describe('once rendered', function () {
|
||||
var model, view;
|
||||
var model;
|
||||
var view;
|
||||
|
||||
before(function() {
|
||||
global.stubChannel(EditorApplication);
|
||||
|
@ -119,8 +119,8 @@ define([
|
||||
global.stubChannel(EditorApplication);
|
||||
global.stubConfig(EditorApplication);
|
||||
global.stubAvailableStyles(EditorApplication);
|
||||
var model = new (FooterBlock.FooterBlockModel)(),
|
||||
view;
|
||||
var model = new (FooterBlock.FooterBlockModel)();
|
||||
var view;
|
||||
|
||||
beforeEach(function () {
|
||||
global.stubChannel(EditorApplication);
|
||||
@ -139,8 +139,8 @@ define([
|
||||
fonts: ['Arial', 'Tahoma'],
|
||||
textSizes: ['16px', '20px']
|
||||
});
|
||||
var model = new (FooterBlock.FooterBlockModel)(),
|
||||
view = new (FooterBlock.FooterBlockSettingsView)({model: model});
|
||||
var model = new (FooterBlock.FooterBlockModel)();
|
||||
var view = new (FooterBlock.FooterBlockSettingsView)({model: model});
|
||||
|
||||
it('renders', function () {
|
||||
expect(view.render).to.not.throw();
|
||||
@ -148,7 +148,8 @@ define([
|
||||
});
|
||||
|
||||
describe('once rendered', function () {
|
||||
var model, view;
|
||||
var model;
|
||||
var view;
|
||||
|
||||
beforeEach(function() {
|
||||
global.stubChannel(EditorApplication);
|
||||
|
@ -118,8 +118,8 @@ define([
|
||||
global.stubChannel(EditorApplication);
|
||||
global.stubConfig(EditorApplication);
|
||||
global.stubAvailableStyles(EditorApplication);
|
||||
var model = new (HeaderBlock.HeaderBlockModel)(),
|
||||
view;
|
||||
var model = new (HeaderBlock.HeaderBlockModel)();
|
||||
var view;
|
||||
|
||||
beforeEach(function () {
|
||||
global.stubChannel(EditorApplication);
|
||||
@ -139,8 +139,8 @@ define([
|
||||
fonts: ['Arial', 'Tahoma'],
|
||||
textSizes: ['16px', '20px']
|
||||
});
|
||||
var model = new (HeaderBlock.HeaderBlockModel)(),
|
||||
view = new (HeaderBlock.HeaderBlockSettingsView)({model: model});
|
||||
var model = new (HeaderBlock.HeaderBlockModel)();
|
||||
var view = new (HeaderBlock.HeaderBlockSettingsView)({model: model});
|
||||
|
||||
it('renders', function () {
|
||||
expect(view.render).to.not.throw();
|
||||
@ -148,7 +148,8 @@ define([
|
||||
});
|
||||
|
||||
describe('once rendered', function () {
|
||||
var model, view;
|
||||
var model;
|
||||
var view;
|
||||
|
||||
beforeEach(function() {
|
||||
global.stubChannel(EditorApplication);
|
||||
|
@ -107,8 +107,8 @@ define([
|
||||
global.stubChannel(EditorApplication);
|
||||
global.stubConfig(EditorApplication);
|
||||
global.stubAvailableStyles(EditorApplication);
|
||||
var model = new (ImageBlock.ImageBlockModel)(),
|
||||
view;
|
||||
var model = new (ImageBlock.ImageBlockModel)();
|
||||
var view;
|
||||
|
||||
beforeEach(function () {
|
||||
view = new (ImageBlock.ImageBlockView)({model: model});
|
||||
@ -158,7 +158,8 @@ define([
|
||||
});
|
||||
|
||||
describe('block settings view', function () {
|
||||
var model, view;
|
||||
var model;
|
||||
var view;
|
||||
var newWidth = 123;
|
||||
var newHeight = 456;
|
||||
var newLink = 'http://example.org/someNewLink';
|
||||
|
@ -261,7 +261,8 @@ define([
|
||||
});
|
||||
|
||||
describe('block view', function () {
|
||||
var model, view;
|
||||
var model;
|
||||
var view;
|
||||
|
||||
beforeEach(function () {
|
||||
global.stubChannel(EditorApplication);
|
||||
@ -285,7 +286,8 @@ define([
|
||||
});
|
||||
|
||||
describe('block settings view', function () {
|
||||
var model, view;
|
||||
var model;
|
||||
var view;
|
||||
|
||||
before(function () {
|
||||
CommunicationComponent.getPostTypes = function() {
|
||||
@ -421,7 +423,8 @@ define([
|
||||
});
|
||||
|
||||
describe('when "title only" display type is selected', function() {
|
||||
var model, view;
|
||||
var model;
|
||||
var view;
|
||||
beforeEach(function() {
|
||||
model = new (PostsBlock.PostsBlockModel)();
|
||||
model.request = sinon.stub().returns({$el: {}});
|
||||
|
@ -130,7 +130,8 @@ define([
|
||||
});
|
||||
|
||||
describe('once rendered', function () {
|
||||
var model, view;
|
||||
var model;
|
||||
var view;
|
||||
|
||||
before(function () {
|
||||
global.stubChannel(EditorApplication);
|
||||
@ -215,7 +216,8 @@ define([
|
||||
});
|
||||
|
||||
describe('once rendered', function () {
|
||||
var model, view;
|
||||
var model;
|
||||
var view;
|
||||
beforeEach(function () {
|
||||
global.stubChannel(EditorApplication);
|
||||
global.stubAvailableStyles(EditorApplication, {
|
||||
|
@ -122,8 +122,8 @@ define([
|
||||
global.stubChannel(EditorApplication);
|
||||
global.stubConfig(EditorApplication);
|
||||
|
||||
var model = new (SpacerBlock.SpacerBlockModel)(),
|
||||
view;
|
||||
var model = new (SpacerBlock.SpacerBlockModel)();
|
||||
var view;
|
||||
|
||||
beforeEach(function () {
|
||||
global.stubChannel(EditorApplication);
|
||||
@ -135,7 +135,8 @@ define([
|
||||
});
|
||||
|
||||
describe('once rendered', function () {
|
||||
var view, model;
|
||||
var view;
|
||||
var model;
|
||||
beforeEach(function() {
|
||||
global.stubChannel(EditorApplication);
|
||||
global.stubConfig(EditorApplication);
|
||||
|
@ -38,8 +38,8 @@ define([
|
||||
|
||||
describe('block view', function () {
|
||||
global.stubConfig(EditorApplication);
|
||||
var model = new (TextBlock.TextBlockModel)(),
|
||||
view = new (TextBlock.TextBlockView)({model: model});
|
||||
var model = new (TextBlock.TextBlockModel)();
|
||||
var view = new (TextBlock.TextBlockView)({model: model});
|
||||
|
||||
it('renders', function () {
|
||||
expect(view.render).to.not.throw();
|
||||
@ -47,8 +47,8 @@ define([
|
||||
});
|
||||
|
||||
describe('once rendered', function () {
|
||||
var model = new (TextBlock.TextBlockModel)(),
|
||||
view;
|
||||
var model = new (TextBlock.TextBlockModel)();
|
||||
var view;
|
||||
|
||||
beforeEach(function () {
|
||||
global.stubConfig(EditorApplication);
|
||||
|
@ -32,9 +32,9 @@ define([
|
||||
});
|
||||
|
||||
it('caches results', function() {
|
||||
var deferred = jQuery.Deferred(),
|
||||
mock = sinon.mock({ post: function() {} }).expects('post').once().returns(deferred),
|
||||
module = CommunicationInjector({
|
||||
var deferred = jQuery.Deferred();
|
||||
var mock = sinon.mock({ post: function() {} }).expects('post').once().returns(deferred);
|
||||
var module = CommunicationInjector({
|
||||
mailpoet: {
|
||||
Ajax: {
|
||||
post: mock
|
||||
@ -54,16 +54,16 @@ define([
|
||||
|
||||
describe('getTaxonomies', function() {
|
||||
it('sends post type to endpoint', function() {
|
||||
var spy,
|
||||
post = function(params) {
|
||||
var spy;
|
||||
var post = function(params) {
|
||||
var deferred = jQuery.Deferred();
|
||||
deferred.resolve({
|
||||
category: 'val1',
|
||||
post_tag: 'val2'
|
||||
});
|
||||
return deferred;
|
||||
},
|
||||
module;
|
||||
};
|
||||
var module;
|
||||
spy = sinon.spy(post);
|
||||
module = CommunicationInjector({
|
||||
mailpoet: {
|
||||
@ -99,9 +99,9 @@ define([
|
||||
});
|
||||
|
||||
it('caches results', function() {
|
||||
var deferred = jQuery.Deferred(),
|
||||
mock = sinon.mock({ post: function() {} }).expects('post').once().returns(deferred),
|
||||
module = CommunicationInjector({
|
||||
var deferred = jQuery.Deferred();
|
||||
var mock = sinon.mock({ post: function() {} }).expects('post').once().returns(deferred);
|
||||
var module = CommunicationInjector({
|
||||
mailpoet: {
|
||||
Ajax: {
|
||||
post: mock
|
||||
@ -163,9 +163,9 @@ define([
|
||||
});
|
||||
|
||||
it('caches results', function() {
|
||||
var deferred = jQuery.Deferred(),
|
||||
mock = sinon.mock({ post: function() {} }).expects('post').once().returns(deferred),
|
||||
module = CommunicationInjector({
|
||||
var deferred = jQuery.Deferred();
|
||||
var mock = sinon.mock({ post: function() {} }).expects('post').once().returns(deferred);
|
||||
var module = CommunicationInjector({
|
||||
mailpoet: {
|
||||
Ajax: {
|
||||
post: mock
|
||||
@ -182,13 +182,13 @@ define([
|
||||
|
||||
describe('getPosts', function() {
|
||||
it('sends options to endpoint', function() {
|
||||
var spy,
|
||||
post = function(params) {
|
||||
var spy;
|
||||
var post = function(params) {
|
||||
var deferred = jQuery.Deferred();
|
||||
deferred.resolve({});
|
||||
return deferred;
|
||||
},
|
||||
module;
|
||||
};
|
||||
var module;
|
||||
spy = sinon.spy(post);
|
||||
module = CommunicationInjector({
|
||||
mailpoet: {
|
||||
@ -231,9 +231,9 @@ define([
|
||||
});
|
||||
|
||||
it('caches results', function() {
|
||||
var deferred = jQuery.Deferred(),
|
||||
mock = sinon.mock({ post: function() {} }).expects('post').once().returns(deferred),
|
||||
module = CommunicationInjector({
|
||||
var deferred = jQuery.Deferred();
|
||||
var mock = sinon.mock({ post: function() {} }).expects('post').once().returns(deferred);
|
||||
var module = CommunicationInjector({
|
||||
mailpoet: {
|
||||
Ajax: {
|
||||
post: mock
|
||||
@ -253,13 +253,13 @@ define([
|
||||
|
||||
describe('getTransformedPosts', function() {
|
||||
it('sends options to endpoint', function() {
|
||||
var spy,
|
||||
post = function(params) {
|
||||
var spy;
|
||||
var post = function(params) {
|
||||
var deferred = jQuery.Deferred();
|
||||
deferred.resolve({});
|
||||
return deferred;
|
||||
},
|
||||
module;
|
||||
};
|
||||
var module;
|
||||
spy = sinon.spy(post);
|
||||
module = CommunicationInjector({
|
||||
mailpoet: {
|
||||
@ -302,9 +302,9 @@ define([
|
||||
});
|
||||
|
||||
it('caches results', function() {
|
||||
var deferred = jQuery.Deferred(),
|
||||
mock = sinon.mock({ post: function() {} }).expects('post').once().returns(deferred),
|
||||
module = CommunicationInjector({
|
||||
var deferred = jQuery.Deferred();
|
||||
var mock = sinon.mock({ post: function() {} }).expects('post').once().returns(deferred);
|
||||
var module = CommunicationInjector({
|
||||
mailpoet: {
|
||||
Ajax: {
|
||||
post: mock
|
||||
|
@ -65,8 +65,8 @@ define([
|
||||
|
||||
describe('block types', function() {
|
||||
it('registers a block type view and model', function() {
|
||||
var blockModel = new Backbone.SuperModel(),
|
||||
blockView = new Backbone.View();
|
||||
var blockModel = new Backbone.SuperModel();
|
||||
var blockView = new Backbone.View();
|
||||
ContentComponent.registerBlockType('testType', {
|
||||
blockModel: blockModel,
|
||||
blockView: blockView
|
||||
@ -80,9 +80,11 @@ define([
|
||||
it('includes content, globalStyles and initial newsletter fields', function() {
|
||||
var dataField = {
|
||||
containerModelField: 'containerModelValue'
|
||||
}, stylesField = {
|
||||
};
|
||||
var stylesField = {
|
||||
globalStylesField: 'globalStylesValue'
|
||||
}, newsletterFields = {
|
||||
};
|
||||
var newsletterFields = {
|
||||
subject: 'test newsletter subject'
|
||||
};
|
||||
EditorApplication._contentContainer = {
|
||||
|
@ -23,7 +23,8 @@ define([
|
||||
});
|
||||
|
||||
describe('once rendered', function() {
|
||||
var view, model;
|
||||
var view;
|
||||
var model;
|
||||
beforeEach(function() {
|
||||
model = new Backbone.SuperModel({
|
||||
subject: 'a test subject',
|
||||
|
@ -38,8 +38,8 @@ define([
|
||||
});
|
||||
|
||||
it('triggers afterEditorSave event', function() {
|
||||
var spy = sinon.spy(),
|
||||
promise = jQuery.Deferred();
|
||||
var spy = sinon.spy();
|
||||
var promise = jQuery.Deferred();
|
||||
global.stubChannel(EditorApplication, {
|
||||
trigger: spy
|
||||
});
|
||||
@ -74,8 +74,8 @@ define([
|
||||
});
|
||||
|
||||
it('encodes newsletter body in JSON format', function() {
|
||||
var body = {type: 'testType'},
|
||||
mock = sinon.mock()
|
||||
var body = {type: 'testType'};
|
||||
var mock = sinon.mock()
|
||||
.once()
|
||||
.withArgs({
|
||||
body: JSON.stringify(body)
|
||||
@ -134,8 +134,8 @@ define([
|
||||
});
|
||||
|
||||
it('triggers template saving when clicked on "save as template" button', function() {
|
||||
var mock = sinon.mock({ post: function() {} }).expects('post').once().returns(jQuery.Deferred()),
|
||||
html2canvasMock = jQuery.Deferred();
|
||||
var mock = sinon.mock({ post: function() {} }).expects('post').once().returns(jQuery.Deferred());
|
||||
var html2canvasMock = jQuery.Deferred();
|
||||
|
||||
html2canvasMock.resolve({
|
||||
toDataURL: function() { return 'somedataurl'; }
|
||||
@ -174,8 +174,8 @@ define([
|
||||
});
|
||||
|
||||
it('saves newsletter when clicked on "next" button', function() {
|
||||
var spy = sinon.spy(),
|
||||
module = SaveInjector({
|
||||
var spy = sinon.spy();
|
||||
var module = SaveInjector({
|
||||
'newsletter_editor/components/communication': {
|
||||
saveNewsletter: function() {
|
||||
return jQuery.Deferred();
|
||||
|
@ -47,7 +47,9 @@ define([
|
||||
});
|
||||
|
||||
describe('once rendered', function() {
|
||||
var model, availableStyles, view;
|
||||
var model;
|
||||
var availableStyles;
|
||||
var view;
|
||||
before(function() {
|
||||
model = new Backbone.SuperModel({
|
||||
text: {
|
||||
|
@ -35,7 +35,8 @@ define([
|
||||
});
|
||||
|
||||
describe('view', function() {
|
||||
var model, view;
|
||||
var model;
|
||||
var view;
|
||||
beforeEach(function() {
|
||||
model = new (StylesComponent.StylesModel)();
|
||||
view = new (StylesComponent.StylesView)({ model: model });
|
||||
|
Reference in New Issue
Block a user