Fix ESLint linebreak-style in tests

[MAILPOET-1031]
This commit is contained in:
Pavel Dohnal
2017-08-30 15:19:15 +02:00
parent 9061e1b495
commit 737a83cdf3
2 changed files with 223 additions and 224 deletions

View File

@@ -12,7 +12,6 @@
"no-undef": 0, "no-undef": 0,
"one-var": 0, "one-var": 0,
"indent": 0, "indent": 0,
"linebreak-style": 0,
"no-whitespace-before-property": 0, "no-whitespace-before-property": 0,
"object-property-newline": 0, "object-property-newline": 0,
"global-require": 0, "global-require": 0,

View File

@@ -1,223 +1,223 @@
define([ define([
'newsletter_editor/App', 'newsletter_editor/App',
'newsletter_editor/blocks/divider' 'newsletter_editor/blocks/divider'
], 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 () {
global.stubChannel(EditorApplication); global.stubChannel(EditorApplication);
global.stubConfig(EditorApplication, { global.stubConfig(EditorApplication, {
blockDefaults: {} blockDefaults: {}
}); });
global.stubAvailableStyles(EditorApplication); global.stubAvailableStyles(EditorApplication);
model = new (DividerBlock.DividerBlockModel)(); model = new (DividerBlock.DividerBlockModel)();
}); });
afterEach(function () { afterEach(function () {
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$/);
}); });
it('has border style', function () { it('has border style', function () {
expect(model.get('styles.block.borderStyle')).to.match(/^(none|dotted|dashed|solid|double|groove|ridge|inset|outset)$/); expect(model.get('styles.block.borderStyle')).to.match(/^(none|dotted|dashed|solid|double|groove|ridge|inset|outset)$/);
}); });
it('has border width', function () { it('has 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 border color', function () { it('has 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('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
}); });
model.set('styles.block.backgroundColor', '#000000'); model.set('styles.block.backgroundColor', '#000000');
model.set('styles.block.padding', '19px'); model.set('styles.block.padding', '19px');
model.set('styles.block.borderStyle', 'double'); model.set('styles.block.borderStyle', 'double');
model.set('styles.block.borderWidth', '17px'); model.set('styles.block.borderWidth', '17px');
model.set('styles.block.borderColor', '#123456'); model.set('styles.block.borderColor', '#123456');
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: {
styles: { styles: {
block: { block: {
backgroundColor: '#123456', backgroundColor: '#123456',
padding: '37px', padding: '37px',
borderStyle: 'inset', borderStyle: 'inset',
borderWidth: '7px', borderWidth: '7px',
borderColor: '#345678' borderColor: '#345678'
} }
} }
} }
} }
}); });
var model = new (DividerBlock.DividerBlockModel)(); var 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');
expect(model.get('styles.block.borderStyle')).to.equal('inset'); expect(model.get('styles.block.borderStyle')).to.equal('inset');
expect(model.get('styles.block.borderWidth')).to.equal('7px'); expect(model.get('styles.block.borderWidth')).to.equal('7px');
expect(model.get('styles.block.borderColor')).to.equal('#345678'); expect(model.get('styles.block.borderColor')).to.equal('#345678');
}); });
}); });
describe('block view', function () { describe('block view', function () {
var model; var model;
var view; var view;
beforeEach(function () { beforeEach(function () {
global.stubChannel(EditorApplication); global.stubChannel(EditorApplication);
global.stubConfig(EditorApplication); global.stubConfig(EditorApplication);
model = new (DividerBlock.DividerBlockModel)(); model = new (DividerBlock.DividerBlockModel)();
view = new (DividerBlock.DividerBlockView)({model: model}); view = new (DividerBlock.DividerBlockView)({model: model});
}); });
it('renders', function () { it('renders', function () {
expect(view.render).to.not.throw(); expect(view.render).to.not.throw();
expect(view.$('.mailpoet_divider')).to.have.length(1); expect(view.$('.mailpoet_divider')).to.have.length(1);
}); });
it('rerenders if model attributes change', function () { it('rerenders if model attributes change', function () {
view.render(); view.render();
model.set('styles.block.borderStyle', 'inset'); model.set('styles.block.borderStyle', 'inset');
expect(view.$('.mailpoet_divider').css('border-top-style')).to.equal('inset'); expect(view.$('.mailpoet_divider').css('border-top-style')).to.equal('inset');
}); });
it('opens settings if clicked', function () { it('opens settings if clicked', function () {
var mock = sinon.mock().once(); var mock = sinon.mock().once();
model.on('startEditing', mock); model.on('startEditing', mock);
view.render(); view.render();
view.$('.mailpoet_divider').click(); view.$('.mailpoet_divider').click();
mock.verify(); mock.verify();
}); });
it('does not open settings if clicked on the resize handle', function () { it('does not open settings if clicked on the resize handle', function () {
var mock = sinon.mock().never(); var mock = sinon.mock().never();
model.on('startEditing', mock); model.on('startEditing', mock);
view.render(); view.render();
view.$('.mailpoet_resize_handle').click(); view.$('.mailpoet_resize_handle').click();
mock.verify(); mock.verify();
}); });
}); });
describe('settings view', function () { describe('settings view', function () {
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)(), var model = new (DividerBlock.DividerBlockModel)(),
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();
expect(view.$('.mailpoet_divider_selector')).to.have.length(1); expect(view.$('.mailpoet_divider_selector')).to.have.length(1);
}); });
describe('once rendered', function () { describe('once rendered', function () {
var model, view; var model, view;
before(function() { before(function() {
global.stubChannel(EditorApplication); global.stubChannel(EditorApplication);
global.stubAvailableStyles(EditorApplication, { global.stubAvailableStyles(EditorApplication, {
dividers: ['solid', 'inset'] dividers: ['solid', 'inset']
}); });
}); });
beforeEach(function () { beforeEach(function () {
model = new (DividerBlock.DividerBlockModel)(); model = new (DividerBlock.DividerBlockModel)();
view = new (DividerBlock.DividerBlockSettingsView)({model: model}); view = new (DividerBlock.DividerBlockSettingsView)({model: model});
view.render(); view.render();
}); });
it('updates the model when divider style changes', function () { it('updates the model when divider style changes', function () {
view.$('.mailpoet_field_divider_style').last().click(); view.$('.mailpoet_field_divider_style').last().click();
expect(model.get('styles.block.borderStyle')).to.equal('inset'); expect(model.get('styles.block.borderStyle')).to.equal('inset');
}); });
it('updates the model when divider width slider changes', function () { it('updates the model when divider width slider changes', function () {
view.$('.mailpoet_field_divider_border_width').val('17').change(); view.$('.mailpoet_field_divider_border_width').val('17').change();
expect(model.get('styles.block.borderWidth')).to.equal('17px'); expect(model.get('styles.block.borderWidth')).to.equal('17px');
}); });
it('updates the range slider when divider width input changes', function () { it('updates the range slider when divider width input changes', function () {
view.$('.mailpoet_field_divider_border_width_input').val('19').trigger('input'); view.$('.mailpoet_field_divider_border_width_input').val('19').trigger('input');
expect(view.$('.mailpoet_field_divider_border_width').val()).to.equal('19'); expect(view.$('.mailpoet_field_divider_border_width').val()).to.equal('19');
}); });
it('updates the input when divider width range slider changes', function () { it('updates the input when divider width range slider changes', function () {
view.$('.mailpoet_field_divider_border_width').val('19').change(); view.$('.mailpoet_field_divider_border_width').val('19').change();
expect(view.$('.mailpoet_field_divider_border_width_input').val()).to.equal('19'); expect(view.$('.mailpoet_field_divider_border_width_input').val()).to.equal('19');
}); });
it('updates the model when divider color changes', function () { it('updates the model when divider color changes', function () {
view.$('.mailpoet_field_divider_border_color').val('#123457').change(); view.$('.mailpoet_field_divider_border_color').val('#123457').change();
expect(model.get('styles.block.borderColor')).to.equal('#123457'); expect(model.get('styles.block.borderColor')).to.equal('#123457');
}); });
it('updates the model when divider background color changes', function () { it('updates the model when divider background color changes', function () {
view.$('.mailpoet_field_divider_background_color').val('#cccccc').change(); view.$('.mailpoet_field_divider_background_color').val('#cccccc').change();
expect(model.get('styles.block.backgroundColor')).to.equal('#cccccc'); expect(model.get('styles.block.backgroundColor')).to.equal('#cccccc');
}); });
it ('changes color of available divider styles when actual divider color changes', function() { it ('changes color of available divider styles when actual divider color changes', function() {
var newColor = '#889912'; var newColor = '#889912';
view.$('.mailpoet_field_divider_border_color').val(newColor).change(); view.$('.mailpoet_field_divider_border_color').val(newColor).change();
expect(view.$('.mailpoet_field_divider_style div')).to.have.$css('border-top-color', newColor); expect(view.$('.mailpoet_field_divider_style div')).to.have.$css('border-top-color', newColor);
}); });
it('does not display "Apply to all" option when `hideApplyToAll` option is active', function() { it('does not display "Apply to all" option when `hideApplyToAll` option is active', function() {
view = new (DividerBlock.DividerBlockSettingsView)({ view = new (DividerBlock.DividerBlockSettingsView)({
model: model, model: model,
renderOptions: { renderOptions: {
hideApplyToAll: true hideApplyToAll: true
} }
}); });
view.render(); view.render();
expect(view.$('.mailpoet_button_divider_apply_to_all').length).to.equal(0); expect(view.$('.mailpoet_button_divider_apply_to_all').length).to.equal(0);
}); });
it.skip('closes the sidepanel after "Done" is clicked', function () { it.skip('closes the sidepanel after "Done" is clicked', function () {
var mock = sinon.mock().once(); var mock = sinon.mock().once();
global.MailPoet.Modal.cancel = mock; global.MailPoet.Modal.cancel = mock;
view.$('.mailpoet_done_editing').click(); view.$('.mailpoet_done_editing').click();
mock.verify(); mock.verify();
delete(global.MailPoet.Modal.cancel); delete(global.MailPoet.Modal.cancel);
}); });
}); });
}); });
}); });
}); });