tests: quotes

This commit is contained in:
Amine Ben hammou
2017-08-23 17:09:45 +00:00
committed by pavel-mailpoet
parent 2985705b14
commit d181bde0e9
15 changed files with 67 additions and 68 deletions

View File

@ -27,7 +27,6 @@
"func-call-spacing": 0, "func-call-spacing": 0,
"max-len": 0, "max-len": 0,
"space-unary-ops": 0, "space-unary-ops": 0,
"quotes": 0,
"no-unused-vars": 0, "no-unused-vars": 0,
"no-unused-expressions": 0, "no-unused-expressions": 0,
"no-underscore-dangle": 0, "no-underscore-dangle": 0,

View File

@ -20,8 +20,8 @@ module.exports = {
loadTemplate: function (path, window, opts) { loadTemplate: function (path, window, opts) {
var w = window || global.window; var w = window || global.window;
var options = opts || {}; var options = opts || {};
options.type = "text/x-handlebars-template"; options.type = 'text/x-handlebars-template';
this.loadScript("views/newsletter/templates/" + path, w, options); this.loadScript('views/newsletter/templates/' + path, w, options);
} }
}; };

View File

@ -80,10 +80,10 @@ global.stubImage = function(defaultWidth, defaultHeight) {
this.address = ''; this.address = '';
Object.defineProperty(this, 'src', { Object.defineProperty(this, 'src', {
"get": function() { 'get': function() {
return this.address; return this.address;
}, },
"set": function(src) { 'set': function(src) {
this.address = src; this.address = src;
this.onload(); this.onload();
} }

View File

@ -166,7 +166,7 @@ define([
expect(model.get('divider')).to.be.instanceof(Backbone.Model); expect(model.get('divider')).to.be.instanceof(Backbone.Model);
}); });
it("uses defaults from config when they are set", function () { it('uses defaults from config when they are set', function () {
global.stubConfig(EditorApplication, { global.stubConfig(EditorApplication, {
blockDefaults: { blockDefaults: {
automatedLatestContent: { automatedLatestContent: {
@ -301,23 +301,23 @@ define([
view = new (module.AutomatedLatestContentBlockView)({model: model}); view = new (module.AutomatedLatestContentBlockView)({model: model});
}); });
it("listens to the event", function () { it('listens to the event', function () {
expect(onStub).to.have.been.calledOnce; expect(onStub).to.have.been.calledOnce;
expect(onStub).to.have.been.calledWith("replaceAllButtonStyles", sinon.match.func); expect(onStub).to.have.been.calledWith('replaceAllButtonStyles', sinon.match.func);
}); });
it("updates the model", function () { it('updates the model', function () {
const callback = onStub.getCall(0).args[1]; const callback = onStub.getCall(0).args[1];
const data = { const data = {
styles: { styles: {
block: { block: {
borderRadius: "14px" borderRadius: '14px'
} }
} }
}; };
callback(data); callback(data);
expect(model.set).to.have.been.calledOnce; expect(model.set).to.have.been.calledOnce;
expect(model.set).to.have.been.calledWithMatch(sinon.match.has("readMoreButton", data)); expect(model.set).to.have.been.calledWithMatch(sinon.match.has('readMoreButton', data));
}); });
}); });

View File

@ -4,8 +4,8 @@ define([
], function(App, ButtonBlock) { ], function(App, ButtonBlock) {
var EditorApplication = App; var EditorApplication = App;
describe("Button", function () { describe('Button', function () {
describe("model", function () { describe('model', function () {
var model; var model;
beforeEach(function () { beforeEach(function () {
@ -22,69 +22,69 @@ define([
} }
}); });
it("has a button type", function () { it('has a button type', function () {
expect(model.get('type')).to.equal('button'); expect(model.get('type')).to.equal('button');
}); });
it("has a label", function () { it('has a label', function () {
expect(model.get('text')).to.be.a('string'); expect(model.get('text')).to.be.a('string');
}); });
it("has a url", function () { it('has a url', function () {
expect(model.get('url')).to.be.a('string'); expect(model.get('url')).to.be.a('string');
}); });
it("has a block background color", function () { it('has a block background color', function () {
expect(model.get('styles.block.backgroundColor')).to.match(/^(#[abcdef0-9]{6})|transparent$/); expect(model.get('styles.block.backgroundColor')).to.match(/^(#[abcdef0-9]{6})|transparent$/);
}); });
it("has a block border color", function () { it('has a block border color', function () {
expect(model.get('styles.block.borderColor')).to.match(/^(#[abcdef0-9]{6})|transparent$/); expect(model.get('styles.block.borderColor')).to.match(/^(#[abcdef0-9]{6})|transparent$/);
}); });
it("has a block border width", function () { it('has a block border width', function () {
expect(model.get('styles.block.borderWidth')).to.match(/^\d+px$/); expect(model.get('styles.block.borderWidth')).to.match(/^\d+px$/);
}); });
it("has block border radius", function () { it('has block border radius', function () {
expect(model.get('styles.block.borderRadius')).to.match(/^\d+px$/); expect(model.get('styles.block.borderRadius')).to.match(/^\d+px$/);
}); });
it("has block border style", function () { it('has block border style', function () {
expect(model.get('styles.block.borderStyle')).to.equal('solid'); expect(model.get('styles.block.borderStyle')).to.equal('solid');
}); });
it("has a text color", function () { it('has a text color', function () {
expect(model.get('styles.block.fontColor')).to.match(/^(#[abcdef0-9]{6})|transparent$/); expect(model.get('styles.block.fontColor')).to.match(/^(#[abcdef0-9]{6})|transparent$/);
}); });
it("has a text font family", function () { it('has a text font family', function () {
expect(model.get('styles.block.fontFamily')).to.be.a('string'); expect(model.get('styles.block.fontFamily')).to.be.a('string');
}); });
it("has a text size", function () { it('has a text size', function () {
expect(model.get('styles.block.fontSize')).to.match(/^\d+px$/); expect(model.get('styles.block.fontSize')).to.match(/^\d+px$/);
}); });
it("has a text font weight", function () { it('has a text font weight', function () {
expect(model.get('styles.block.fontWeight')).to.match(/^(bold|normal)$/); expect(model.get('styles.block.fontWeight')).to.match(/^(bold|normal)$/);
}); });
it("has width", function () { it('has width', function () {
expect(model.get('styles.block.width')).to.match(/^\d+px$/); expect(model.get('styles.block.width')).to.match(/^\d+px$/);
}); });
it("has line height", function () { it('has line height', function () {
expect(model.get('styles.block.lineHeight')).to.match(/^\d+px$/); expect(model.get('styles.block.lineHeight')).to.match(/^\d+px$/);
}); });
it("changes attributes with set", function () { it('changes attributes with set', function () {
var newText = 'Some new text'; var newText = 'Some new text';
model.set('text', newText); model.set('text', newText);
expect(model.get('text')).to.equal(newText); expect(model.get('text')).to.equal(newText);
}); });
it("triggers autosave if any attribute changes", function () { it('triggers autosave if any attribute changes', function () {
var mock = sinon.mock().exactly(12).withArgs('autoSave'); var mock = sinon.mock().exactly(12).withArgs('autoSave');
EditorApplication.getChannel = sinon.stub().returns({ EditorApplication.getChannel = sinon.stub().returns({
trigger: mock trigger: mock
@ -104,7 +104,7 @@ define([
mock.verify(); mock.verify();
}); });
it("uses defaults from config when they are set", function () { it('uses defaults from config when they are set', function () {
global.stubConfig(EditorApplication, { global.stubConfig(EditorApplication, {
blockDefaults: { blockDefaults: {
button: { button: {
@ -272,17 +272,17 @@ define([
view.render(); view.render();
}); });
it("listens to the event", function () { it('listens to the event', function () {
expect(onStub).to.have.been.calledOnce; expect(onStub).to.have.been.calledOnce;
expect(onStub).to.have.been.calledWith("replaceAllButtonStyles", sinon.match.func); expect(onStub).to.have.been.calledWith('replaceAllButtonStyles', sinon.match.func);
}); });
it("updates the model", function () { it('updates the model', function () {
const callback = onStub.getCall(0).args[1]; const callback = onStub.getCall(0).args[1];
const data = { const data = {
styles: { styles: {
block: { block: {
borderRadius: "14px" borderRadius: '14px'
} }
} }
}; };

View File

@ -28,7 +28,7 @@ define([
expect(model.get('blocks')).to.be.instanceof(Backbone.Collection); expect(model.get('blocks')).to.be.instanceof(Backbone.Collection);
}); });
it("uses defaults from config when they are set", function () { it('uses defaults from config when they are set', function () {
global.stubConfig(EditorApplication, { global.stubConfig(EditorApplication, {
blockDefaults: { blockDefaults: {
container: { container: {

View File

@ -4,8 +4,8 @@ define([
], function(App, DividerBlock) { ], function(App, DividerBlock) {
var EditorApplication = App; var EditorApplication = App;
describe("Divider", function () { describe('Divider', function () {
describe("model", function () { describe('model', function () {
var model; var model;
beforeEach(function () { beforeEach(function () {
@ -21,15 +21,15 @@ define([
delete EditorApplication.getChannel; delete EditorApplication.getChannel;
}); });
it("has a divider type", function () { it('has a divider type', function () {
expect(model.get('type')).to.equal('divider'); expect(model.get('type')).to.equal('divider');
}); });
it("has a background color", function () { it('has a background color', function () {
expect(model.get('styles.block.backgroundColor')).to.match(/^(#[abcdef0-9]{6})|transparent$/); expect(model.get('styles.block.backgroundColor')).to.match(/^(#[abcdef0-9]{6})|transparent$/);
}); });
it("has padding", function () { it('has padding', function () {
expect(model.get('styles.block.padding')).to.match(/^\d+px$/); expect(model.get('styles.block.padding')).to.match(/^\d+px$/);
}); });
@ -45,13 +45,13 @@ define([
expect(model.get('styles.block.borderColor')).to.match(/^(#[abcdef0-9]{6})|transparent$/); expect(model.get('styles.block.borderColor')).to.match(/^(#[abcdef0-9]{6})|transparent$/);
}); });
it("changes attributes with set", function () { it('changes attributes with set', function () {
var newValue = 'outset'; var newValue = 'outset';
model.set('styles.block.borderStyle', newValue); model.set('styles.block.borderStyle', newValue);
expect(model.get('styles.block.borderStyle')).to.equal(newValue); expect(model.get('styles.block.borderStyle')).to.equal(newValue);
}); });
it("triggers autosave if any attribute changes", function () { it('triggers autosave if any attribute changes', function () {
var mock = sinon.mock().exactly(5).withArgs('autoSave'); var mock = sinon.mock().exactly(5).withArgs('autoSave');
EditorApplication.getChannel = sinon.stub().returns({ EditorApplication.getChannel = sinon.stub().returns({
trigger: mock trigger: mock
@ -66,7 +66,7 @@ define([
mock.verify(); mock.verify();
}); });
it("uses defaults from config when they are set", function () { it('uses defaults from config when they are set', function () {
global.stubConfig(EditorApplication, { global.stubConfig(EditorApplication, {
blockDefaults: { blockDefaults: {
divider: { divider: {

View File

@ -75,7 +75,7 @@ define([
mock.verify(); mock.verify();
}); });
it("uses defaults from config when they are set", function () { it('uses defaults from config when they are set', function () {
global.stubConfig(EditorApplication, { global.stubConfig(EditorApplication, {
blockDefaults: { blockDefaults: {
footer: { footer: {

View File

@ -51,13 +51,13 @@ define([
expect(model.get('styles.link.textDecoration')).to.match(/^(underline|none)$/); expect(model.get('styles.link.textDecoration')).to.match(/^(underline|none)$/);
}); });
it("changes attributes with set", function () { it('changes attributes with set', function () {
var newValue = 'Some random teeeext'; var newValue = 'Some random teeeext';
model.set('text', newValue); model.set('text', newValue);
expect(model.get('text')).to.equal(newValue); expect(model.get('text')).to.equal(newValue);
}); });
it("triggers autosave if any attribute changes", function () { it('triggers autosave if any attribute changes', function () {
var mock = sinon.mock().exactly(8).withArgs('autoSave'); var mock = sinon.mock().exactly(8).withArgs('autoSave');
EditorApplication.getChannel = sinon.stub().returns({ EditorApplication.getChannel = sinon.stub().returns({
trigger: mock trigger: mock
@ -75,7 +75,7 @@ define([
mock.verify(); mock.verify();
}); });
it("uses defaults from config when they are set", function () { it('uses defaults from config when they are set', function () {
global.stubConfig(EditorApplication, { global.stubConfig(EditorApplication, {
blockDefaults: { blockDefaults: {
header: { header: {

View File

@ -70,7 +70,7 @@ define([
mock.verify(); mock.verify();
}); });
it("uses defaults from config when they are set", function () { it('uses defaults from config when they are set', function () {
global.stubConfig(EditorApplication, { global.stubConfig(EditorApplication, {
blockDefaults: { blockDefaults: {
image: { image: {

View File

@ -125,7 +125,7 @@ define([
expect(model.get('divider')).to.be.instanceof(Backbone.Model); expect(model.get('divider')).to.be.instanceof(Backbone.Model);
}); });
it("uses defaults from config when they are set", function () { it('uses defaults from config when they are set', function () {
global.stubConfig(EditorApplication, { global.stubConfig(EditorApplication, {
blockDefaults: { blockDefaults: {
posts: { posts: {

View File

@ -25,7 +25,7 @@ define([
expect(model.get('icons')).to.be.an.instanceof(Backbone.Collection); expect(model.get('icons')).to.be.an.instanceof(Backbone.Collection);
}); });
it("uses defaults from config when they are set", function () { it('uses defaults from config when they are set', function () {
global.stubConfig(EditorApplication, { global.stubConfig(EditorApplication, {
blockDefaults: { blockDefaults: {
social: { social: {

View File

@ -33,13 +33,13 @@ define([
expect(model.get('styles.block.backgroundColor')).to.match(/^(#[abcdef0-9]{6})|transparent$/); expect(model.get('styles.block.backgroundColor')).to.match(/^(#[abcdef0-9]{6})|transparent$/);
}); });
it("changes attributes with set", function () { it('changes attributes with set', function () {
var newValue = '33px'; var newValue = '33px';
model.set('styles.block.height', newValue); model.set('styles.block.height', newValue);
expect(model.get('styles.block.height')).to.equal(newValue); expect(model.get('styles.block.height')).to.equal(newValue);
}); });
it("triggers autosave if any attribute changes", function () { it('triggers autosave if any attribute changes', function () {
var mock = sinon.mock().exactly(2).withArgs('autoSave'); var mock = sinon.mock().exactly(2).withArgs('autoSave');
EditorApplication.getChannel = sinon.stub().returns({ EditorApplication.getChannel = sinon.stub().returns({
trigger: mock trigger: mock
@ -51,7 +51,7 @@ define([
mock.verify(); mock.verify();
}); });
it("uses defaults from config when they are set", function () { it('uses defaults from config when they are set', function () {
global.stubConfig(EditorApplication, { global.stubConfig(EditorApplication, {
blockDefaults: { blockDefaults: {
spacer: { spacer: {

View File

@ -20,7 +20,7 @@ define([
expect(model.get('text')).to.be.a('string'); expect(model.get('text')).to.be.a('string');
}); });
it("uses defaults from config when they are set", function () { it('uses defaults from config when they are set', function () {
global.stubConfig(EditorApplication, { global.stubConfig(EditorApplication, {
blockDefaults: { blockDefaults: {
text: { text: {

View File

@ -7,7 +7,7 @@ define([
describe('getPostTypes', function() { describe('getPostTypes', function() {
it('fetches post types from the server', function() { it('fetches post types from the server', function() {
var module = CommunicationInjector({ var module = CommunicationInjector({
"mailpoet": { 'mailpoet': {
Ajax: { Ajax: {
post: function() { post: function() {
var deferred = jQuery.Deferred(); var deferred = jQuery.Deferred();
@ -31,7 +31,7 @@ define([
var deferred = jQuery.Deferred(), var deferred = jQuery.Deferred(),
mock = sinon.mock({ post: function() {} }).expects('post').once().returns(deferred), mock = sinon.mock({ post: function() {} }).expects('post').once().returns(deferred),
module = CommunicationInjector({ module = CommunicationInjector({
"mailpoet": { 'mailpoet': {
Ajax: { Ajax: {
post: mock post: mock
} }
@ -62,7 +62,7 @@ define([
module; module;
spy = sinon.spy(post); spy = sinon.spy(post);
module = CommunicationInjector({ module = CommunicationInjector({
"mailpoet": { 'mailpoet': {
Ajax: { Ajax: {
post: spy post: spy
} }
@ -75,7 +75,7 @@ define([
it('fetches taxonomies from the server', function() { it('fetches taxonomies from the server', function() {
var module = CommunicationInjector({ var module = CommunicationInjector({
"mailpoet": { 'mailpoet': {
Ajax: { Ajax: {
post: function() { post: function() {
var deferred = jQuery.Deferred(); var deferred = jQuery.Deferred();
@ -98,7 +98,7 @@ define([
var deferred = jQuery.Deferred(), var deferred = jQuery.Deferred(),
mock = sinon.mock({ post: function() {} }).expects('post').once().returns(deferred), mock = sinon.mock({ post: function() {} }).expects('post').once().returns(deferred),
module = CommunicationInjector({ module = CommunicationInjector({
"mailpoet": { 'mailpoet': {
Ajax: { Ajax: {
post: mock post: mock
} }
@ -123,7 +123,7 @@ define([
var module; var module;
spy = sinon.spy(post); spy = sinon.spy(post);
module = CommunicationInjector({ module = CommunicationInjector({
"mailpoet": { 'mailpoet': {
Ajax: { Ajax: {
post: spy post: spy
} }
@ -138,7 +138,7 @@ define([
it('fetches terms from the server', function() { it('fetches terms from the server', function() {
var module = CommunicationInjector({ var module = CommunicationInjector({
"mailpoet": { 'mailpoet': {
Ajax: { Ajax: {
post: function() { post: function() {
var deferred = jQuery.Deferred(); var deferred = jQuery.Deferred();
@ -162,7 +162,7 @@ define([
var deferred = jQuery.Deferred(), var deferred = jQuery.Deferred(),
mock = sinon.mock({ post: function() {} }).expects('post').once().returns(deferred), mock = sinon.mock({ post: function() {} }).expects('post').once().returns(deferred),
module = CommunicationInjector({ module = CommunicationInjector({
"mailpoet": { 'mailpoet': {
Ajax: { Ajax: {
post: mock post: mock
} }
@ -187,7 +187,7 @@ define([
module; module;
spy = sinon.spy(post); spy = sinon.spy(post);
module = CommunicationInjector({ module = CommunicationInjector({
"mailpoet": { 'mailpoet': {
Ajax: { Ajax: {
post: spy post: spy
} }
@ -206,7 +206,7 @@ define([
it('fetches posts from the server', function() { it('fetches posts from the server', function() {
var module = CommunicationInjector({ var module = CommunicationInjector({
"mailpoet": { 'mailpoet': {
Ajax: { Ajax: {
post: function() { post: function() {
var deferred = jQuery.Deferred(); var deferred = jQuery.Deferred();
@ -230,7 +230,7 @@ define([
var deferred = jQuery.Deferred(), var deferred = jQuery.Deferred(),
mock = sinon.mock({ post: function() {} }).expects('post').once().returns(deferred), mock = sinon.mock({ post: function() {} }).expects('post').once().returns(deferred),
module = CommunicationInjector({ module = CommunicationInjector({
"mailpoet": { 'mailpoet': {
Ajax: { Ajax: {
post: mock post: mock
} }
@ -258,7 +258,7 @@ define([
module; module;
spy = sinon.spy(post); spy = sinon.spy(post);
module = CommunicationInjector({ module = CommunicationInjector({
"mailpoet": { 'mailpoet': {
Ajax: { Ajax: {
post: spy post: spy
} }
@ -277,7 +277,7 @@ define([
it('fetches transformed posts from the server', function() { it('fetches transformed posts from the server', function() {
var module = CommunicationInjector({ var module = CommunicationInjector({
"mailpoet": { 'mailpoet': {
Ajax: { Ajax: {
post: function() { post: function() {
var deferred = jQuery.Deferred(); var deferred = jQuery.Deferred();
@ -301,7 +301,7 @@ define([
var deferred = jQuery.Deferred(), var deferred = jQuery.Deferred(),
mock = sinon.mock({ post: function() {} }).expects('post').once().returns(deferred), mock = sinon.mock({ post: function() {} }).expects('post').once().returns(deferred),
module = CommunicationInjector({ module = CommunicationInjector({
"mailpoet": { 'mailpoet': {
Ajax: { Ajax: {
post: mock post: mock
} }