From eb0f1bdde858dedb7e42a6b00a4f191b0e7b28c5 Mon Sep 17 00:00:00 2001 From: Artur Arseniev Date: Sun, 27 May 2018 23:54:22 +0200 Subject: [PATCH] Update tests for jest --- package.json | 1 + src/asset_manager/view/AssetView.js | 2 + src/asset_manager/view/AssetsView.js | 1 + src/block_manager/model/Block.js | 2 +- src/block_manager/model/Blocks.js | 2 +- src/block_manager/model/Categories.js | 2 +- src/block_manager/model/Category.js | 2 +- src/block_manager/view/BlocksView.js | 4 +- src/canvas/model/Canvas.js | 2 +- src/canvas/model/Frame.js | 2 +- src/canvas/view/CanvasView.js | 1 + src/code_manager/model/CodeMirrorEditor.js | 2 +- src/code_manager/model/HtmlGenerator.js | 2 +- src/code_manager/model/JsGenerator.js | 5 +- src/code_manager/model/JsonGenerator.js | 5 +- src/code_manager/view/EditorView.js | 5 +- src/commands/model/Command.js | 2 +- src/commands/model/Commands.js | 2 +- src/commands/view/CreateComponent.js | 2 + src/commands/view/DeleteComponent.js | 2 + src/commands/view/ExportTemplate.js | 1 + src/commands/view/ImageComponent.js | 3 +- src/commands/view/InsertCustom.js | 3 +- src/commands/view/MoveComponent.js | 2 + src/commands/view/OpenLayers.js | 1 + src/commands/view/OpenStyleManager.js | 2 +- src/commands/view/Preview.js | 2 + src/commands/view/SelectPosition.js | 1 + src/commands/view/ShowOffset.js | 1 + src/commands/view/TextComponent.js | 3 +- src/css_composer/model/CssRule.js | 3 +- src/css_composer/model/CssRules.js | 2 +- src/device_manager/model/Device.js | 2 +- src/device_manager/model/Devices.js | 2 +- src/utils/Dragger.js | 1 + src/utils/Sorter.js | 1 + test/helper.js | 49 ----------------- test/setup.js | 23 ++++++++ test/specs/asset_manager/index.js | 4 +- test/specs/asset_manager/model/Asset.js | 10 ++-- test/specs/asset_manager/model/AssetImage.js | 8 +-- test/specs/asset_manager/model/Assets.js | 2 +- .../asset_manager/view/AssetImageView.js | 8 +-- test/specs/asset_manager/view/AssetView.js | 2 +- test/specs/asset_manager/view/AssetsView.js | 16 +++--- test/specs/asset_manager/view/FileUploader.js | 4 +- test/specs/block_manager/index.js | 4 +- test/specs/block_manager/view/BlocksView.js | 2 +- test/specs/code_manager/index.js | 2 +- test/specs/commands/index.js | 52 +++++++++---------- test/specs/commands/model/CommandModels.js | 2 +- test/specs/css_composer/index.js | 4 +- test/specs/css_composer/view/CssRuleView.js | 2 +- test/specs/css_composer/view/CssRulesView.js | 8 +-- test/specs/device_manager/index.js | 4 +- test/specs/device_manager/view/DevicesView.js | 4 +- test/specs/dom_components/index.js | 6 +-- test/specs/dom_components/model/Component.js | 4 +- .../dom_components/view/ComponentImageView.js | 2 +- .../dom_components/view/ComponentsView.js | 4 +- test/specs/grapesjs/index.js | 24 ++++----- test/specs/keymaps/index.js | 2 +- test/specs/modal/index.js | 2 +- test/specs/modal/view/ModalView.js | 6 +-- test/specs/panels/index.js | 4 +- test/specs/panels/view/ButtonView.js | 2 +- test/specs/panels/view/ButtonsView.js | 2 +- test/specs/panels/view/PanelsView.js | 2 +- test/specs/plugin_manager/index.js | 4 +- test/specs/selector_manager/index.js | 2 +- .../selector_manager/view/ClassTagView.js | 14 ++--- .../selector_manager/view/ClassTagsView.js | 14 ++--- test/specs/storage_manager/index.js | 10 ++-- test/specs/style_manager/index.js | 6 +-- test/specs/style_manager/model/Models.js | 8 +-- test/specs/style_manager/view/LayerView.js | 12 ++--- .../style_manager/view/PropertyColorView.js | 16 +++--- .../view/PropertyCompositeView.js | 12 ++--- .../style_manager/view/PropertyIntegerView.js | 16 +++--- .../style_manager/view/PropertyRadioView.js | 12 ++--- .../style_manager/view/PropertySelectView.js | 12 ++--- .../style_manager/view/PropertyStackView.js | 14 ++--- test/specs/style_manager/view/PropertyView.js | 18 +++---- test/specs/style_manager/view/SectorView.js | 6 +-- test/specs/trait_manager/model/TraitsModel.js | 2 +- test/specs/trait_manager/view/TraitsView.js | 2 +- 86 files changed, 264 insertions(+), 264 deletions(-) delete mode 100644 test/helper.js create mode 100644 test/setup.js diff --git a/package.json b/package.json index e0f1535acb..daec3de4be 100644 --- a/package.json +++ b/package.json @@ -84,6 +84,7 @@ }, "jest": { "modulePaths": ["./src"], + "setupFiles": ["/test/setup.js"], "moduleNameMapper": { "^jquery$": "cash-dom" } diff --git a/src/asset_manager/view/AssetView.js b/src/asset_manager/view/AssetView.js index 3297ee8e54..b2df5fb441 100644 --- a/src/asset_manager/view/AssetView.js +++ b/src/asset_manager/view/AssetView.js @@ -1,3 +1,5 @@ +import Backbone from 'backbone'; + module.exports = Backbone.View.extend({ initialize(o = {}) { this.options = o; diff --git a/src/asset_manager/view/AssetsView.js b/src/asset_manager/view/AssetsView.js index 061fbc29dd..138309df55 100644 --- a/src/asset_manager/view/AssetsView.js +++ b/src/asset_manager/view/AssetsView.js @@ -1,3 +1,4 @@ +import Backbone from 'backbone'; var AssetView = require('./AssetView'); var AssetImageView = require('./AssetImageView'); var FileUploader = require('./FileUploader'); diff --git a/src/block_manager/model/Block.js b/src/block_manager/model/Block.js index 356091ea1e..b66d3779d4 100644 --- a/src/block_manager/model/Block.js +++ b/src/block_manager/model/Block.js @@ -1,4 +1,4 @@ -var Backbone = require('backbone'); +import Backbone from 'backbone'; var Category = require('./Category'); module.exports = Backbone.Model.extend({ diff --git a/src/block_manager/model/Blocks.js b/src/block_manager/model/Blocks.js index 30b9a039ab..5c3d024756 100644 --- a/src/block_manager/model/Blocks.js +++ b/src/block_manager/model/Blocks.js @@ -1,4 +1,4 @@ -var Backbone = require('backbone'); +import Backbone from 'backbone'; var Block = require('./Block'); module.exports = Backbone.Collection.extend({ diff --git a/src/block_manager/model/Categories.js b/src/block_manager/model/Categories.js index 849324aee9..2d3a7b4180 100644 --- a/src/block_manager/model/Categories.js +++ b/src/block_manager/model/Categories.js @@ -1,4 +1,4 @@ -var Backbone = require('backbone'); +import Backbone from 'backbone'; module.exports = Backbone.Collection.extend({ model: require('./Category') diff --git a/src/block_manager/model/Category.js b/src/block_manager/model/Category.js index 379151c572..cc6b489248 100644 --- a/src/block_manager/model/Category.js +++ b/src/block_manager/model/Category.js @@ -1,4 +1,4 @@ -var Backbone = require('backbone'); +import Backbone from 'backbone'; module.exports = Backbone.Model.extend({ defaults: { diff --git a/src/block_manager/view/BlocksView.js b/src/block_manager/view/BlocksView.js index 8d8a4fce49..6a722391ef 100644 --- a/src/block_manager/view/BlocksView.js +++ b/src/block_manager/view/BlocksView.js @@ -1,11 +1,11 @@ -import { isString, isObject } from 'underscore'; +import { isString, isObject, bindAll } from 'underscore'; const BlockView = require('./BlockView'); const CategoryView = require('./CategoryView'); module.exports = require('backbone').View.extend({ initialize(opts, config) { - _.bindAll(this, 'getSorter', 'onDrag', 'onDrop'); + bindAll(this, 'getSorter', 'onDrag', 'onDrop'); this.config = config || {}; this.categories = opts.categories || ''; this.renderedCategories = []; diff --git a/src/canvas/model/Canvas.js b/src/canvas/model/Canvas.js index ce168885fc..7f09c39ad6 100644 --- a/src/canvas/model/Canvas.js +++ b/src/canvas/model/Canvas.js @@ -1,4 +1,4 @@ -var Backbone = require('backbone'); +import Backbone from 'backbone'; var Frame = require('./Frame'); module.exports = Backbone.Model.extend({ diff --git a/src/canvas/model/Frame.js b/src/canvas/model/Frame.js index 9c859ac0df..30e835c61e 100644 --- a/src/canvas/model/Frame.js +++ b/src/canvas/model/Frame.js @@ -1,4 +1,4 @@ -var Backbone = require('backbone'); +import Backbone from 'backbone'; module.exports = Backbone.Model.extend({ defaults: { diff --git a/src/canvas/view/CanvasView.js b/src/canvas/view/CanvasView.js index 9dbf291f9b..96c6e88ddc 100644 --- a/src/canvas/view/CanvasView.js +++ b/src/canvas/view/CanvasView.js @@ -1,3 +1,4 @@ +import Backbone from 'backbone'; import { on, off, getElement } from 'utils/mixins'; const FrameView = require('./FrameView'); const $ = Backbone.$; diff --git a/src/code_manager/model/CodeMirrorEditor.js b/src/code_manager/model/CodeMirrorEditor.js index 045f65f2bb..e233ecfc3d 100644 --- a/src/code_manager/model/CodeMirrorEditor.js +++ b/src/code_manager/model/CodeMirrorEditor.js @@ -1,4 +1,4 @@ -var Backbone = require('backbone'); +import Backbone from 'backbone'; var CodeMirror = require('codemirror/lib/codemirror'); var htmlMode = require('codemirror/mode/htmlmixed/htmlmixed'); var cssMode = require('codemirror/mode/css/css'); diff --git a/src/code_manager/model/HtmlGenerator.js b/src/code_manager/model/HtmlGenerator.js index 84559412e6..3862ad5c88 100644 --- a/src/code_manager/model/HtmlGenerator.js +++ b/src/code_manager/model/HtmlGenerator.js @@ -1,4 +1,4 @@ -var Backbone = require('backbone'); +import Backbone from 'backbone'; module.exports = Backbone.Model.extend({ build(model, opts = {}) { diff --git a/src/code_manager/model/JsGenerator.js b/src/code_manager/model/JsGenerator.js index 4c1116e7ae..e67c60130c 100644 --- a/src/code_manager/model/JsGenerator.js +++ b/src/code_manager/model/JsGenerator.js @@ -1,4 +1,5 @@ -var Backbone = require('backbone'); +import { extend } from 'underscore'; +import Backbone from 'backbone'; module.exports = Backbone.Model.extend({ mapModel(model) { @@ -11,7 +12,7 @@ module.exports = Backbone.Model.extend({ if (script) { // If the component has scripts we need to expose his ID var attr = model.get('attributes'); - attr = _.extend({}, attr, { id }); + attr = extend({}, attr, { id }); model.set('attributes', attr); var scrStr = model.getScriptString(); diff --git a/src/code_manager/model/JsonGenerator.js b/src/code_manager/model/JsonGenerator.js index 48dc5f737e..1a28558640 100644 --- a/src/code_manager/model/JsonGenerator.js +++ b/src/code_manager/model/JsonGenerator.js @@ -1,4 +1,5 @@ -var Backbone = require('backbone'); +import { each } from 'underscore'; +import Backbone from 'backbone'; module.exports = Backbone.Model.extend({ /** @inheritdoc */ @@ -6,7 +7,7 @@ module.exports = Backbone.Model.extend({ var json = model.toJSON(); this.beforeEach(json); - _.each( + each( json, function(v, attr) { var obj = json[attr]; diff --git a/src/code_manager/view/EditorView.js b/src/code_manager/view/EditorView.js index e68fc2afa9..82b8618b82 100644 --- a/src/code_manager/view/EditorView.js +++ b/src/code_manager/view/EditorView.js @@ -1,7 +1,8 @@ -var Backbone = require('backbone'); +import { template } from 'underscore'; +import Backbone from 'backbone'; module.exports = Backbone.View.extend({ - template: _.template(` + template: template(`
<%= label %>
diff --git a/src/commands/model/Command.js b/src/commands/model/Command.js index a6fcb3639c..8b17c4c337 100644 --- a/src/commands/model/Command.js +++ b/src/commands/model/Command.js @@ -1,4 +1,4 @@ -var Backbone = require('backbone'); +import Backbone from 'backbone'; module.exports = Backbone.Model.extend({ defaults: { diff --git a/src/commands/model/Commands.js b/src/commands/model/Commands.js index a2036bf9ba..0e6cd16863 100644 --- a/src/commands/model/Commands.js +++ b/src/commands/model/Commands.js @@ -1,4 +1,4 @@ -var Backbone = require('backbone'); +import Backbone from 'backbone'; var Command = require('./Command'); module.exports = Backbone.Collection.extend({ diff --git a/src/commands/view/CreateComponent.js b/src/commands/view/CreateComponent.js index 99438a2a5f..9778369d3d 100644 --- a/src/commands/view/CreateComponent.js +++ b/src/commands/view/CreateComponent.js @@ -1,3 +1,5 @@ +import _ from 'underscore'; +import Backbone from 'backbone'; const SelectPosition = require('./SelectPosition'); const $ = Backbone.$; diff --git a/src/commands/view/DeleteComponent.js b/src/commands/view/DeleteComponent.js index a023bbc621..f55d200dc4 100644 --- a/src/commands/view/DeleteComponent.js +++ b/src/commands/view/DeleteComponent.js @@ -1,3 +1,5 @@ +import _ from 'underscore'; +import Backbone from 'backbone'; const SelectComponent = require('./SelectComponent'); const $ = Backbone.$; diff --git a/src/commands/view/ExportTemplate.js b/src/commands/view/ExportTemplate.js index a5fda7243f..b9f22a86aa 100644 --- a/src/commands/view/ExportTemplate.js +++ b/src/commands/view/ExportTemplate.js @@ -1,3 +1,4 @@ +import Backbone from 'backbone'; const $ = Backbone.$; module.exports = { diff --git a/src/commands/view/ImageComponent.js b/src/commands/view/ImageComponent.js index f150195d5a..58df4fda5a 100644 --- a/src/commands/view/ImageComponent.js +++ b/src/commands/view/ImageComponent.js @@ -1,4 +1,5 @@ -var Backbone = require('backbone'); +import _ from 'underscore'; +import Backbone from 'backbone'; var InsertCustom = require('./InsertCustom'); module.exports = _.extend({}, InsertCustom, { diff --git a/src/commands/view/InsertCustom.js b/src/commands/view/InsertCustom.js index 9a3d61ef9e..b7751a282a 100644 --- a/src/commands/view/InsertCustom.js +++ b/src/commands/view/InsertCustom.js @@ -1,4 +1,5 @@ -var Backbone = require('backbone'); +import _ from 'underscore'; +import Backbone from 'backbone'; var CreateComponent = require('./CreateComponent'); module.exports = _.extend({}, CreateComponent, { diff --git a/src/commands/view/MoveComponent.js b/src/commands/view/MoveComponent.js index 219072acbf..d7cb093d73 100644 --- a/src/commands/view/MoveComponent.js +++ b/src/commands/view/MoveComponent.js @@ -1,3 +1,5 @@ +import _ from 'underscore'; +import Backbone from 'backbone'; import { on, off } from 'utils/mixins'; const SelectComponent = require('./SelectComponent'); diff --git a/src/commands/view/OpenLayers.js b/src/commands/view/OpenLayers.js index 08edfe68b7..9bca39724b 100644 --- a/src/commands/view/OpenLayers.js +++ b/src/commands/view/OpenLayers.js @@ -1,3 +1,4 @@ +import Backbone from 'backbone'; const Layers = require('navigator'); const $ = Backbone.$; diff --git a/src/commands/view/OpenStyleManager.js b/src/commands/view/OpenStyleManager.js index 87869a786d..1cdadd6565 100644 --- a/src/commands/view/OpenStyleManager.js +++ b/src/commands/view/OpenStyleManager.js @@ -1,5 +1,5 @@ +import Backbone from 'backbone'; const StyleManager = require('style_manager'); -const Backbone = require('backbone'); const $ = Backbone.$; module.exports = { diff --git a/src/commands/view/Preview.js b/src/commands/view/Preview.js index 4a878dc22e..7a3dddac50 100644 --- a/src/commands/view/Preview.js +++ b/src/commands/view/Preview.js @@ -1,3 +1,5 @@ +import _ from 'underscore'; + module.exports = { getPanels(editor) { if (!this.panels) this.panels = editor.Panels.getPanelsEl(); diff --git a/src/commands/view/SelectPosition.js b/src/commands/view/SelectPosition.js index 06f2f6a52d..c4b0d31ce8 100644 --- a/src/commands/view/SelectPosition.js +++ b/src/commands/view/SelectPosition.js @@ -1,3 +1,4 @@ +import Backbone from 'backbone'; const $ = Backbone.$; module.exports = { diff --git a/src/commands/view/ShowOffset.js b/src/commands/view/ShowOffset.js index b407092c8d..1965f90c97 100644 --- a/src/commands/view/ShowOffset.js +++ b/src/commands/view/ShowOffset.js @@ -1,3 +1,4 @@ +import Backbone from 'backbone'; const $ = Backbone.$; module.exports = { diff --git a/src/commands/view/TextComponent.js b/src/commands/view/TextComponent.js index aafc9589aa..dd573fbebd 100644 --- a/src/commands/view/TextComponent.js +++ b/src/commands/view/TextComponent.js @@ -1,4 +1,5 @@ -var Backbone = require('backbone'); +import _ from 'underscore'; +import Backbone from 'backbone'; var CreateComponent = require('./CreateComponent'); module.exports = _.extend({}, CreateComponent, { diff --git a/src/css_composer/model/CssRule.js b/src/css_composer/model/CssRule.js index 81d455dee5..1795649283 100644 --- a/src/css_composer/model/CssRule.js +++ b/src/css_composer/model/CssRule.js @@ -1,7 +1,8 @@ +import _ from 'underscore'; +import Backbone from 'backbone'; import Styleable from 'domain_abstract/model/Styleable'; import { isEmpty, forEach } from 'underscore'; -var Backbone = require('backbone'); var Selectors = require('selector_manager/model/Selectors'); module.exports = Backbone.Model.extend(Styleable).extend({ diff --git a/src/css_composer/model/CssRules.js b/src/css_composer/model/CssRules.js index 2d7ba138c3..15c4661e95 100644 --- a/src/css_composer/model/CssRules.js +++ b/src/css_composer/model/CssRules.js @@ -1,4 +1,4 @@ -var Backbone = require('backbone'); +import Backbone from 'backbone'; var CssRule = require('./CssRule'); module.exports = Backbone.Collection.extend({ diff --git a/src/device_manager/model/Device.js b/src/device_manager/model/Device.js index 123906f03e..5d3198083b 100644 --- a/src/device_manager/model/Device.js +++ b/src/device_manager/model/Device.js @@ -1,4 +1,4 @@ -var Backbone = require('backbone'); +import Backbone from 'backbone'; module.exports = Backbone.Model.extend({ idAttribute: 'name', diff --git a/src/device_manager/model/Devices.js b/src/device_manager/model/Devices.js index c6ced6ffba..a917b9338d 100644 --- a/src/device_manager/model/Devices.js +++ b/src/device_manager/model/Devices.js @@ -1,4 +1,4 @@ -var Backbone = require('backbone'); +import Backbone from 'backbone'; var Device = require('./Device'); module.exports = Backbone.Collection.extend({ diff --git a/src/utils/Dragger.js b/src/utils/Dragger.js index 9d28774d65..f366e5f840 100644 --- a/src/utils/Dragger.js +++ b/src/utils/Dragger.js @@ -1,3 +1,4 @@ +import Backbone from 'backbone'; const $ = Backbone.$; var getBoundingRect = (el, win) => { diff --git a/src/utils/Sorter.js b/src/utils/Sorter.js index 90318287d0..d910e4d220 100644 --- a/src/utils/Sorter.js +++ b/src/utils/Sorter.js @@ -1,3 +1,4 @@ +import Backbone from 'backbone'; import { isString, isFunction } from 'underscore'; import { on, off, matches } from 'utils/mixins'; const $ = Backbone.$; diff --git a/test/helper.js b/test/helper.js deleted file mode 100644 index 13207b510b..0000000000 --- a/test/helper.js +++ /dev/null @@ -1,49 +0,0 @@ -import _ from 'underscore'; -import sinon from 'sinon'; -import { JSDOM } from 'jsdom'; - -const dom = new JSDOM('', { - resources: 'usable' -}); -const window = dom.window; - -// Fix for the require of jquery -var Module = require('module'); -var originalRequire = Module.prototype.require; -Module.prototype.require = function(name) { - if (name == 'jquery') { - return originalRequire.call(this, 'cash-dom'); - } - return originalRequire.apply(this, arguments); -}; - -var localStorage = { - getItem(key) { - return this[key]; - }, - setItem(key, value) { - this[key] = value; - }, - removeItem(key, value) { - delete this[key]; - } -}; - -global.window = window; -global.document = window.document; -global.FormData = window.FormData; -global._ = _; -global.expect = expect; -global.sinon = sinon; -global.grapesjs = require('./../src'); -global.Backbone = require('backbone'); -global.localStorage = localStorage; -global.SVGElement = global.Element; -window.$ = Backbone.$; -global.navigator = { userAgent: 'node.js' }; - -Object.keys(window).forEach(key => { - if (!(key in global)) { - global[key] = window[key]; - } -}); diff --git a/test/setup.js b/test/setup.js new file mode 100644 index 0000000000..8253692c90 --- /dev/null +++ b/test/setup.js @@ -0,0 +1,23 @@ +import _ from 'underscore'; +import Backbone from 'backbone'; +import sinon from 'sinon'; +import grapesjs from './../src'; + +const localStorage = { + getItem(key) { + return this[key]; + }, + setItem(key, value) { + this[key] = value; + }, + removeItem(key, value) { + delete this[key]; + } +}; + +global.Backbone = Backbone; +global._ = _; +global.sinon = sinon; +global.grapesjs = grapesjs; +global.$ = Backbone.$; +global.localStorage = localStorage; diff --git a/test/specs/asset_manager/index.js b/test/specs/asset_manager/index.js index ebd0050a23..80c22d15f9 100644 --- a/test/specs/asset_manager/index.js +++ b/test/specs/asset_manager/index.js @@ -36,7 +36,7 @@ describe('Asset Manager', () => { }); test('Object exists', () => { - expect(obj).toExist(); + expect(obj).toBeTruthy(); }); test('No assets inside', () => { @@ -80,7 +80,7 @@ describe('Asset Manager', () => { test('Render assets', () => { obj.add(imgObj); - expect(obj.render()).toExist(); + expect(obj.render()).toBeTruthy(); }); describe('With storage', () => { diff --git a/test/specs/asset_manager/model/Asset.js b/test/specs/asset_manager/model/Asset.js index f65f5162bf..3c7c693a2d 100644 --- a/test/specs/asset_manager/model/Asset.js +++ b/test/specs/asset_manager/model/Asset.js @@ -4,15 +4,15 @@ module.exports = { run() { describe('Asset', () => { test('Object exists', () => { - expect(Asset).toExist(); + expect(Asset).toBeTruthy(); }); test('Has default values', () => { var obj = new Asset({}); - expect(obj.get('type')).toNotExist(); - expect(obj.get('src')).toNotExist(); - expect(obj.getExtension()).toNotExist(); - expect(obj.getFilename()).toNotExist(); + expect(obj.get('type')).toBeFalsy(); + expect(obj.get('src')).toBeFalsy(); + expect(obj.getExtension()).toBeFalsy(); + expect(obj.getFilename()).toBeFalsy(); }); test('Test getFilename', () => { diff --git a/test/specs/asset_manager/model/AssetImage.js b/test/specs/asset_manager/model/AssetImage.js index 81c9ebf8af..42818b5176 100644 --- a/test/specs/asset_manager/model/AssetImage.js +++ b/test/specs/asset_manager/model/AssetImage.js @@ -4,18 +4,18 @@ module.exports = { run() { describe('AssetImage', () => { test('Object exists', () => { - expect(AssetImage).toExist(); + expect(AssetImage).toBeTruthy(); }); test('Has default values', () => { var obj = new AssetImage({}); expect(obj.get('type')).toEqual('image'); - expect(obj.get('src')).toNotExist(); + expect(obj.get('src')).toBeFalsy(); expect(obj.get('unitDim')).toEqual('px'); expect(obj.get('height')).toEqual(0); expect(obj.get('width')).toEqual(0); - expect(obj.getExtension()).toNotExist(); - expect(obj.getFilename()).toNotExist(); + expect(obj.getExtension()).toBeFalsy(); + expect(obj.getFilename()).toBeFalsy(); }); }); } diff --git a/test/specs/asset_manager/model/Assets.js b/test/specs/asset_manager/model/Assets.js index 77d0553407..af4a976332 100644 --- a/test/specs/asset_manager/model/Assets.js +++ b/test/specs/asset_manager/model/Assets.js @@ -14,7 +14,7 @@ module.exports = { }); test('Object exists', () => { - expect(obj).toExist(); + expect(obj).toBeTruthy(); }); test('Collection is empty', () => { diff --git a/test/specs/asset_manager/view/AssetImageView.js b/test/specs/asset_manager/view/AssetImageView.js index 5919d035b1..c1ba792402 100644 --- a/test/specs/asset_manager/view/AssetImageView.js +++ b/test/specs/asset_manager/view/AssetImageView.js @@ -25,7 +25,7 @@ module.exports = { }); test('Object exists', () => { - expect(AssetImageView).toExist(); + expect(AssetImageView).toBeTruthy(); }); describe('Asset should be rendered correctly', () => { @@ -46,15 +46,15 @@ module.exports = { }); test('Could be selected', () => { - var spy = expect.spyOn(obj, 'updateTarget'); + var spy = jest.spyOn(obj, 'updateTarget'); obj.$el.trigger('click'); - expect(obj.$el.attr('class')).toInclude('highlight'); + expect(obj.$el.attr('class')).toContain('highlight'); expect(spy).toHaveBeenCalled(); }); test('Could be chosen', () => { sinon.stub(obj, 'updateTarget'); - var spy = expect.spyOn(obj, 'updateTarget'); + var spy = jest.spyOn(obj, 'updateTarget'); obj.$el.trigger('dblclick'); expect(spy).toHaveBeenCalled(); //obj.updateTarget.calledOnce.should.equal(true); diff --git a/test/specs/asset_manager/view/AssetView.js b/test/specs/asset_manager/view/AssetView.js index 3de289f0d7..9bb53359df 100644 --- a/test/specs/asset_manager/view/AssetView.js +++ b/test/specs/asset_manager/view/AssetView.js @@ -29,7 +29,7 @@ module.exports = { }); test('Object exists', () => { - expect(AssetView).toExist(); + expect(AssetView).toBeTruthy(); }); test('Has correct prefix', () => { diff --git a/test/specs/asset_manager/view/AssetsView.js b/test/specs/asset_manager/view/AssetsView.js index 31538716b3..9de3e628a4 100644 --- a/test/specs/asset_manager/view/AssetsView.js +++ b/test/specs/asset_manager/view/AssetsView.js @@ -27,11 +27,11 @@ module.exports = { }); test('Object exists', () => { - expect(AssetsView).toExist(); + expect(AssetsView).toBeTruthy(); }); test('Collection is empty', () => { - expect(obj.getAssetsEl().innerHTML).toNotExist(); + expect(obj.getAssetsEl().innerHTML).toBeFalsy(); }); test('Add new asset', () => { @@ -42,20 +42,20 @@ module.exports = { test('Render new asset', () => { coll.add({ src: 'test' }); - expect(obj.getAssetsEl().innerHTML).toExist(); + expect(obj.getAssetsEl().innerHTML).toBeTruthy(); }); test('Render correctly new image asset', () => { coll.add({ type: 'image', src: 'test' }); var asset = obj.getAssetsEl().firstChild; expect(asset.tagName).toEqual('DIV'); - expect(asset.innerHTML).toExist(); + expect(asset.innerHTML).toBeTruthy(); }); test('Clean collection from asset', () => { var model = coll.add({ src: 'test' }); coll.remove(model); - expect(obj.getAssetsEl().innerHTML).toNotExist(); + expect(obj.getAssetsEl().innerHTML).toBeFalsy(); }); test('Deselect works', () => { @@ -63,15 +63,15 @@ module.exports = { var $asset = obj.$el.children().first(); $asset.attr('class', obj.pfx + 'highlight'); coll.trigger('deselectAll'); - expect($asset.attr('class')).toNotExist(); + expect($asset.attr('class')).toBeFalsy(); }); test('Returns not empty assets element', () => { - expect(obj.getAssetsEl()).toExist(); + expect(obj.getAssetsEl()).toBeTruthy(); }); test('Returns not empty url input', () => { - expect(obj.getAddInput()).toExist(); + expect(obj.getAddInput()).toBeTruthy(); }); test('Add image asset from input string', () => { diff --git a/test/specs/asset_manager/view/FileUploader.js b/test/specs/asset_manager/view/FileUploader.js index 6680a3c780..20d72b3682 100644 --- a/test/specs/asset_manager/view/FileUploader.js +++ b/test/specs/asset_manager/view/FileUploader.js @@ -16,11 +16,11 @@ module.exports = { }); test('Object exists', () => { - expect(FileUploader).toExist(); + expect(FileUploader).toBeTruthy(); }); test('Has correct prefix', () => { - expect(obj.pfx).toNotExist(); + expect(obj.pfx).toBeFalsy(); }); describe('Should be rendered correctly', () => { diff --git a/test/specs/block_manager/index.js b/test/specs/block_manager/index.js index 04ff88f881..db4687df44 100644 --- a/test/specs/block_manager/index.js +++ b/test/specs/block_manager/index.js @@ -22,7 +22,7 @@ describe('BlockManager', () => { }); test('Object exists', () => { - expect(obj).toExist(); + expect(obj).toBeTruthy(); }); test('No blocks inside', () => { @@ -64,7 +64,7 @@ describe('BlockManager', () => { test('Render blocks', () => { obj.render(); - expect(obj.getContainer()).toExist(); + expect(obj.getContainer()).toBeTruthy(); }); }); diff --git a/test/specs/block_manager/view/BlocksView.js b/test/specs/block_manager/view/BlocksView.js index 59b6cddd3a..d0143872a6 100644 --- a/test/specs/block_manager/view/BlocksView.js +++ b/test/specs/block_manager/view/BlocksView.js @@ -24,7 +24,7 @@ module.exports = { }); test('The container is not empty', () => { - expect(view.el.outerHTML).toExist(); + expect(view.el.outerHTML).toBeTruthy(); }); test('No children inside', () => { diff --git a/test/specs/code_manager/index.js b/test/specs/code_manager/index.js index c2ba569733..78d74b11f2 100644 --- a/test/specs/code_manager/index.js +++ b/test/specs/code_manager/index.js @@ -14,7 +14,7 @@ describe('Code Manager', () => { }); test('Object exists', () => { - expect(CodeManager).toExist(); + expect(CodeManager).toBeTruthy(); }); test('No code generators inside', () => { diff --git a/test/specs/commands/index.js b/test/specs/commands/index.js index b9e45cdc2c..c5928d1d0d 100644 --- a/test/specs/commands/index.js +++ b/test/specs/commands/index.js @@ -15,7 +15,7 @@ describe('Commands', () => { }); test('No commands inside', () => { - expect(obj.get('test')).toEqual(null); + expect(obj.get('test')).toBeUndefined(); }); test('Push new command', () => { @@ -25,38 +25,38 @@ describe('Commands', () => { }); test('Load default commands at init', () => { - expect(obj.get('select-comp')).toNotEqual(null); - expect(obj.get('create-comp')).toNotEqual(null); - expect(obj.get('delete-comp')).toNotEqual(null); - expect(obj.get('image-comp')).toNotEqual(null); - expect(obj.get('move-comp')).toNotEqual(null); - expect(obj.get('text-comp')).toNotEqual(null); - expect(obj.get('insert-custom')).toNotEqual(null); - expect(obj.get('export-template')).toNotEqual(null); - expect(obj.get('sw-visibility')).toNotEqual(null); - expect(obj.get('open-layers')).toNotEqual(null); - expect(obj.get('open-sm')).toNotEqual(null); - expect(obj.get('open-tm')).toNotEqual(null); - expect(obj.get('open-blocks')).toNotEqual(null); - expect(obj.get('open-assets')).toNotEqual(null); - expect(obj.get('show-offset')).toNotEqual(null); - expect(obj.get('select-parent')).toNotEqual(null); - expect(obj.get('tlb-delete')).toNotEqual(null); - expect(obj.get('tlb-clone')).toNotEqual(null); - expect(obj.get('tlb-move')).toNotEqual(null); - expect(obj.get('fullscreen')).toNotEqual(null); - expect(obj.get('preview')).toNotEqual(null); - expect(obj.get('resize')).toNotEqual(null); - expect(obj.get('drag')).toNotEqual(null); + expect(obj.get('select-comp')).not.toBeUndefined(); + expect(obj.get('create-comp')).not.toBeUndefined(); + expect(obj.get('delete-comp')).not.toBeUndefined(); + expect(obj.get('image-comp')).not.toBeUndefined(); + expect(obj.get('move-comp')).not.toBeUndefined(); + expect(obj.get('text-comp')).not.toBeUndefined(); + expect(obj.get('insert-custom')).not.toBeUndefined(); + expect(obj.get('export-template')).not.toBeUndefined(); + expect(obj.get('sw-visibility')).not.toBeUndefined(); + expect(obj.get('open-layers')).not.toBeUndefined(); + expect(obj.get('open-sm')).not.toBeUndefined(); + expect(obj.get('open-tm')).not.toBeUndefined(); + expect(obj.get('open-blocks')).not.toBeUndefined(); + expect(obj.get('open-assets')).not.toBeUndefined(); + expect(obj.get('show-offset')).not.toBeUndefined(); + expect(obj.get('select-parent')).not.toBeUndefined(); + expect(obj.get('tlb-delete')).not.toBeUndefined(); + expect(obj.get('tlb-clone')).not.toBeUndefined(); + expect(obj.get('tlb-move')).not.toBeUndefined(); + expect(obj.get('fullscreen')).not.toBeUndefined(); + expect(obj.get('preview')).not.toBeUndefined(); + expect(obj.get('resize')).not.toBeUndefined(); + expect(obj.get('drag')).not.toBeUndefined(); }); test('Default commands after loadDefaultCommands', () => { obj.loadDefaultCommands(); - expect(obj.get('select-comp')).toNotEqual(null); + expect(obj.get('select-comp')).not.toBeUndefined(); }); test('Commands module should not have toLoad property', () => { - expect(obj.toLoad).toEqual(null); + expect(obj.toLoad).toBeUndefined(); }); }); }); diff --git a/test/specs/commands/model/CommandModels.js b/test/specs/commands/model/CommandModels.js index fccbab4956..485a7546a1 100644 --- a/test/specs/commands/model/CommandModels.js +++ b/test/specs/commands/model/CommandModels.js @@ -31,7 +31,7 @@ module.exports = { }); test('Object is ok', () => { - expect(obj).toExist(); + expect(obj).toBeTruthy(); }); }); } diff --git a/test/specs/css_composer/index.js b/test/specs/css_composer/index.js index d65b48fd17..0d1ef288d0 100644 --- a/test/specs/css_composer/index.js +++ b/test/specs/css_composer/index.js @@ -43,7 +43,7 @@ describe('Css Composer', () => { }); test('Object exists', () => { - expect(CssComposer).toExist(); + expect(CssComposer).toBeTruthy(); }); test('storageKey returns array', () => { @@ -163,7 +163,7 @@ describe('Css Composer', () => { }); test('Renders correctly', () => { - expect(obj.render()).toExist(); + expect(obj.render()).toBeTruthy(); }); test('Create a rule with id selector by using setIdRule()', () => { diff --git a/test/specs/css_composer/view/CssRuleView.js b/test/specs/css_composer/view/CssRuleView.js index d9b886796b..c0c2317406 100644 --- a/test/specs/css_composer/view/CssRuleView.js +++ b/test/specs/css_composer/view/CssRuleView.js @@ -22,7 +22,7 @@ module.exports = { }); test('Object exists', () => { - expect(CssRuleView).toExist(); + expect(CssRuleView).toBeTruthy(); }); test('Empty style inside', () => { diff --git a/test/specs/css_composer/view/CssRulesView.js b/test/specs/css_composer/view/CssRulesView.js index d547f74239..00eb1a828d 100644 --- a/test/specs/css_composer/view/CssRulesView.js +++ b/test/specs/css_composer/view/CssRulesView.js @@ -46,11 +46,11 @@ module.exports = { }); test('Object exists', () => { - expect(CssRulesView).toExist(); + expect(CssRulesView).toBeTruthy(); }); test('Collection is empty. Styles structure bootstraped', () => { - expect(obj.$el.html()).toExist(); + expect(obj.$el.html()).toBeTruthy(); const foundStylesContainers = obj.$el.find('div'); expect(foundStylesContainers.length).toEqual(devices.length); @@ -71,7 +71,7 @@ module.exports = { test('Add new rule', () => { sinon.stub(obj, 'addToCollection'); obj.collection.add({}); - expect(obj.addToCollection.calledOnce).toExist(true); + expect(obj.addToCollection.calledOnce).toBeTruthy(); }); test('Add correctly rules with different media queries', () => { @@ -100,7 +100,7 @@ module.exports = { test('Render new rule', () => { obj.collection.add({}); - expect(obj.$el.find(`#${prefix}`).html()).toExist(); + expect(obj.$el.find(`#${prefix}`).html()).toBeTruthy(); }); }); } diff --git a/test/specs/device_manager/index.js b/test/specs/device_manager/index.js index 91cf611030..b3b46d3b18 100644 --- a/test/specs/device_manager/index.js +++ b/test/specs/device_manager/index.js @@ -18,7 +18,7 @@ describe('DeviceManager', () => { }); test('Object exists', () => { - expect(obj).toExist(); + expect(obj).toBeTruthy(); }); test('No device inside', () => { @@ -55,7 +55,7 @@ describe('DeviceManager', () => { }); test('Render devices', () => { - expect(obj.render()).toExist(); + expect(obj.render()).toBeTruthy(); }); }); diff --git a/test/specs/device_manager/view/DevicesView.js b/test/specs/device_manager/view/DevicesView.js index 1e782f1a7c..a691a90d16 100644 --- a/test/specs/device_manager/view/DevicesView.js +++ b/test/specs/device_manager/view/DevicesView.js @@ -24,7 +24,7 @@ module.exports = { }); test('The content is not empty', () => { - expect(view.el.innerHTML).toExist(); + expect(view.el.innerHTML).toBeTruthy(); }); test('No options without devices', () => { @@ -33,7 +33,7 @@ module.exports = { test('Render new button', () => { view.collection.add({}); - expect(view.$el.html()).toExist(); + expect(view.$el.html()).toBeTruthy(); }); describe('With configs', () => { diff --git a/test/specs/dom_components/index.js b/test/specs/dom_components/index.js index 32abc9236c..c0c7d6fddd 100644 --- a/test/specs/dom_components/index.js +++ b/test/specs/dom_components/index.js @@ -59,7 +59,7 @@ describe('DOM Components', () => { }); test('Object exists', () => { - expect(DomComponents).toExist(); + expect(DomComponents).toBeTruthy(); }); test('storageKey returns array', () => { @@ -99,7 +99,7 @@ describe('DOM Components', () => { }); test('Wrapper exists', () => { - expect(obj.getWrapper()).toExist(); + expect(obj.getWrapper()).toBeTruthy(); }); test('No components inside', () => { @@ -117,7 +117,7 @@ describe('DOM Components', () => { }); test('Render wrapper', () => { - expect(obj.render()).toExist(); + expect(obj.render()).toBeTruthy(); }); test('Import propertly components and styles with the same ids', () => { diff --git a/test/specs/dom_components/model/Component.js b/test/specs/dom_components/model/Component.js index 6146ef074a..7bb5331fb5 100644 --- a/test/specs/dom_components/model/Component.js +++ b/test/specs/dom_components/model/Component.js @@ -350,7 +350,7 @@ module.exports = {
TEST
`); const notInhereted = model => { - expect(model.get('stop')).toEqual(1); + expect(model.get('stop')).toEqual('1'); expect(model.get('removable')).toEqual(true); expect(model.get('draggable')).toEqual(true); expect(model.get('propagate')).toEqual(['stop']); @@ -384,7 +384,7 @@ module.exports = { }); test('Not droppable', () => { - expect(obj.get('droppable')).toEqual(false); + expect(obj.get('droppable')).toEqual(0); }); test('ComponentImage toHTML', () => { diff --git a/test/specs/dom_components/view/ComponentImageView.js b/test/specs/dom_components/view/ComponentImageView.js index f6c64c9bb6..5bc402dd2c 100644 --- a/test/specs/dom_components/view/ComponentImageView.js +++ b/test/specs/dom_components/view/ComponentImageView.js @@ -35,7 +35,7 @@ module.exports = { }); test('Renders correctly', () => { - expect(view.render()).toExist(); + expect(view.render()).toBeTruthy(); }); }); } diff --git a/test/specs/dom_components/view/ComponentsView.js b/test/specs/dom_components/view/ComponentsView.js index 09fa94add7..114535cea6 100644 --- a/test/specs/dom_components/view/ComponentsView.js +++ b/test/specs/dom_components/view/ComponentsView.js @@ -31,7 +31,7 @@ module.exports = { }); test('Collection is empty', () => { - expect(view.$el.html()).toNotExist(); + expect(view.$el.html()).toBeFalsy(); }); test('Add new component', () => { @@ -42,7 +42,7 @@ module.exports = { test('Render new component', () => { view.collection.add({}); - expect(view.$el.html()).toExist(); + expect(view.$el.html()).toBeTruthy(); }); }); } diff --git a/test/specs/grapesjs/index.js b/test/specs/grapesjs/index.js index 90c4ac9c1c..c32241a06e 100644 --- a/test/specs/grapesjs/index.js +++ b/test/specs/grapesjs/index.js @@ -56,12 +56,12 @@ describe('GrapesJS', () => { }); test('Main object should be loaded', () => { - expect(obj).toExist(); + expect(obj).toBeTruthy(); }); test('Init new editor', () => { var editor = obj.init(config); - expect(editor).toExist(); + expect(editor).toBeTruthy(); }); test('Init new editor with node for container', () => { @@ -73,7 +73,7 @@ describe('GrapesJS', () => { } }; var editor = obj.init(configAlt); - expect(editor).toExist(); + expect(editor).toBeTruthy(); }); test('New editor is empty', () => { @@ -81,7 +81,7 @@ describe('GrapesJS', () => { var html = editor.getHtml(); //var css = editor.getCss(); var protCss = editor.getConfig().protectedCss; - expect(html ? html : '').toNotExist(); + expect(html ? html : '').toBeFalsy(); //expect((css ? css : '')).toEqual(protCss); expect(editor.getComponents().length).toEqual(0); expect(editor.getStyle().length).toEqual(0); @@ -94,12 +94,12 @@ describe('GrapesJS', () => { var editor = obj.init(config); - expect(window.frames[0].document.documentElement.outerHTML).toInclude( + expect(window.frames[0].document.documentElement.outerHTML).toContain( config.baseCss ); - expect(window.frames[0].document.documentElement.outerHTML) - .toNotInclude(`body { - margin: 0;`); + expect( + window.frames[0].document.documentElement.outerHTML.replace(/\s+/g, ` `) + ).not.toContain(`body { margin: 0;`); }); test('Editor canvas baseCSS defaults to sensible values if not defined', () => { @@ -108,9 +108,9 @@ describe('GrapesJS', () => { var editor = obj.init(config); - expect(window.frames[0].document.documentElement.outerHTML) - .toInclude(`body { - margin: 0;`); + expect( + window.frames[0].document.documentElement.outerHTML.replace(/\s+/g, ` `) + ).toContain(`body { margin: 0;`); }); test('Init editor with html', () => { @@ -352,7 +352,7 @@ describe('GrapesJS', () => { test('There is no active device', () => { var editor = obj.init(config); - expect(editor.getDevice()).toNotExist(); + expect(editor.getDevice()).toBeFalsy(); }); test('Active another device', () => { diff --git a/test/specs/keymaps/index.js b/test/specs/keymaps/index.js index ffeeee5e0a..85f7d954c8 100644 --- a/test/specs/keymaps/index.js +++ b/test/specs/keymaps/index.js @@ -12,7 +12,7 @@ describe('Keymaps', () => { }); test('Object exists', () => { - expect(obj).toExist(); + expect(obj).toBeTruthy(); }); test('No keymaps inside', () => { diff --git a/test/specs/modal/index.js b/test/specs/modal/index.js index 755953d3d8..9aec6ac958 100644 --- a/test/specs/modal/index.js +++ b/test/specs/modal/index.js @@ -14,7 +14,7 @@ describe('Modal dialog', () => { }); test('Object exists', () => { - expect(obj).toExist(); + expect(obj).toBeTruthy(); }); test('Is close by default', () => { diff --git a/test/specs/modal/view/ModalView.js b/test/specs/modal/view/ModalView.js index a6360553fd..2f9bdc7d9e 100644 --- a/test/specs/modal/view/ModalView.js +++ b/test/specs/modal/view/ModalView.js @@ -23,11 +23,11 @@ module.exports = { }); test('The content is not empty', () => { - expect(view.el.innerHTML).toExist(); + expect(view.el.innerHTML).toBeTruthy(); }); test('Get content', () => { - expect(view.getContent()).toExist(); + expect(view.getContent()).toBeTruthy(); }); test('Update content', () => { @@ -36,7 +36,7 @@ module.exports = { }); test('Get title', () => { - expect(view.getTitle()).toExist(); + expect(view.getTitle()).toBeTruthy(); }); test('Update title', () => { diff --git a/test/specs/panels/index.js b/test/specs/panels/index.js index 7b2693ccaf..4c2ea16149 100644 --- a/test/specs/panels/index.js +++ b/test/specs/panels/index.js @@ -19,7 +19,7 @@ describe('Panels', () => { }); test('Object exists', () => { - expect(obj).toExist(); + expect(obj).toBeTruthy(); }); test('No panels inside', () => { @@ -84,7 +84,7 @@ describe('Panels', () => { }); test('Renders correctly', () => { - expect(obj.render()).toExist(); + expect(obj.render()).toBeTruthy(); }); test('Active correctly activable buttons', () => { diff --git a/test/specs/panels/view/ButtonView.js b/test/specs/panels/view/ButtonView.js index 7fca871085..cdb2849cca 100644 --- a/test/specs/panels/view/ButtonView.js +++ b/test/specs/panels/view/ButtonView.js @@ -85,7 +85,7 @@ module.exports = { }); test('Renders correctly', () => { - expect(view.render()).toExist(); + expect(view.render()).toBeTruthy(); }); }); } diff --git a/test/specs/panels/view/ButtonsView.js b/test/specs/panels/view/ButtonsView.js index a60be38e15..5acf712de7 100644 --- a/test/specs/panels/view/ButtonsView.js +++ b/test/specs/panels/view/ButtonsView.js @@ -34,7 +34,7 @@ module.exports = { test('Render new button', () => { view.collection.add({}); - expect(view.$el.html()).toExist(); + expect(view.$el.html()).toBeTruthy(); }); }); } diff --git a/test/specs/panels/view/PanelsView.js b/test/specs/panels/view/PanelsView.js index 001192c11a..9fc64e8471 100644 --- a/test/specs/panels/view/PanelsView.js +++ b/test/specs/panels/view/PanelsView.js @@ -35,7 +35,7 @@ module.exports = { test('Render new panel', () => { view.collection.add({}); - expect(view.$el.html()).toExist(); + expect(view.$el.html()).toBeTruthy(); }); }); } diff --git a/test/specs/plugin_manager/index.js b/test/specs/plugin_manager/index.js index cd50f4a7c2..6e660aa8a5 100644 --- a/test/specs/plugin_manager/index.js +++ b/test/specs/plugin_manager/index.js @@ -17,7 +17,7 @@ describe('PluginManager', () => { }); test('Object exists', () => { - expect(obj).toExist(); + expect(obj).toBeTruthy(); }); test('No plugins inside', () => { @@ -26,7 +26,7 @@ describe('PluginManager', () => { test('Add new plugin', () => { obj.add('test', testPlugin); - expect(obj.get('test')).toExist(); + expect(obj.get('test')).toBeTruthy(); }); test('Added plugin is working', () => { diff --git a/test/specs/selector_manager/index.js b/test/specs/selector_manager/index.js index c90fbb72ae..adb86bc29d 100644 --- a/test/specs/selector_manager/index.js +++ b/test/specs/selector_manager/index.js @@ -21,7 +21,7 @@ describe('SelectorManager', () => { }); test('Object exists', () => { - expect(obj).toExist(); + expect(obj).toBeTruthy(); }); test('No selectors inside', () => { diff --git a/test/specs/selector_manager/view/ClassTagView.js b/test/specs/selector_manager/view/ClassTagView.js index 6d63affa92..95427b3b41 100644 --- a/test/specs/selector_manager/view/ClassTagView.js +++ b/test/specs/selector_manager/view/ClassTagView.js @@ -33,12 +33,12 @@ module.exports = { }); test('Object exists', () => { - expect(ClassTagView).toExist(); + expect(ClassTagView).toBeTruthy(); }); test('Not empty', () => { var $el = obj.$el; - expect($el.html()).toExist(); + expect($el.html()).toBeTruthy(); }); test('Not empty', () => { @@ -49,21 +49,21 @@ module.exports = { describe('Should be rendered correctly', () => { test('Has close button', () => { var $el = obj.$el; - expect($el.find('#close')[0]).toExist(); + expect($el.find('#close')[0]).toBeTruthy(); }); test('Has checkbox', () => { var $el = obj.$el; - expect($el.find('#checkbox')[0]).toExist(); + expect($el.find('#checkbox')[0]).toBeTruthy(); }); test('Has label', () => { var $el = obj.$el; - expect($el.find('#tag-label')[0]).toExist(); + expect($el.find('#tag-label')[0]).toBeTruthy(); }); }); test('Could be removed', () => { obj.$el.find('#close').trigger('click'); - setTimeout(() => expect(fixtures.innerHTML).toNotExist(), 0); + setTimeout(() => expect(fixtures.innerHTML).toBeFalsy(), 5); }); test('Checkbox toggles status', () => { @@ -76,7 +76,7 @@ module.exports = { }); test('Label input is disabled', () => { - expect(obj.getInputEl().contentEditable).toNotEqual(true); + expect(obj.getInputEl().contentEditable).toBeFalsy(); }); test('On double click label input is enable', () => { diff --git a/test/specs/selector_manager/view/ClassTagsView.js b/test/specs/selector_manager/view/ClassTagsView.js index 0161f4628f..cf8aec7314 100644 --- a/test/specs/selector_manager/view/ClassTagsView.js +++ b/test/specs/selector_manager/view/ClassTagsView.js @@ -64,7 +64,7 @@ module.exports = { }); test('Object exists', () => { - expect(ClassTagsView).toExist(); + expect(ClassTagsView).toBeTruthy(); }); test('Not tags inside', () => { @@ -80,14 +80,14 @@ module.exports = { test('Start new tag creation', () => { testContext.btnAdd.trigger('click'); expect(testContext.btnAdd.css('display')).toEqual('none'); - expect(testContext.input.css('display')).toNotEqual('none'); + expect(testContext.input.css('display')).not.toEqual('none'); }); test('Stop tag creation', () => { testContext.btnAdd.trigger('click'); testContext.input.val('test'); testContext.input.trigger('blur'); - expect(testContext.btnAdd.css('display')).toNotEqual('none'); + expect(testContext.btnAdd.css('display')).not.toEqual('none'); expect(testContext.input.css('display')).toEqual('none'); expect(testContext.input.val()).toEqual(null); }); @@ -193,16 +193,16 @@ module.exports = { describe('Should be rendered correctly', () => { test('Has label', () => { - expect(view.$el.find('#label')[0]).toExist(); + expect(view.$el.find('#label')[0]).toBeTruthy(); }); test('Has tags container', () => { - expect(view.$el.find('#tags-c')[0]).toExist(); + expect(view.$el.find('#tags-c')[0]).toBeTruthy(); }); test('Has add button', () => { - expect(view.$el.find('#add-tag')[0]).toExist(); + expect(view.$el.find('#add-tag')[0]).toBeTruthy(); }); test('Has states input', () => { - expect(view.$el.find('#states')[0]).toExist(); + expect(view.$el.find('#states')[0]).toBeTruthy(); }); }); }); diff --git a/test/specs/storage_manager/index.js b/test/specs/storage_manager/index.js index 8f2f19c233..f34a63e201 100644 --- a/test/specs/storage_manager/index.js +++ b/test/specs/storage_manager/index.js @@ -14,7 +14,7 @@ describe('Storage Manager', () => { }); test('Object exists', () => { - expect(StorageManager).toExist(); + expect(StorageManager).toBeTruthy(); }); test('Autosave is active by default', () => { @@ -50,14 +50,14 @@ describe('Storage Manager', () => { }); test('Store do not execute if empty', () => { - expect(obj.store({ item: 'test' })).toEqual(null); + expect(obj.store({ item: 'test' })).toBeUndefined(); }); test('Load default storages ', () => { obj.loadDefaultProviders(); - expect(obj.get('local')).toExist(); - expect(obj.get('remote')).toExist(); - expect(obj.get('test')).toNotExist(); + expect(obj.get('local')).toBeTruthy(); + expect(obj.get('remote')).toBeTruthy(); + expect(obj.get('test')).toBeFalsy(); }); describe('With custom storage', () => { diff --git a/test/specs/style_manager/index.js b/test/specs/style_manager/index.js index d00b505851..d1feb2cce5 100644 --- a/test/specs/style_manager/index.js +++ b/test/specs/style_manager/index.js @@ -26,7 +26,7 @@ describe('StyleManager', () => { }); test('Object exists', () => { - expect(obj).toExist(); + expect(obj).toBeTruthy(); }); test('No sectors', () => { @@ -72,7 +72,7 @@ describe('StyleManager', () => { test('Add property', () => { obj.addSector('test', {}); - expect(obj.addProperty('test', {})).toExist(); + expect(obj.addProperty('test', {})).toBeTruthy(); expect(obj.getProperties('test').length).toEqual(1); }); @@ -122,7 +122,7 @@ describe('StyleManager', () => { }); test('Renders correctly', () => { - expect(obj.render()).toExist(); + expect(obj.render()).toBeTruthy(); }); describe('Init with configuration', () => { diff --git a/test/specs/style_manager/model/Models.js b/test/specs/style_manager/model/Models.js index d67d089a19..7acb2b1a33 100644 --- a/test/specs/style_manager/model/Models.js +++ b/test/specs/style_manager/model/Models.js @@ -124,7 +124,7 @@ module.exports = { }); test('Object exists', () => { - expect(obj).toExist(); + expect(obj).toBeTruthy(); }); }); @@ -213,7 +213,7 @@ module.exports = { }); test('Object exists', () => { - expect(obj).toExist(); + expect(obj).toBeTruthy(); }); }); @@ -277,7 +277,7 @@ module.exports = { }); test('Object exists', () => { - expect(obj).toExist(); + expect(obj).toBeTruthy(); }); test('Init index on add', () => { @@ -333,7 +333,7 @@ module.exports = { }); test('Object exists', () => { - expect(obj).toExist(); + expect(obj).toBeTruthy(); }); test('Build single prop', () => { diff --git a/test/specs/style_manager/view/LayerView.js b/test/specs/style_manager/view/LayerView.js index 78faab131a..e402470a6f 100644 --- a/test/specs/style_manager/view/LayerView.js +++ b/test/specs/style_manager/view/LayerView.js @@ -29,11 +29,11 @@ module.exports = { test('Rendered correctly', () => { var layer = view.el; - expect(fixtures.querySelector('.layer')).toExist(); - expect(layer.querySelector('#label')).toExist(); - expect(layer.querySelector('#close-layer')).toExist(); - expect(view.getPropertiesWrapper()).toExist(); - expect(view.getPreviewEl()).toExist(); + expect(fixtures.querySelector('.layer')).toBeTruthy(); + expect(layer.querySelector('#label')).toBeTruthy(); + expect(layer.querySelector('#close-layer')).toBeTruthy(); + expect(view.getPropertiesWrapper()).toBeTruthy(); + expect(view.getPreviewEl()).toBeTruthy(); }); test('Is not active by default', () => { @@ -52,7 +52,7 @@ module.exports = { test('No preview', () => { var style = view.el.querySelector('#preview').style; - expect(style.cssText).toNotExist(); + expect(style.cssText).toBeFalsy(); }); }); } diff --git a/test/specs/style_manager/view/PropertyColorView.js b/test/specs/style_manager/view/PropertyColorView.js index 0ae0ac6199..5c9e62c17a 100644 --- a/test/specs/style_manager/view/PropertyColorView.js +++ b/test/specs/style_manager/view/PropertyColorView.js @@ -60,24 +60,24 @@ module.exports = { test('Rendered correctly', () => { var prop = view.el; - expect(fixtures.querySelector('.property')).toExist(); - expect(prop.querySelector('.label')).toExist(); - expect(prop.querySelector('.field')).toExist(); + expect(fixtures.querySelector('.property')).toBeTruthy(); + expect(prop.querySelector('.label')).toBeTruthy(); + expect(prop.querySelector('.field')).toBeTruthy(); }); test('Inputs rendered', () => { var prop = view.el; - expect(prop.querySelector('input[type=text]')).toExist(); + expect(prop.querySelector('input[type=text]')).toBeTruthy(); }); test('Inputs should exist', () => { - expect(view.$input).toExist(); - expect(view.$color).toExist(); + expect(view.$input).toBeTruthy(); + expect(view.$color).toBeTruthy(); }); test('Input value is empty', () => { - expect(view.model.get('value')).toNotExist(); - expect(view.getInputValue()).toNotExist(); + expect(view.model.get('value')).toBeFalsy(); + expect(view.getInputValue()).toBeFalsy(); }); test('Update model on setValue', () => { diff --git a/test/specs/style_manager/view/PropertyCompositeView.js b/test/specs/style_manager/view/PropertyCompositeView.js index 5bfc33941c..5b962dcfed 100644 --- a/test/specs/style_manager/view/PropertyCompositeView.js +++ b/test/specs/style_manager/view/PropertyCompositeView.js @@ -66,14 +66,14 @@ module.exports = { test('Rendered correctly', () => { var prop = view.el; - expect(fixtures.querySelector('.property')).toExist(); - expect(prop.querySelector('.label')).toExist(); - expect(prop.querySelector('.field')).toExist(); + expect(fixtures.querySelector('.property')).toBeTruthy(); + expect(prop.querySelector('.label')).toBeTruthy(); + expect(prop.querySelector('.field')).toBeTruthy(); }); test('Properties rendered', () => { var prop = view.el; - expect(prop.querySelector('.properties')).toExist(); + expect(prop.querySelector('.properties')).toBeTruthy(); }); test('Properties rendered correctly', () => { @@ -85,7 +85,7 @@ module.exports = { }); test('Props should exist', () => { - expect(view.$props).toExist(); + expect(view.$props).toBeTruthy(); }); test('Input value is empty', () => { @@ -206,7 +206,7 @@ module.exports = { component.set('style', style); expect(view.valueOnIndex(2)).toEqual('value3'); expect(view.valueOnIndex(0)).toEqual('value1'); - expect(view.valueOnIndex(4)).toEqual(null); + expect(view.valueOnIndex(4)).toEqual(undefined); }); test('Build value from properties', () => { diff --git a/test/specs/style_manager/view/PropertyIntegerView.js b/test/specs/style_manager/view/PropertyIntegerView.js index edc7c2b091..7b87db1577 100644 --- a/test/specs/style_manager/view/PropertyIntegerView.js +++ b/test/specs/style_manager/view/PropertyIntegerView.js @@ -61,15 +61,15 @@ module.exports = { test('Rendered correctly', () => { var prop = view.el; - expect(fixtures.querySelector('.property')).toExist(); - expect(prop.querySelector('.label')).toExist(); - expect(prop.querySelector('.field')).toExist(); + expect(fixtures.querySelector('.property')).toBeTruthy(); + expect(prop.querySelector('.label')).toBeTruthy(); + expect(prop.querySelector('.field')).toBeTruthy(); }); test('Inputs rendered', () => { var prop = view.el; - expect(prop.querySelector('input[type=text]')).toExist(); - expect(prop.querySelector(unitsElSel)).toExist(); + expect(prop.querySelector('input[type=text]')).toBeTruthy(); + expect(prop.querySelector(unitsElSel)).toBeTruthy(); }); test('Units rendered', () => { @@ -85,12 +85,12 @@ module.exports = { }); test('Inputs should exist', () => { - expect(view.input).toExist(); - expect(view.unit).toExist(); + expect(view.input).toBeTruthy(); + expect(view.unit).toBeTruthy(); }); test('Input value is empty', () => { - expect(view.model.get('value')).toNotExist(); + expect(view.model.get('value')).toBeFalsy(); }); test('Update model on setValue', () => { diff --git a/test/specs/style_manager/view/PropertyRadioView.js b/test/specs/style_manager/view/PropertyRadioView.js index acea7f6367..36d07dae5e 100644 --- a/test/specs/style_manager/view/PropertyRadioView.js +++ b/test/specs/style_manager/view/PropertyRadioView.js @@ -63,14 +63,14 @@ module.exports = { test('Rendered correctly', () => { var prop = view.el; - expect(fixtures.querySelector('.property')).toExist(); - expect(prop.querySelector('.label')).toExist(); - expect(prop.querySelector('.field')).toExist(); + expect(fixtures.querySelector('.property')).toBeTruthy(); + expect(prop.querySelector('.label')).toBeTruthy(); + expect(prop.querySelector('.field')).toBeTruthy(); }); test('Radio rendered', () => { var prop = view.el; - expect(prop.querySelector('input[type=radio]')).toExist(); + expect(prop.querySelector('input[type=radio]')).toBeTruthy(); }); test('Options rendered', () => { @@ -99,11 +99,11 @@ module.exports = { }); test('Input should exist', () => { - expect(view.input).toExist(); + expect(view.input).toBeTruthy(); }); test('Input value is empty', () => { - expect(view.model.get('value')).toNotExist(); + expect(view.model.get('value')).toBeFalsy(); }); test('Update model on input change', () => { diff --git a/test/specs/style_manager/view/PropertySelectView.js b/test/specs/style_manager/view/PropertySelectView.js index 86d8a339e9..f0417e8676 100644 --- a/test/specs/style_manager/view/PropertySelectView.js +++ b/test/specs/style_manager/view/PropertySelectView.js @@ -58,14 +58,14 @@ module.exports = { test('Rendered correctly', () => { var prop = view.el; - expect(fixtures.querySelector('.property')).toExist(); - expect(prop.querySelector('.label')).toExist(); - expect(prop.querySelector('.field')).toExist(); + expect(fixtures.querySelector('.property')).toBeTruthy(); + expect(prop.querySelector('.label')).toBeTruthy(); + expect(prop.querySelector('.field')).toBeTruthy(); }); test('Select rendered', () => { var prop = view.el; - expect(prop.querySelector('select')).toExist(); + expect(prop.querySelector('select')).toBeTruthy(); }); test('Options rendered', () => { @@ -85,11 +85,11 @@ module.exports = { }); test('Input should exist', () => { - expect(view.input).toExist(); + expect(view.input).toBeTruthy(); }); test('Input value is empty', () => { - expect(view.model.get('value')).toNotExist(); + expect(view.model.get('value')).toBeFalsy(); }); test('Update model on input change', () => { diff --git a/test/specs/style_manager/view/PropertyStackView.js b/test/specs/style_manager/view/PropertyStackView.js index 90501f98d5..07fcbd3ffe 100644 --- a/test/specs/style_manager/view/PropertyStackView.js +++ b/test/specs/style_manager/view/PropertyStackView.js @@ -68,18 +68,18 @@ module.exports = { test('Rendered correctly', () => { var prop = view.el; - expect(fixtures.querySelector('.property')).toExist(); - expect(prop.querySelector('.label')).toExist(); - expect(prop.querySelector('.field')).toExist(); - expect(prop.querySelector('#add')).toExist(); + expect(fixtures.querySelector('.property')).toBeTruthy(); + expect(prop.querySelector('.label')).toBeTruthy(); + expect(prop.querySelector('.field')).toBeTruthy(); + expect(prop.querySelector('#add')).toBeTruthy(); }); test('Layers rendered', () => { - expect(view.el.querySelector('.layers')).toExist(); + expect(view.el.querySelector('.layers')).toBeTruthy(); }); test('Layers wrapper should exist', () => { - expect(view.el.querySelector('[data-layers-wrapper]')).toExist(); + expect(view.el.querySelector('[data-layers-wrapper]')).toBeTruthy(); }); test('Layers rendered correctly', () => { @@ -93,7 +93,7 @@ module.exports = { test('Layers container is empty', () => { var layers = view.el.querySelector('.layers'); - expect(layers.innerHTML).toNotExist(); + expect(layers.innerHTML).toBeFalsy(); }); describe('With layers', () => { diff --git a/test/specs/style_manager/view/PropertyView.js b/test/specs/style_manager/view/PropertyView.js index c3b5ea1613..38a0f4b641 100644 --- a/test/specs/style_manager/view/PropertyView.js +++ b/test/specs/style_manager/view/PropertyView.js @@ -51,23 +51,23 @@ module.exports = { test('Rendered correctly', () => { var prop = view.el; - expect(fixtures.querySelector('.property')).toExist(); - expect(prop.querySelector('.label')).toExist(); - expect(prop.querySelector('.field')).toExist(); + expect(fixtures.querySelector('.property')).toBeTruthy(); + expect(prop.querySelector('.label')).toBeTruthy(); + expect(prop.querySelector('.field')).toBeTruthy(); }); test('Input should exist', () => { - expect(view.getInputEl()).toExist(); + expect(view.getInputEl()).toBeTruthy(); }); test('Input value is empty', () => { - expect(view.model.get('value')).toNotExist(); - expect(view.getInputValue()).toNotExist(); + expect(view.model.get('value')).toBeFalsy(); + expect(view.getInputValue()).toBeFalsy(); }); test('Model not change without update trigger', () => { view.getInputEl().value = propValue; - expect(view.model.get('value')).toNotExist(); + expect(view.model.get('value')).toBeFalsy(); }); // Tests inputValueChanged() @@ -120,7 +120,7 @@ module.exports = { }); test('Target style is empty without values', () => { - expect(view.getTargetValue()).toNotExist(); + expect(view.getTargetValue()).toBeFalsy(); }); test('Target style is correct', () => { @@ -134,7 +134,7 @@ module.exports = { var style = {}; style[propName + '2'] = propValue; component.set('style', style); - expect(view.getTargetValue()).toNotExist(); + expect(view.getTargetValue()).toBeFalsy(); }); test('Fetch value from function', () => { diff --git a/test/specs/style_manager/view/SectorView.js b/test/specs/style_manager/view/SectorView.js index ab9dc15464..781fbe79c9 100644 --- a/test/specs/style_manager/view/SectorView.js +++ b/test/specs/style_manager/view/SectorView.js @@ -24,9 +24,9 @@ module.exports = { test('Rendered correctly', () => { var sector = view.el; - expect(sector.querySelector('.title')).toExist(); + expect(sector.querySelector('.title')).toBeTruthy(); var props = sector.querySelector('.properties'); - expect(props).toExist(); + expect(props).toBeTruthy(); expect(sector.classList.contains('open')).toEqual(true); }); @@ -76,7 +76,7 @@ module.exports = { expect(sector.querySelector('.title').innerHTML).toContain( 'TestName' ); - expect(props).toExist(); + expect(props).toBeTruthy(); expect(sector.classList.contains('open')).toEqual(false); expect(props.style.display).toEqual('none'); }); diff --git a/test/specs/trait_manager/model/TraitsModel.js b/test/specs/trait_manager/model/TraitsModel.js index 75b0b15cdb..54aa37eac9 100644 --- a/test/specs/trait_manager/model/TraitsModel.js +++ b/test/specs/trait_manager/model/TraitsModel.js @@ -21,7 +21,7 @@ module.exports = { }); test('Object exists', () => { - expect(Trait).toExist(); + expect(Trait).toBeTruthy(); }); }); } diff --git a/test/specs/trait_manager/view/TraitsView.js b/test/specs/trait_manager/view/TraitsView.js index 55969efbf0..f830d05576 100644 --- a/test/specs/trait_manager/view/TraitsView.js +++ b/test/specs/trait_manager/view/TraitsView.js @@ -28,7 +28,7 @@ module.exports = { }); test('Object exists', () => { - expect(Trait).toExist(); + expect(Trait).toBeTruthy(); }); test('Target has no attributes on init', () => {