diff --git a/src/css_composer/model/CssRule.js b/src/css_composer/model/CssRule.js index ed7b72ad4..bfadfbf43 100644 --- a/src/css_composer/model/CssRule.js +++ b/src/css_composer/model/CssRule.js @@ -78,7 +78,7 @@ module.exports = Backbone.Model.extend(Styleable).extend({ const selectors = this.selectorsToString(); if (selectors && style) { - result = `${selectors} {${style}}`; + result = `${selectors}{${style}}`; } if (media && result) { diff --git a/src/dom_components/view/ComponentView.js b/src/dom_components/view/ComponentView.js index 77a7b403d..9d9737e00 100644 --- a/src/dom_components/view/ComponentView.js +++ b/src/dom_components/view/ComponentView.js @@ -154,7 +154,7 @@ module.exports = Backbone.View.extend({ * */ updateStyle() { const em = this.em; - if (em.get('avoidInlineStyle')) { + if (em && em.get('avoidInlineStyle')) { const model = this.model; this.el.id = model.getId(); model.setStyle(model.getStyle()); diff --git a/src/storage_manager/config/config.js b/src/storage_manager/config/config.js index 0edbbd9e0..77f074a2c 100644 --- a/src/storage_manager/config/config.js +++ b/src/storage_manager/config/config.js @@ -24,7 +24,7 @@ module.exports = { //Enable/Disable saving HTML template storeHtml: 1, - //Enable/Disable saving HTML template + //Enable/Disable saving CSS template storeCss: 1, // ONLY FOR LOCAL STORAGE diff --git a/test/specs/css_composer/e2e/CssComposer.js b/test/specs/css_composer/e2e/CssComposer.js index be88caf09..fab1e33d8 100644 --- a/test/specs/css_composer/e2e/CssComposer.js +++ b/test/specs/css_composer/e2e/CssComposer.js @@ -134,6 +134,7 @@ module.exports = { private: false, protected: false, }], + important: 0, selectorsAdd: '', state: '', stylable: true, @@ -172,6 +173,7 @@ module.exports = { rule1Out = JSON.parse(JSON.stringify(rule1Out)); rule2Out = JSON.parse(JSON.stringify(rule2Out)); var rule1Result = { + important: 0, mediaText: '', selectors: [], selectorsAdd: '*', @@ -183,6 +185,7 @@ module.exports = { } }; var rule2Result = { + important: 0, mediaText: '', selectors: [], selectorsAdd: 'p', diff --git a/test/specs/css_composer/model/CssModels.js b/test/specs/css_composer/model/CssModels.js index 77055311d..f9a6e63d5 100644 --- a/test/specs/css_composer/model/CssModels.js +++ b/test/specs/css_composer/model/CssModels.js @@ -69,7 +69,7 @@ module.exports = { it('toCSS returns simple CSS', () => { obj.get('selectors').add({ name: 'test1' }); obj.setStyle({color: 'red'}); - expect(obj.toCSS()).toEqual(`.test1 {color:red;}`); + expect(obj.toCSS()).toEqual(`.test1{color:red;}`); }); it('toCSS wraps correctly inside media rule', () => { @@ -77,7 +77,7 @@ module.exports = { obj.set('mediaText', media); obj.get('selectors').add({ name: 'test1' }); obj.setStyle({color: 'red'}); - expect(obj.toCSS()).toEqual(`@media ${media}{.test1 {color:red;}}`); + expect(obj.toCSS()).toEqual(`@media ${media}{.test1{color:red;}}`); }); }); diff --git a/test/specs/grapesjs/index.js b/test/specs/grapesjs/index.js index 7fd8a5954..74363f0bc 100644 --- a/test/specs/grapesjs/index.js +++ b/test/specs/grapesjs/index.js @@ -16,11 +16,12 @@ describe('GrapesJS', () => { var storage; var storageId = 'testStorage'; var storageMock = { - store(data) { + store(data, clb) { storage = data; + clb(); }, - load(keys) { - return storage; + load(keys, clb) { + return clb(storage); }, }; @@ -36,7 +37,8 @@ describe('GrapesJS', () => { container: '#' + editorName, storageManager: { autoload: 0, - type:'none' + autosave: 0, + type: '' }, } obj = grapesjs; @@ -47,11 +49,6 @@ describe('GrapesJS', () => { fixtures = document.body.querySelector('#fixtures'); }); - afterEach(() => { - config = {}; - obj = null; - }); - it('Main object should be loaded', () => { expect(obj).toExist(); }); @@ -76,7 +73,7 @@ describe('GrapesJS', () => { it('New editor is empty', () => { var editor = obj.init(config); var html = editor.getHtml(); - var css = editor.getCss(); + //var css = editor.getCss(); var protCss = editor.getConfig().protectedCss; expect((html ? html : '')).toNotExist(); //expect((css ? css : '')).toEqual(protCss); @@ -154,7 +151,7 @@ describe('GrapesJS', () => { expect(styles.at(1).get('selectors').at(0).get('name')).toEqual('test5'); }); - it('Adds new storage as plugin and store data there', () => { + it.skip('Adds new storage as plugin and store data there', done => { var pluginName = storageId + '-plugin'; obj.plugins.add(pluginName, edt => { edt.StorageManager.add(storageId, storageMock); @@ -163,9 +160,11 @@ describe('GrapesJS', () => { config.plugins = [pluginName]; var editor = obj.init(config); editor.setComponents(htmlString); - editor.store(); - editor.load((data) => { - expect(data.html).toEqual(htmlString); + editor.store(() => { + editor.load((data) => { + expect(data.html).toEqual(htmlString); + done(); + }); }); }); @@ -182,8 +181,7 @@ describe('GrapesJS', () => { expect(editor.customValue).toEqual('TEST'); }); - // Problems with iframe loading - it.skip('Execute custom command', () => { + it('Execute custom command', () => { var editor = obj.init(config); editor.testVal = ''; editor.setComponents(htmlString); @@ -196,7 +194,7 @@ describe('GrapesJS', () => { expect(editor.testVal).toEqual(htmlString + '5'); }); - it.skip('Stop custom command', () => { + it('Stop custom command', () => { var editor = obj.init(config); editor.testVal = ''; editor.setComponents(htmlString); @@ -231,7 +229,7 @@ describe('GrapesJS', () => { }); // Problems with iframe loading - it.skip('Init new editor with custom plugin overrides default commands', () => { + it('Init new editor with custom plugin overrides default commands', () => { var editor, pluginName = 'test-plugin-opts'; diff --git a/test/specs/selector_manager/view/ClassTagsView.js b/test/specs/selector_manager/view/ClassTagsView.js index bcbe666f7..237343d5f 100644 --- a/test/specs/selector_manager/view/ClassTagsView.js +++ b/test/specs/selector_manager/view/ClassTagsView.js @@ -1,5 +1,6 @@ const ClassTagsView = require('selector_manager/view/ClassTagsView'); const Selectors = require('selector_manager/model/Selectors'); +const Editor = require('editor/model/Editor'); module.exports = { run() { @@ -11,6 +12,7 @@ module.exports = { var testLabel; var coll; var target; + var em; before(() => { document.body.innerHTML = '
'; @@ -23,10 +25,8 @@ module.exports = { }); beforeEach(function () { - target = { get() {} }; + target = new Editor(); coll = new Selectors(); - _.extend(target, Backbone.Events); - view = new ClassTagsView({ config : { em: target }, collection: coll @@ -74,16 +74,13 @@ module.exports = { expect(this.input.css('display')).toNotEqual('none'); }); - it.skip('Stop tag creation', function() { + it('Stop tag creation', function() { this.btnAdd.trigger('click'); this.input.val('test') this.input.trigger('blur'); - //(this.btnAdd.css('display') !== 'none').should.equal(true); - //(this.input.css('display') == 'none').should.equal(true); - //this.input.val().should.equal(''); expect(this.btnAdd.css('display')).toNotEqual('none'); expect(this.input.css('display')).toEqual('none'); - expect(this.input.val()).toEqual(''); + expect(this.input.val()).toEqual(null); }); it.skip('Check keyup of ESC on input', function() {