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,
"max-len": 0,
"space-unary-ops": 0,
"quotes": 0,
"no-unused-vars": 0,
"no-unused-expressions": 0,
"no-underscore-dangle": 0,

View File

@ -20,8 +20,8 @@ module.exports = {
loadTemplate: function (path, window, opts) {
var w = window || global.window;
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 = '';
Object.defineProperty(this, 'src', {
"get": function() {
'get': function() {
return this.address;
},
"set": function(src) {
'set': function(src) {
this.address = src;
this.onload();
}

View File

@ -166,7 +166,7 @@ define([
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, {
blockDefaults: {
automatedLatestContent: {
@ -301,23 +301,23 @@ define([
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.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 data = {
styles: {
block: {
borderRadius: "14px"
borderRadius: '14px'
}
}
};
callback(data);
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) {
var EditorApplication = App;
describe("Button", function () {
describe("model", function () {
describe('Button', function () {
describe('model', function () {
var model;
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');
});
it("has a label", function () {
it('has a label', function () {
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');
});
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$/);
});
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$/);
});
it("has a block border width", function () {
it('has a block border width', function () {
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$/);
});
it("has block border style", function () {
it('has block border style', function () {
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$/);
});
it("has a text font family", function () {
it('has a text font family', function () {
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$/);
});
it("has a text font weight", function () {
it('has a text font weight', function () {
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$/);
});
it("has line height", function () {
it('has line height', function () {
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';
model.set('text', 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');
EditorApplication.getChannel = sinon.stub().returns({
trigger: mock
@ -104,7 +104,7 @@ define([
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, {
blockDefaults: {
button: {
@ -272,17 +272,17 @@ define([
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.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 data = {
styles: {
block: {
borderRadius: "14px"
borderRadius: '14px'
}
}
};

View File

@ -28,7 +28,7 @@ define([
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, {
blockDefaults: {
container: {

View File

@ -4,8 +4,8 @@ define([
], function(App, DividerBlock) {
var EditorApplication = App;
describe("Divider", function () {
describe("model", function () {
describe('Divider', function () {
describe('model', function () {
var model;
beforeEach(function () {
@ -21,15 +21,15 @@ define([
delete EditorApplication.getChannel;
});
it("has a divider type", function () {
it('has a divider type', function () {
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$/);
});
it("has padding", function () {
it('has padding', function () {
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$/);
});
it("changes attributes with set", function () {
it('changes attributes with set', function () {
var newValue = 'outset';
model.set('styles.block.borderStyle', 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');
EditorApplication.getChannel = sinon.stub().returns({
trigger: mock
@ -66,7 +66,7 @@ define([
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, {
blockDefaults: {
divider: {

View File

@ -75,7 +75,7 @@ define([
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, {
blockDefaults: {
footer: {

View File

@ -51,13 +51,13 @@ define([
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';
model.set('text', 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');
EditorApplication.getChannel = sinon.stub().returns({
trigger: mock
@ -75,7 +75,7 @@ define([
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, {
blockDefaults: {
header: {

View File

@ -70,7 +70,7 @@ define([
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, {
blockDefaults: {
image: {

View File

@ -125,7 +125,7 @@ define([
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, {
blockDefaults: {
posts: {

View File

@ -25,7 +25,7 @@ define([
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, {
blockDefaults: {
social: {

View File

@ -33,13 +33,13 @@ define([
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';
model.set('styles.block.height', 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');
EditorApplication.getChannel = sinon.stub().returns({
trigger: mock
@ -51,7 +51,7 @@ define([
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, {
blockDefaults: {
spacer: {

View File

@ -20,7 +20,7 @@ define([
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, {
blockDefaults: {
text: {

View File

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