From fdcfc8a2534cbc044df639ac99bb7edae177429e Mon Sep 17 00:00:00 2001
From: JFH <20402845+jfhenon@users.noreply.github.com>
Date: Tue, 28 Dec 2021 11:02:29 -0300
Subject: [PATCH] move to standard linter for simpler configuration
---
.eslintignore | 30 -
.eslintrc.js | 96 -
.gitignore | 1 -
.npmignore | 1 -
cypress/integration/ui/clipboard.js | 68 +-
cypress/integration/ui/control-points.js | 26 +-
cypress/integration/ui/export.js | 22 +-
cypress/integration/ui/issues/issue-359.js | 20 +-
cypress/integration/ui/issues/issue-407.js | 26 +-
cypress/integration/ui/issues/issue-408.js | 22 +-
cypress/integration/ui/issues/issue-423.js | 20 +-
cypress/integration/ui/issues/issue-660.js | 26 +-
cypress/integration/ui/key-commands.js | 12 +-
cypress/integration/ui/scenario.js | 222 +-
cypress/integration/ui/scenario1.js | 48 +-
cypress/integration/ui/scenario2.js | 136 +-
cypress/integration/ui/scenario3.js | 82 +-
cypress/integration/ui/scenario4.js | 190 +-
cypress/integration/ui/scenario5.js | 174 +-
cypress/integration/ui/scenario6.js | 162 +-
cypress/integration/ui/scenario7.js | 162 +-
cypress/integration/ui/tool-selection.js | 14 +-
.../browser-bugs/removeItem-setAttribute.js | 14 +-
cypress/integration/unit/contextmenu.js | 46 +-
cypress/integration/unit/coords.js | 336 +-
cypress/integration/unit/draw.js | 958 ++--
cypress/integration/unit/history.js | 719 +--
cypress/integration/unit/math.js | 156 +-
cypress/integration/unit/path.js | 242 +-
cypress/integration/unit/recalculate.js | 173 +-
cypress/integration/unit/sanitize.js | 22 +-
cypress/integration/unit/select.js | 146 +-
cypress/integration/unit/test1.js | 212 +-
cypress/integration/unit/units.js | 120 +-
cypress/integration/unit/utilities-bbox.js | 573 +--
.../integration/unit/utilities-performance.js | 172 +-
cypress/integration/unit/utilities.js | 346 +-
cypress/plugins/index.js | 8 +-
cypress/plugins/main.js | 36 +-
cypress/support/assert-almostEquals.js | 16 +-
cypress/support/assert-close.js | 66 +-
.../assert-expectOutOfBoundsException.js | 22 +-
cypress/support/assertion-wrapper.js | 12 +-
cypress/support/commands.js | 18 +-
cypress/support/index.js | 8 +-
cypress/support/ui-test-helper.js | 28 +-
demos/canvas.html | 39 +-
docs/jsdoc-config.js | 6 +-
docs/tutorials/ConfigOptions.md | 16 +-
docs/tutorials/Events.md | 10 +-
docs/tutorials/ExtensionDocs.md | 16 +-
docs/versions/3.0.0.md | 2 +-
nyc.config.js | 18 +-
package-lock.json | 4403 ++++++++---------
package.json | 58 +-
rollup.config.js | 86 +-
src/common/browser.js | 52 +-
src/common/units.js | 144 +-
src/editor/ConfigObj.js | 166 +-
src/editor/Editor.js | 862 ++--
src/editor/EditorStartup.js | 704 ++-
src/editor/MainMenu.js | 315 +-
src/editor/Rulers.js | 229 +-
src/editor/browser-not-supported.js | 8 +-
src/editor/components/PaintBox.js | 151 +-
src/editor/components/index.js | 29 +-
.../components/jgraduate/ColorValuePicker.js | 552 +--
src/editor/components/jgraduate/Slider.js | 326 +-
src/editor/components/jgraduate/Util.js | 165 +-
.../components/jgraduate/jQuery.jGraduate.js | 1132 +++--
.../components/jgraduate/jQuery.jPicker.js | 1828 +++----
src/editor/components/jgraduate/paint.js | 78 +-
src/editor/components/seButton.js | 148 +-
src/editor/components/seColorPicker.js | 131 +-
src/editor/components/seDropdown.js | 94 +-
src/editor/components/seExplorerButton.js | 226 +-
src/editor/components/seFlyingButton.js | 189 +-
src/editor/components/seInput.js | 112 +-
src/editor/components/seList.js | 135 +-
src/editor/components/seListItem.js | 87 +-
src/editor/components/seMenu.js | 63 +-
src/editor/components/seMenuItem.js | 84 +-
src/editor/components/sePalette.js | 67 +-
src/editor/components/sePlainBorderButton.js | 14 +-
src/editor/components/sePlainMenuButton.js | 10 +-
src/editor/components/seSelect.js | 155 +-
src/editor/components/seSpinInput.js | 162 +-
src/editor/components/seText.js | 76 +-
src/editor/components/seZoom.js | 96 +-
src/editor/contextmenu.js | 38 +-
src/editor/dialogs/SePlainAlertDialog.js | 18 +-
src/editor/dialogs/cmenuDialog.js | 290 +-
src/editor/dialogs/cmenuLayersDialog.js | 153 +-
src/editor/dialogs/editorPreferencesDialog.js | 426 +-
src/editor/dialogs/exportDialog.js | 143 +-
src/editor/dialogs/imagePropertiesDialog.js | 401 +-
src/editor/dialogs/index.js | 22 +-
.../dialogs/se-elix/define/NumberSpinBox.js | 5 +-
.../dialogs/se-elix/src/base/NumberSpinBox.js | 93 +-
.../se-elix/src/plain/PlainNumberSpinBox.js | 6 +-
src/editor/dialogs/seAlertDialog.js | 14 +-
src/editor/dialogs/seConfirmDialog.js | 18 +-
src/editor/dialogs/sePromptDialog.js | 62 +-
src/editor/dialogs/seSelectDialog.js | 18 +-
src/editor/dialogs/svgSourceDialog.js | 191 +-
.../ext-eyedropper/ext-eyedropper.js | 138 +-
.../extensions/ext-eyedropper/locale/en.js | 2 +-
.../extensions/ext-eyedropper/locale/fr.js | 2 +-
.../extensions/ext-eyedropper/locale/zh-CN.js | 2 +-
src/editor/extensions/ext-grid/ext-grid.js | 177 +-
src/editor/extensions/ext-grid/locale/en.js | 2 +-
src/editor/extensions/ext-grid/locale/fr.js | 2 +-
.../extensions/ext-grid/locale/zh-CN.js | 2 +-
.../ext-helloworld/ext-helloworld.js | 60 +-
.../extensions/ext-helloworld/locale/en.js | 2 +-
.../extensions/ext-helloworld/locale/fr.js | 2 +-
.../extensions/ext-helloworld/locale/zh-CN.js | 2 +-
.../extensions/ext-imagelib/ext-imagelib.js | 626 ++-
src/editor/extensions/ext-imagelib/index.js | 54 +-
.../extensions/ext-imagelib/locale/de.js | 2 +-
.../extensions/ext-imagelib/locale/en.js | 2 +-
.../extensions/ext-imagelib/locale/fr.js | 2 +-
.../extensions/ext-imagelib/locale/pl.js | 2 +-
.../extensions/ext-imagelib/locale/pt-BR.js | 2 +-
.../extensions/ext-imagelib/locale/ro.js | 2 +-
.../extensions/ext-imagelib/locale/sk.js | 2 +-
.../extensions/ext-imagelib/locale/sl.js | 2 +-
.../extensions/ext-imagelib/locale/zh-CN.js | 2 +-
.../extensions/ext-imagelib/openclipart.js | 457 +-
.../extensions/ext-markers/ext-markers.js | 287 +-
.../extensions/ext-markers/locale/en.js | 2 +-
.../extensions/ext-markers/locale/zh-CN.js | 2 +-
.../extensions/ext-opensave/ext-opensave.js | 263 +-
.../extensions/ext-opensave/locale/en.js | 2 +-
.../extensions/ext-opensave/locale/fr.js | 2 +-
.../extensions/ext-opensave/locale/zh-CN.js | 2 +-
.../ext-overview_window/dragmove/dragmove.js | 90 +-
.../ext-overview_window.js | 179 +-
.../extensions/ext-panning/ext-panning.js | 70 +-
.../extensions/ext-panning/locale/en.js | 2 +-
.../extensions/ext-panning/locale/zh-CN.js | 2 +-
.../extensions/ext-polystar/ext-polystar.js | 508 +-
.../extensions/ext-polystar/locale/en.js | 2 +-
.../extensions/ext-polystar/locale/fr.js | 2 +-
.../extensions/ext-polystar/locale/zh-CN.js | 2 +-
.../extensions/ext-shapes/ext-shapes.js | 153 +-
src/editor/extensions/ext-shapes/locale/en.js | 2 +-
src/editor/extensions/ext-shapes/locale/fr.js | 2 +-
.../extensions/ext-shapes/locale/zh-CN.js | 2 +-
.../extensions/ext-storage/ext-storage.js | 130 +-
.../extensions/ext-storage/locale/de.js | 2 +-
.../extensions/ext-storage/locale/en.js | 2 +-
.../extensions/ext-storage/locale/fr.js | 2 +-
.../extensions/ext-storage/locale/zh-CN.js | 2 +-
.../extensions/ext-storage/storageDialog.js | 176 +-
src/editor/index.html | 26 +-
src/editor/locale.js | 25 +-
src/editor/locale/lang.af.js | 4 +-
src/editor/locale/lang.ar.js | 4 +-
src/editor/locale/lang.az.js | 4 +-
src/editor/locale/lang.be.js | 4 +-
src/editor/locale/lang.bg.js | 4 +-
src/editor/locale/lang.ca.js | 4 +-
src/editor/locale/lang.cs.js | 4 +-
src/editor/locale/lang.cy.js | 4 +-
src/editor/locale/lang.da.js | 4 +-
src/editor/locale/lang.de.js | 4 +-
src/editor/locale/lang.el.js | 4 +-
src/editor/locale/lang.en.js | 2 +-
src/editor/locale/lang.es.js | 4 +-
src/editor/locale/lang.et.js | 2 +-
src/editor/locale/lang.fa.js | 2 +-
src/editor/locale/lang.fi.js | 2 +-
src/editor/locale/lang.fr.js | 2 +-
src/editor/locale/lang.fy.js | 2 +-
src/editor/locale/lang.ga.js | 2 +-
src/editor/locale/lang.gl.js | 2 +-
src/editor/locale/lang.he.js | 2 +-
src/editor/locale/lang.hi.js | 2 +-
src/editor/locale/lang.hr.js | 2 +-
src/editor/locale/lang.hu.js | 2 +-
src/editor/locale/lang.hy.js | 2 +-
src/editor/locale/lang.id.js | 2 +-
src/editor/locale/lang.is.js | 2 +-
src/editor/locale/lang.it.js | 2 +-
src/editor/locale/lang.ja.js | 2 +-
src/editor/locale/lang.ko.js | 2 +-
src/editor/locale/lang.lt.js | 2 +-
src/editor/locale/lang.lv.js | 2 +-
src/editor/locale/lang.mk.js | 2 +-
src/editor/locale/lang.ms.js | 2 +-
src/editor/locale/lang.mt.js | 2 +-
src/editor/locale/lang.nl.js | 2 +-
src/editor/locale/lang.no.js | 2 +-
src/editor/locale/lang.pl.js | 2 +-
src/editor/locale/lang.pt-BR.js | 2 +-
src/editor/locale/lang.pt-PT.js | 2 +-
src/editor/locale/lang.ro.js | 2 +-
src/editor/locale/lang.ru.js | 2 +-
src/editor/locale/lang.sk.js | 2 +-
src/editor/locale/lang.sl.js | 2 +-
src/editor/locale/lang.sq.js | 2 +-
src/editor/locale/lang.sr.js | 2 +-
src/editor/locale/lang.sv.js | 2 +-
src/editor/locale/lang.sw.js | 2 +-
src/editor/locale/lang.test.js | 2 +-
src/editor/locale/lang.th.js | 2 +-
src/editor/locale/lang.tl.js | 2 +-
src/editor/locale/lang.tr.js | 2 +-
src/editor/locale/lang.uk.js | 2 +-
src/editor/locale/lang.vi.js | 2 +-
src/editor/locale/lang.yi.js | 2 +-
src/editor/locale/lang.zh-CN.js | 2 +-
src/editor/locale/lang.zh-HK.js | 2 +-
src/editor/locale/lang.zh-TW.js | 2 +-
src/editor/panels/BottomPanel.js | 182 +-
src/editor/panels/LayersPanel.js | 374 +-
src/editor/panels/LeftPanel.js | 165 +-
src/editor/panels/TopPanel.js | 954 ++--
src/editor/touch.js | 35 +-
src/svgcanvas/blur-event.js | 116 +-
src/svgcanvas/clear.js | 45 +-
src/svgcanvas/coords.js | 442 +-
src/svgcanvas/copy-elem.js | 46 +-
src/svgcanvas/dataStorage.js | 18 +-
src/svgcanvas/draw.js | 608 +--
src/svgcanvas/elem-get-set.js | 706 +--
src/svgcanvas/event.js | 1981 ++++----
src/svgcanvas/history.js | 288 +-
src/svgcanvas/historyrecording.js | 66 +-
src/svgcanvas/jQuery.attr.js | 44 +-
src/svgcanvas/json.js | 58 +-
src/svgcanvas/layer.js | 107 +-
src/svgcanvas/math.js | 114 +-
src/svgcanvas/namespaces.js | 14 +-
src/svgcanvas/paste-elem.js | 96 +-
src/svgcanvas/path-actions.js | 1102 ++---
src/svgcanvas/path-method.js | 762 +--
src/svgcanvas/path.js | 625 +--
src/svgcanvas/recalculate.js | 728 +--
src/svgcanvas/sanitize.js | 246 +-
src/svgcanvas/select.js | 358 +-
src/svgcanvas/selected-elem.js | 869 ++--
src/svgcanvas/selection.js | 292 +-
src/svgcanvas/svg-exec.js | 934 ++--
src/svgcanvas/svgcanvas.js | 1078 ++--
src/svgcanvas/svgroot.js | 8 +-
src/svgcanvas/text-actions.js | 343 +-
src/svgcanvas/undo.js | 194 +-
src/svgcanvas/utilities.js | 883 ++--
web-dev-server.config.mjs | 34 +-
251 files changed, 19760 insertions(+), 19935 deletions(-)
delete mode 100644 .eslintignore
delete mode 100644 .eslintrc.js
diff --git a/.eslintignore b/.eslintignore
deleted file mode 100644
index 40a0b115..00000000
--- a/.eslintignore
+++ /dev/null
@@ -1,30 +0,0 @@
-node_modules
-ignore
-
-coverage
-instrumented
-dist
-docs/jsdoc
-archive
-
-jsconfig.json
-releases
-!.eslintrc.js
-!.ncurc.js
-
-es-dev-server.config.js
-nyc.config.js
-
-svgedit-custom.css
-
-# Vendor/minified files
-src/editor/jquery.min.js
-
-# Previously minified though exporting
-src/editor/js-hotkeys
-
-src/editor/extensions/ext-mathjax/mathjax
-
-# jquery files
-src/editor/jgraduate/jQuery.jPicker.js
-
diff --git a/.eslintrc.js b/.eslintrc.js
deleted file mode 100644
index e6096b1b..00000000
--- a/.eslintrc.js
+++ /dev/null
@@ -1,96 +0,0 @@
-"use strict";
-
-module.exports = {
- extends: [
- "plugin:compat/recommended",
- "plugin:node/recommended",
- "plugin:no-unsanitized/DOM",
- "plugin:promise/recommended",
- "plugin:import/errors",
- "plugin:markdown/recommended",
- "eslint:recommended"
- ],
- plugins: [ "jsdoc", "promise", "html", "import" ],
- parserOptions: {
- ecmaVersion: 2020,
- sourceType: "module"
- },
- env: {
- browser: true,
- es6: true
- },
- rules: {
- /** @todo len should probably more 120-150 */
- "max-len": [ "warn", { "code": 250 } ],
- "indent": [ "error", 2 ],
- "no-var": "error",
- /** @todo this rule should be actived. needs some courage as this rule is broken in many places... */
- "one-var": [ "error", "never" ],
- /** @todo jsdoc should be made warn or error */
- "valid-jsdoc": "off",
- /** @todo no param reassign creates too many warnings but should be a warning */
- "no-param-reassign": "off",
- /** @todo no use before define creates too many warnings but should be a warning */
- "no-use-before-define": "off",
- /** @todo camel case creates too many warnings but should be a warning */
- "camelcase": "off",
- "comma-dangle": [ "error" ],
- "node/no-unsupported-features/es-syntax": 0,
- "no-unused-vars": [ "error", { "argsIgnorePattern": "^_" } ],
- "semi" : "error",
- "prefer-const": "error",
- "no-trailing-spaces": "error",
- "array-bracket-spacing": [ "error", "always" ],
- "comma-spacing": "error",
- "object-curly-spacing": [ "error", "always" ],
- "no-console": [
- "warn",
- { "allow": [ "warn", "error", "info", "table" ] }
- ],
- "arrow-parens": [ "error", "always" ]
- },
- overrides: [
- {
- files: [ 'cypress/**/*' ],
- extends: [
- "plugin:cypress/recommended"
- ],
- env: {
- mocha: true,
- node: true
- },
- globals: { "assert": true },
- rules: {
- // with ci, instrumented is not created before linter
- "import/no-unresolved": [ 2, { ignore: [ 'instrumented' ] } ],
- "node/no-missing-import": 0,
- "node/no-unpublished-import": 0,
- "node/no-unpublished-require": 0
- }
- },
- {
- files: [ 'docs/**/*' ],
- rules: { // md files have example that don't need a strict checking
- "no-undef": 0,
- "import/no-unresolved": 0,
- "node/no-missing-import": 0,
- "jsdoc/check-examples": [
- "warn",
- {
- rejectExampleCodeRegex: "^`",
- checkDefaults: true,
- checkParams: true,
- checkProperties: true
- }
- ]
- }
- },
- {
- files: [ 'src/editor/locale/*.js' ],
- rules: { // lang files may have long length
- "max-len": "off",
- "camelcase": "off"
- }
- }
- ]
-};
diff --git a/.gitignore b/.gitignore
index c4f8ddb0..9c68b054 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,7 +9,6 @@ coverage
instrumented
.nyc_output
.vscode
-.eslintcache
.DS_Store
.idea
dist
diff --git a/.npmignore b/.npmignore
index dbd7ab3e..b3fd8eec 100644
--- a/.npmignore
+++ b/.npmignore
@@ -2,5 +2,4 @@ lgtm.yml
coverage/**
.nyc_output
instrumented/**
-.eslintcache
node_modules/**
diff --git a/cypress/integration/ui/clipboard.js b/cypress/integration/ui/clipboard.js
index 26d423b6..ae6b062e 100644
--- a/cypress/integration/ui/clipboard.js
+++ b/cypress/integration/ui/clipboard.js
@@ -1,14 +1,14 @@
import {
visitAndApproveStorage
-} from '../../support/ui-test-helper.js';
+} from '../../support/ui-test-helper.js'
describe('UI - Clipboard', function () {
beforeEach(() => {
- visitAndApproveStorage();
- });
+ visitAndApproveStorage()
+ })
it('Editor - Copy and paste', () => {
- cy.get('#tool_source').click();
+ cy.get('#tool_source').click()
cy.get('#svg_source_textarea')
.type('{selectall}', { force: true })
@@ -17,47 +17,47 @@ describe('UI - Clipboard', function () {
Layer 1
- `, { force: true, parseSpecialCharSequences: false });
- cy.get('#tool_source_save').click();
- cy.get('#testCircle').should('exist');
- cy.get('#svg_1').should('not.exist');
- cy.get('#svg_2').should('not.exist');
+ `, { force: true, parseSpecialCharSequences: false })
+ cy.get('#tool_source_save').click()
+ cy.get('#testCircle').should('exist')
+ cy.get('#svg_1').should('not.exist')
+ cy.get('#svg_2').should('not.exist')
// Copy.
- cy.get('#testCircle').click().rightclick();
- cy.get('#cmenu_canvas a[href="#copy"]').click({ force: true });
+ cy.get('#testCircle').click().rightclick()
+ cy.get('#cmenu_canvas a[href="#copy"]').click({ force: true })
// Paste.
// Scrollbars fail to recenter in Cypress test. Works fine in reality.
// Thus forcing click is needed since workspace is mostly offscreen.
- cy.get('#svgroot').rightclick({ force: true });
- cy.get('#cmenu_canvas a[href="#paste"]').click({ force: true });
- cy.get('#testCircle').should('exist');
- cy.get('#svg_1').should('exist');
- cy.get('#svg_2').should('not.exist');
+ cy.get('#svgroot').rightclick({ force: true })
+ cy.get('#cmenu_canvas a[href="#paste"]').click({ force: true })
+ cy.get('#testCircle').should('exist')
+ cy.get('#svg_1').should('exist')
+ cy.get('#svg_2').should('not.exist')
// Cut.
- cy.get('#testCircle').click().rightclick();
- cy.get('#cmenu_canvas a[href="#cut"]').click({ force: true });
- cy.get('#testCircle').should('not.exist');
- cy.get('#svg_1').should('exist');
- cy.get('#svg_2').should('not.exist');
+ cy.get('#testCircle').click().rightclick()
+ cy.get('#cmenu_canvas a[href="#cut"]').click({ force: true })
+ cy.get('#testCircle').should('not.exist')
+ cy.get('#svg_1').should('exist')
+ cy.get('#svg_2').should('not.exist')
// Paste.
// Scrollbars fail to recenter in Cypress test. Works fine in reality.
// Thus forcing click is needed since workspace is mostly offscreen.
- cy.get('#svgroot').rightclick({ force: true });
- cy.get('#cmenu_canvas a[href="#paste"]').click({ force: true });
- cy.get('#testCircle').should('not.exist');
- cy.get('#svg_1').should('exist');
- cy.get('#svg_2').should('exist');
+ cy.get('#svgroot').rightclick({ force: true })
+ cy.get('#cmenu_canvas a[href="#paste"]').click({ force: true })
+ cy.get('#testCircle').should('not.exist')
+ cy.get('#svg_1').should('exist')
+ cy.get('#svg_2').should('exist')
// Delete.
- cy.get('#svg_2').click().rightclick();
- cy.get('#cmenu_canvas a[href="#delete"]').click({ force: true });
- cy.get('#svg_1').click().rightclick();
- cy.get('#cmenu_canvas a[href="#delete"]').click({ force: true });
- cy.get('#svg_1').should('not.exist');
- cy.get('#svg_2').should('not.exist');
- });
-});
+ cy.get('#svg_2').click().rightclick()
+ cy.get('#cmenu_canvas a[href="#delete"]').click({ force: true })
+ cy.get('#svg_1').click().rightclick()
+ cy.get('#cmenu_canvas a[href="#delete"]').click({ force: true })
+ cy.get('#svg_1').should('not.exist')
+ cy.get('#svg_2').should('not.exist')
+ })
+})
diff --git a/cypress/integration/ui/control-points.js b/cypress/integration/ui/control-points.js
index 0dcc6c3c..be8efd7c 100644
--- a/cypress/integration/ui/control-points.js
+++ b/cypress/integration/ui/control-points.js
@@ -1,15 +1,15 @@
import {
visitAndApproveStorage
-} from '../../support/ui-test-helper.js';
+} from '../../support/ui-test-helper.js'
describe('UI - Control Points', function () {
beforeEach(() => {
- visitAndApproveStorage();
- });
+ visitAndApproveStorage()
+ })
it('Editor - No parameters: Drag control point of arc path', () => {
- const randomOffset = () => 2 + Math.round(10 + Math.random() * 40);
- cy.get('#tool_source').click();
+ const randomOffset = () => 2 + Math.round(10 + Math.random() * 40)
+ cy.get('#tool_source').click()
cy.get('#svg_source_textarea')
.type('{selectall}', { force: true })
.type(``, { force: true, parseSpecialCharSequences: false });
- cy.get('#tool_source_save').click({ force: true });
+ `, { force: true, parseSpecialCharSequences: false })
+ cy.get('#tool_source_save').click({ force: true })
- cy.get('#svg_1').click({ force: true }).click({ force: true });
+ cy.get('#svg_1').click({ force: true }).click({ force: true })
cy.get('#pathpointgrip_0').trigger('mousedown', { which: 1, force: true })
.trigger('mousemove', randomOffset(), randomOffset(), { force: true })
- .trigger('mouseup', { force: true });
+ .trigger('mouseup', { force: true })
cy.get('#pathpointgrip_1').trigger('mousedown', { which: 1, force: true })
.trigger('mousemove', randomOffset(), randomOffset(), { force: true })
- .trigger('mouseup', { force: true });
+ .trigger('mouseup', { force: true })
- cy.get('#svg_1[d]').should('not.contain', 'NaN');
- });
-});
+ cy.get('#svg_1[d]').should('not.contain', 'NaN')
+ })
+})
diff --git a/cypress/integration/ui/export.js b/cypress/integration/ui/export.js
index f77877c8..128a5f83 100644
--- a/cypress/integration/ui/export.js
+++ b/cypress/integration/ui/export.js
@@ -1,20 +1,20 @@
import {
visitAndApproveStorage, openMainMenu
-} from '../../support/ui-test-helper.js';
+} from '../../support/ui-test-helper.js'
describe('UI - Export tests', function () {
beforeEach(() => {
- visitAndApproveStorage();
- });
+ visitAndApproveStorage()
+ })
it('Editor - No parameters: Has export button', () => {
- openMainMenu();
- cy.get('#tool_export');
- });
+ openMainMenu()
+ cy.get('#tool_export')
+ })
it('Editor - No parameters: Export button clicking; dialog opens', () => {
- openMainMenu();
- cy.get('#tool_export').click({ force: true });
- cy.get('#dialog_content select');
- });
-});
+ openMainMenu()
+ cy.get('#tool_export').click({ force: true })
+ cy.get('#dialog_content select')
+ })
+})
diff --git a/cypress/integration/ui/issues/issue-359.js b/cypress/integration/ui/issues/issue-359.js
index d93fb5b9..df448c22 100644
--- a/cypress/integration/ui/issues/issue-359.js
+++ b/cypress/integration/ui/issues/issue-359.js
@@ -1,15 +1,15 @@
import {
visitAndApproveStorage
-} from '../../../support/ui-test-helper.js';
+} from '../../../support/ui-test-helper.js'
// See https://github.com/SVG-Edit/svgedit/issues/359
describe('Fix issue 359', function () {
beforeEach(() => {
- visitAndApproveStorage();
- });
+ visitAndApproveStorage()
+ })
it('can undo without throwing', function () {
- cy.get('#tool_source').click();
+ cy.get('#tool_source').click()
cy.get('#svg_source_textarea')
.type('{selectall}', { force: true })
.type(``, { parseSpecialCharSequences: false, force: true });
- cy.get('#tool_source_save').click();
- cy.get('#tool_undo').click();
- cy.get('#tool_redo').click(); // test also redo to make the test more comprehensive
+ `, { parseSpecialCharSequences: false, force: true })
+ cy.get('#tool_source_save').click()
+ cy.get('#tool_undo').click()
+ cy.get('#tool_redo').click() // test also redo to make the test more comprehensive
// if the undo throws an error to the console, the test will fail
- });
-});
+ })
+})
diff --git a/cypress/integration/ui/issues/issue-407.js b/cypress/integration/ui/issues/issue-407.js
index a7597aed..fe39c12f 100644
--- a/cypress/integration/ui/issues/issue-407.js
+++ b/cypress/integration/ui/issues/issue-407.js
@@ -1,15 +1,15 @@
import {
visitAndApproveStorage
-} from '../../../support/ui-test-helper.js';
+} from '../../../support/ui-test-helper.js'
// See https://github.com/SVG-Edit/svgedit/issues/407
describe('Fix issue 407', function () {
beforeEach(() => {
- visitAndApproveStorage();
- });
+ visitAndApproveStorage()
+ })
it('can enter edit on text child', function () {
- cy.get('#tool_source').click();
+ cy.get('#tool_source').click()
cy.get('#svg_source_textarea')
.type('{selectall}', { force: true })
.type(``, { force: true, parseSpecialCharSequences: false });
- cy.get('#tool_source_save').click();
- cy.get('#svg_1').click().dblclick();
- cy.get('#a_text').should('exist');
+ `, { force: true, parseSpecialCharSequences: false })
+ cy.get('#tool_source_save').click()
+ cy.get('#svg_1').click().dblclick()
+ cy.get('#a_text').should('exist')
cy.get('#a_text')
.trigger('mousedown', { which: 1, force: true })
.trigger('mouseup', { force: true })
- .dblclick({ force: true });
+ .dblclick({ force: true })
// svgedit use the #text text field to capture the text
- cy.get('#text').type('1234', { force: true });
- cy.get('#a_text').should('have.text', 'he1234llo');
- });
-});
+ cy.get('#text').type('1234', { force: true })
+ cy.get('#a_text').should('have.text', 'he1234llo')
+ })
+})
diff --git a/cypress/integration/ui/issues/issue-408.js b/cypress/integration/ui/issues/issue-408.js
index fdf1bb32..36df34a7 100644
--- a/cypress/integration/ui/issues/issue-408.js
+++ b/cypress/integration/ui/issues/issue-408.js
@@ -1,15 +1,15 @@
import {
visitAndApproveStorage
-} from '../../../support/ui-test-helper.js';
+} from '../../../support/ui-test-helper.js'
// See https://github.com/SVG-Edit/svgedit/issues/408
describe('Fix issue 408', function () {
beforeEach(() => {
- visitAndApproveStorage();
- });
+ visitAndApproveStorage()
+ })
it('should not throw when showing/saving svg content', function () {
- cy.get('#tool_source').click();
+ cy.get('#tool_source').click()
cy.get('#svg_source_textarea')
.type('{selectall}', { force: true })
.type(``, { force: true, parseSpecialCharSequences: false });
- cy.get('#tool_source_save').click();
- cy.get('#svg_6').click().dblclick(); // change context
- cy.get('#tool_source').click(); // reopen tool_source
- cy.get('#tool_source_save').should('exist'); // The save button should be here if it does not throw
- });
-});
+ `, { force: true, parseSpecialCharSequences: false })
+ cy.get('#tool_source_save').click()
+ cy.get('#svg_6').click().dblclick() // change context
+ cy.get('#tool_source').click() // reopen tool_source
+ cy.get('#tool_source_save').should('exist') // The save button should be here if it does not throw
+ })
+})
diff --git a/cypress/integration/ui/issues/issue-423.js b/cypress/integration/ui/issues/issue-423.js
index 6ab956fc..1de97313 100644
--- a/cypress/integration/ui/issues/issue-423.js
+++ b/cypress/integration/ui/issues/issue-423.js
@@ -1,15 +1,15 @@
import {
visitAndApproveStorage
-} from '../../../support/ui-test-helper.js';
+} from '../../../support/ui-test-helper.js'
// See https://github.com/SVG-Edit/svgedit/issues/423
describe('Fix issue 423', function () {
beforeEach(() => {
- visitAndApproveStorage();
- });
+ visitAndApproveStorage()
+ })
it('should not throw when undoing the move', function () {
- cy.get('#tool_source').click();
+ cy.get('#tool_source').click()
cy.get('#svg_source_textarea')
.type('{selectall}', { force: true })
.type(``, { parseSpecialCharSequences: false, force: true });
- cy.get('#tool_source_save').click({ force: true });
+ `, { parseSpecialCharSequences: false, force: true })
+ cy.get('#tool_source_save').click({ force: true })
cy.get('#TANK1')
.trigger('mousedown', { force: true })
.trigger('mousemove', 50, 0, { force: true })
- .trigger('mouseup', { force: true });
- cy.get('#tool_undo').click({ force: true });
- });
-});
+ .trigger('mouseup', { force: true })
+ cy.get('#tool_undo').click({ force: true })
+ })
+})
diff --git a/cypress/integration/ui/issues/issue-660.js b/cypress/integration/ui/issues/issue-660.js
index 3eeefc21..0f4a3694 100644
--- a/cypress/integration/ui/issues/issue-660.js
+++ b/cypress/integration/ui/issues/issue-660.js
@@ -1,16 +1,16 @@
import {
visitAndApproveStorage
-} from '../../../support/ui-test-helper.js';
+} from '../../../support/ui-test-helper.js'
// See https://github.com/SVG-Edit/svgedit/issues/660
describe('Fix issue 660', function () {
beforeEach(() => {
- visitAndApproveStorage();
- cy.viewport(512, 512);
- });
+ visitAndApproveStorage()
+ cy.viewport(512, 512)
+ })
/** @todo: reenable this test when we understand why it is passing locally but not on ci */
it.skip('can resize text', function () {
- cy.get('#tool_source').click();
+ cy.get('#tool_source').click()
cy.get('#svg_source_textarea')
.type('{selectall}', { force: true })
.type(``, { force: true, parseSpecialCharSequences: false });
- cy.get('#tool_source_save').click({ force: true });
- cy.get('#a_text').should('exist');
+ `, { force: true, parseSpecialCharSequences: false })
+ cy.get('#tool_source_save').click({ force: true })
+ cy.get('#a_text').should('exist')
cy.get('#a_text')
.trigger('mousedown', { which: 1, force: true })
- .trigger('mouseup', { force: true });
+ .trigger('mouseup', { force: true })
cy.get('#selectorGrip_resize_s')
.trigger('mousedown', { which: 1, force: true })
.trigger('mousemove', { clientX: 0, clientY: 600 })
- .trigger('mouseup', { force: true });
+ .trigger('mouseup', { force: true })
// svgedit use the #text text field to capture the text
cy.get('#a_text').should('have.attr', 'transform')
- .and('equal', 'matrix(1 0 0 4.54639 0 -540.825)'); // Chrome 96 is matrix(1 0 0 4.17431 0 -325.367)
- });
-});
+ .and('equal', 'matrix(1 0 0 4.54639 0 -540.825)') // Chrome 96 is matrix(1 0 0 4.17431 0 -325.367)
+ })
+})
diff --git a/cypress/integration/ui/key-commands.js b/cypress/integration/ui/key-commands.js
index 9c00fcc3..9ae6ff7c 100644
--- a/cypress/integration/ui/key-commands.js
+++ b/cypress/integration/ui/key-commands.js
@@ -1,14 +1,14 @@
import {
visitAndApproveStorage
-} from '../../support/ui-test-helper.js';
+} from '../../support/ui-test-helper.js'
// See https://github.com/SVG-Edit/svgedit/issues/364
describe('Key commands', function () {
beforeEach(() => {
- visitAndApproveStorage();
- });
+ visitAndApproveStorage()
+ })
it.skip('cmd-A on empty canvas should not cause an error', function () {
- cy.get('body').type('{cmd}a');
- });
-});
+ cy.get('body').type('{cmd}a')
+ })
+})
diff --git a/cypress/integration/ui/scenario.js b/cypress/integration/ui/scenario.js
index 4a0c23f7..a768e44b 100644
--- a/cypress/integration/ui/scenario.js
+++ b/cypress/integration/ui/scenario.js
@@ -1,190 +1,188 @@
import {
visitAndApproveStorage
-} from '../../support/ui-test-helper.js';
+} from '../../support/ui-test-helper.js'
const testSnapshot = () => {
- cy.get('#svgcontent').cleanSnapshot();
-};
+ cy.get('#svgcontent').cleanSnapshot()
+}
describe('use various parts of svg-edit', function () {
before(() => {
- visitAndApproveStorage();
- });
+ visitAndApproveStorage()
+ })
it('check tool_source', function () {
- cy.get('#tool_source').click({ force: true });
+ cy.get('#tool_source').click({ force: true })
cy.get('#svg_source_textarea')
.type('{selectall}', { force: true })
.type(``, { force: true, parseSpecialCharSequences: false });
- cy.get('#tool_source_save').click({ force: true });
- testSnapshot();
- });
+ `, { force: true, parseSpecialCharSequences: false })
+ cy.get('#tool_source_save').click({ force: true })
+ testSnapshot()
+ })
it('check tool_fhpath', function () {
cy.get('#tool_fhpath')
- .click({ force: true });
+ .click({ force: true })
cy.get('#svgcontent')
.trigger('mousemove', 200, 200, { force: true })
.trigger('mousedown', 200, 200, { force: true })
.trigger('mousemove', 20, 20, { force: true })
- .trigger('mouseup', { force: true });
- testSnapshot();
- });
+ .trigger('mouseup', { force: true })
+ testSnapshot()
+ })
it('check tool_text', function () {
cy.get('#tool_text')
- .click({ force: true });
+ .click({ force: true })
cy.get('#svgcontent')
- .trigger('mousedown', 46, 35, { force: true })
- .trigger('mouseup', { force: true });
+ .trigger('mousedown', 46, 35, { force: true })
+ .trigger('mouseup', { force: true })
// svgedit use the #text text field to capture the text
- cy.get('#text').type('AB', { force: true });
- testSnapshot();
- });
+ cy.get('#text').type('AB', { force: true })
+ testSnapshot()
+ })
it('check tool_clone', function () {
- cy.get('#svg_1').click({ force: true });
+ cy.get('#svg_1').click({ force: true })
cy.get('#tool_clone')
- .click({ force: true });
- testSnapshot();
- });
+ .click({ force: true })
+ testSnapshot()
+ })
it('check tool_italic', function () {
- cy.get('#svg_1').click({ force: true });
+ cy.get('#svg_1').click({ force: true })
cy.get('#tool_italic')
- .click({ force: true });
- // eslint-disable-next-line cypress/no-unnecessary-waiting
- cy.wait(500);
- testSnapshot();
- });
+ .click({ force: true })
+ testSnapshot()
+ })
it('check tool_bold', function () {
- cy.get('#svg_1').click({ force: true });
+ cy.get('#svg_1').click({ force: true })
cy.get('#tool_bold')
- .click({ force: true });
- testSnapshot();
- });
+ .click({ force: true })
+ testSnapshot()
+ })
it('check tool_text_change_x_y_coordinate', function () {
- cy.get('#svg_2').click({ force: true });
- for(let n = 0; n < 25; n ++){
+ cy.get('#svg_2').click({ force: true })
+ for (let n = 0; n < 25; n++) {
cy.get('#selected_x').shadow().find('elix-number-spin-box').eq(0).shadow().find('#upButton').eq(0)
- .click({ force: true });
+ .click({ force: true })
}
- for(let n = 0; n < 25; n ++){
+ for (let n = 0; n < 25; n++) {
cy.get('#selected_y').shadow().find('elix-number-spin-box').eq(0).shadow().find('#upButton').eq(0)
- .click({ force: true });
+ .click({ force: true })
}
- testSnapshot();
- });
+ testSnapshot()
+ })
it('check tool_text_change_font_size', function () {
- cy.get('#svg_1').click({ force: true });
- for(let n = 0; n < 10; n ++){
+ cy.get('#svg_1').click({ force: true })
+ for (let n = 0; n < 10; n++) {
cy.get('#font_size').shadow().find('elix-number-spin-box').eq(0).shadow().find('#upButton').eq(0)
- .click({ force: true });
+ .click({ force: true })
}
- testSnapshot();
- });
+ testSnapshot()
+ })
it('check tool_text_change_stroke_width', function () {
- cy.get('#svg_1').click({ force: true });
+ cy.get('#svg_1').click({ force: true })
cy.get('#stroke_width').shadow().find('elix-number-spin-box').eq(0).shadow().find('#upButton').eq(0)
- .click({ force: true });
- testSnapshot();
- });
+ .click({ force: true })
+ testSnapshot()
+ })
it('check tool_text_change_stoke_fill_color', function () {
- cy.get('#svg_1').click({ force: true });
- cy.get('#stroke_color').shadow().find('#picker').eq(0).click({ force: true });
+ cy.get('#svg_1').click({ force: true })
+ cy.get('#stroke_color').shadow().find('#picker').eq(0).click({ force: true })
cy.get('#stroke_color').shadow().find('#color_picker').eq(0)
.find('#jGraduate_colPick').eq(0).find('#jPicker-table').eq(0)
- .find('.QuickColor').eq(51).click({ force: true });
+ .find('.QuickColor').eq(51).click({ force: true })
cy.get('#stroke_color').shadow().find('#color_picker').eq(0)
.find('#jGraduate_colPick').eq(0).find('#jPicker-table').eq(0)
- .find('#Ok').eq(0).click({ force: true });
- cy.get('#fill_color').shadow().find('#picker').eq(0).click({ force: true });
+ .find('#Ok').eq(0).click({ force: true })
+ cy.get('#fill_color').shadow().find('#picker').eq(0).click({ force: true })
cy.get('#fill_color').shadow().find('#color_picker').eq(0)
.find('#jGraduate_colPick').eq(0).find('#jPicker-table').eq(0)
- .find('.QuickColor').eq(3).click({ force: true });
+ .find('.QuickColor').eq(3).click({ force: true })
cy.get('#fill_color').shadow().find('#color_picker').eq(0)
.find('#jGraduate_colPick').eq(0).find('#jPicker-table').eq(0)
- .find('#Ok').eq(0).click({ force: true });
- testSnapshot();
- });
+ .find('#Ok').eq(0).click({ force: true })
+ testSnapshot()
+ })
it('check tool_text_anchor_start', function () {
- cy.get('#svg_1').click({ force: true });
+ cy.get('#svg_1').click({ force: true })
cy.get('#tool_text_anchor_start')
- .click({ force: true });
- testSnapshot();
- });
+ .click({ force: true })
+ testSnapshot()
+ })
it('check tool_text_anchor_middle', function () {
- cy.get('#svg_1').click({ force: true });
+ cy.get('#svg_1').click({ force: true })
cy.get('#tool_text_anchor_middle')
- .click({ force: true });
- testSnapshot();
- });
+ .click({ force: true })
+ testSnapshot()
+ })
it('check tool_text_anchor_end', function () {
- cy.get('#svg_1').click({ force: true });
+ cy.get('#svg_1').click({ force: true })
cy.get('#tool_text_anchor_end')
- .click({ force: true });
- testSnapshot();
- });
+ .click({ force: true })
+ testSnapshot()
+ })
it('check tool_text_change_rotation', function () {
- cy.get('#svg_2').click({ force: true });
- for(let n = 0; n < 5; n ++){
+ cy.get('#svg_2').click({ force: true })
+ for (let n = 0; n < 5; n++) {
cy.get('#angle').shadow().find('elix-number-spin-box').eq(0).shadow().find('#upButton').eq(0)
- .click({ force: true });
+ .click({ force: true })
}
- testSnapshot();
- });
+ testSnapshot()
+ })
it('check tool_text_change_blur', function () {
- cy.get('#svg_2').click({ force: true });
- for(let n = 0; n < 10; n ++){
+ cy.get('#svg_2').click({ force: true })
+ for (let n = 0; n < 10; n++) {
cy.get('#blur').shadow().find('elix-number-spin-box').eq(0).shadow().find('#upButton').eq(0)
- .click({ force: true });
+ .click({ force: true })
}
- testSnapshot();
- });
+ testSnapshot()
+ })
it('check tool_text_change_opacity', function () {
- cy.get('#svg_2').click({ force: true });
- for(let n = 0; n < 10; n ++){
+ cy.get('#svg_2').click({ force: true })
+ for (let n = 0; n < 10; n++) {
cy.get('#opacity').shadow().find('elix-number-spin-box').eq(0).shadow().find('#downButton').eq(0)
- .click({ force: true });
+ .click({ force: true })
}
- testSnapshot();
- });
+ testSnapshot()
+ })
it('check tool_text_align_to_page', function () {
- cy.get('#svg_2').click({ force: true });
- cy.get('#tool_position').shadow().find('elix-dropdown-list').eq(0).invoke('attr', 'opened', 'opened');
+ cy.get('#svg_2').click({ force: true })
+ cy.get('#tool_position').shadow().find('elix-dropdown-list').eq(0).invoke('attr', 'opened', 'opened')
cy.get('#tool_position').find('se-list-item').eq(2).shadow().find('elix-option').eq(0)
- .click({ force: true });
- testSnapshot();
- });
+ .click({ force: true })
+ testSnapshot()
+ })
it('check tool_text_change_class', function () {
- cy.get('#svg_2').click({ force: true });
+ cy.get('#svg_2').click({ force: true })
cy.get('#elem_class').shadow().find('elix-input').eq(0).shadow().find('#inner').eq(0)
- .type('svg_2_class{enter}', { force: true });
+ .type('svg_2_class{enter}', { force: true })
cy.get('#svg_2')
.should('satisfy', ($el) => {
- const classList = Array.from($el[0].classList);
- return classList.includes('svg_2_class');
- });
- });
+ const classList = Array.from($el[0].classList)
+ return classList.includes('svg_2_class')
+ })
+ })
it('check tool_text_change_id', function () {
- cy.get('#svg_2').click({ force: true }).click({ force: true });
+ cy.get('#svg_2').click({ force: true }).click({ force: true })
cy.get('#elem_id').shadow().find('elix-input').eq(0).shadow().find('#inner').eq(0)
- .type('_id{enter}', { force: true });
+ .type('_id{enter}', { force: true })
cy.get('#svg_2_id')
.should('satisfy', ($el) => {
- const classList = Array.from($el[0].classList);
- return classList.includes('svg_2_class');
- });
- });
+ const classList = Array.from($el[0].classList)
+ return classList.includes('svg_2_class')
+ })
+ })
it('check tool_text_delete', function () {
- cy.get('#svg_2_id').click({ force: true });
- cy.get('#tool_delete').click({ force: true });
- testSnapshot();
- });
+ cy.get('#svg_2_id').click({ force: true })
+ cy.get('#tool_delete').click({ force: true })
+ testSnapshot()
+ })
it('check tool_text_change_font_family', function () {
- cy.get('#svg_1').click({ force: true });
- cy.get('#tool_font_family').shadow().find('select').select("Serif");
- testSnapshot();
- });
-});
+ cy.get('#svg_1').click({ force: true })
+ cy.get('#tool_font_family').shadow().find('select').select('Serif')
+ testSnapshot()
+ })
+})
diff --git a/cypress/integration/ui/scenario1.js b/cypress/integration/ui/scenario1.js
index 55aaa2a3..5dff79ba 100644
--- a/cypress/integration/ui/scenario1.js
+++ b/cypress/integration/ui/scenario1.js
@@ -1,55 +1,55 @@
import {
visitAndApproveStorage
-} from '../../support/ui-test-helper.js';
+} from '../../support/ui-test-helper.js'
const testSnapshot = () => {
- cy.get('#svgcontent').cleanSnapshot();
-};
+ cy.get('#svgcontent').cleanSnapshot()
+}
describe('use all parts of svg-edit', function () {
before(() => {
- visitAndApproveStorage();
- });
+ visitAndApproveStorage()
+ })
it('check tool_source_set', function () {
- cy.get('#tool_source').click({ force: true });
+ cy.get('#tool_source').click({ force: true })
cy.get('#svg_source_textarea')
.type('{selectall}', { force: true })
.type(``, { force: true, parseSpecialCharSequences: false });
- cy.get('#tool_source_save').click({ force: true });
- testSnapshot();
- });
+ `, { force: true, parseSpecialCharSequences: false })
+ cy.get('#tool_source_save').click({ force: true })
+ testSnapshot()
+ })
it('check tool_shape', function () {
- cy.get('#tool_shapelib').shadow().find('.overall').eq(0).click({ force: true });
- cy.get('[data-shape="heart"]').click({ force: true });
+ cy.get('#tool_shapelib').shadow().find('.overall').eq(0).click({ force: true })
+ cy.get('[data-shape="heart"]').click({ force: true })
cy.get('#svgcontent')
.trigger('mousemove', 200, 200, { force: true })
.trigger('mousedown', 200, 200, { force: true })
.trigger('mousemove', 20, 20, { force: true })
- .trigger('mouseup', { force: true });
+ .trigger('mouseup', { force: true })
cy.get('#selectorGrip_rotate')
.trigger('mousedown')
.trigger('mousemove', 20, 20, { force: true })
- .trigger('mouseup', { force: true });
- testSnapshot();
- });
+ .trigger('mouseup', { force: true })
+ testSnapshot()
+ })
it('check tool_image', function () {
- cy.get('#tool_image').click({ force: true });
+ cy.get('#tool_image').click({ force: true })
cy.get('#svgcontent')
.trigger('mousedown', 100, 100, { force: true })
.trigger('mousemove', 120, 120, { force: true })
- .trigger('mouseup', { force: true });
+ .trigger('mouseup', { force: true })
// eslint-disable-next-line promise/catch-or-return
cy.window()
// eslint-disable-next-line promise/always-return
.then(($win) => {
- cy.stub($win, 'prompt').returns('./images/logo.svg');
- cy.contains('OK');
- });
- testSnapshot();
- });
-});
+ cy.stub($win, 'prompt').returns('./images/logo.svg')
+ cy.contains('OK')
+ })
+ testSnapshot()
+ })
+})
diff --git a/cypress/integration/ui/scenario2.js b/cypress/integration/ui/scenario2.js
index 5390b972..c0051639 100644
--- a/cypress/integration/ui/scenario2.js
+++ b/cypress/integration/ui/scenario2.js
@@ -1,124 +1,124 @@
import {
visitAndApproveStorage
-} from '../../support/ui-test-helper.js';
+} from '../../support/ui-test-helper.js'
const testSnapshot = () => {
- cy.get('#svgcontent').cleanSnapshot();
-};
+ cy.get('#svgcontent').cleanSnapshot()
+}
describe('use all parts of svg-edit', function () {
before(() => {
- visitAndApproveStorage();
- });
+ visitAndApproveStorage()
+ })
it('check tool_source_set', function () {
- cy.get('#tool_source').click({ force: true });
+ cy.get('#tool_source').click({ force: true })
cy.get('#svg_source_textarea')
.type('{selectall}', { force: true })
.type(``, { force: true, parseSpecialCharSequences: false });
- cy.get('#tool_source_save').click({ force: true });
- testSnapshot();
- });
+ `, { force: true, parseSpecialCharSequences: false })
+ cy.get('#tool_source_save').click({ force: true })
+ testSnapshot()
+ })
it('check tool_circle', function () {
cy.get('#tool_circle')
- .click({ force: true });
+ .click({ force: true })
cy.get('#svgcontent')
.trigger('mousedown', 150, 150, { force: true })
.trigger('mousemove', 250, 200, { force: true })
- .trigger('mouseup', { force: true });
- testSnapshot();
- });
+ .trigger('mouseup', { force: true })
+ testSnapshot()
+ })
it('check tool_fhellipse', function () {
cy.get('#tool_fhellipse')
- .click({ force: true });
+ .click({ force: true })
cy.get('#svgcontent')
.trigger('mousedown', 200, 80, { force: true })
.trigger('mousemove', 320, 80, { force: true })
.trigger('mousemove', 320, 180, { force: true })
.trigger('mousemove', 200, 180, { force: true })
.trigger('mousemove', 200, 80, { force: true })
- .trigger('mouseup', 200, 80, { force: true });
- testSnapshot();
- });
+ .trigger('mouseup', 200, 80, { force: true })
+ testSnapshot()
+ })
it('check tool_ellipse', function () {
- cy.get('#tool_ellipse').click({ force: true });
+ cy.get('#tool_ellipse').click({ force: true })
cy.get('#svgcontent')
.trigger('mousedown', 75, 150, { force: true })
.trigger('mousemove', 130, 175, { force: true })
- .trigger('mouseup', { force: true });
- testSnapshot();
- });
+ .trigger('mouseup', { force: true })
+ testSnapshot()
+ })
it('check tool_circle_change_fill_color', function () {
- cy.get('#svg_2').click({ force: true });
+ cy.get('#svg_2').click({ force: true })
cy.get('#js-se-palette').find('.square').eq(8)
- .click({ force: true });
- testSnapshot();
- });
+ .click({ force: true })
+ testSnapshot()
+ })
it('check tool_circle_change_opacity', function () {
- cy.get('#svg_2').click({ force: true });
- for(let n = 0; n < 10; n ++){
+ cy.get('#svg_2').click({ force: true })
+ for (let n = 0; n < 10; n++) {
cy.get('#opacity').shadow().find('elix-number-spin-box').eq(0).shadow().find('#downButton').eq(0)
- .click({ force: true });
+ .click({ force: true })
}
- testSnapshot();
- });
+ testSnapshot()
+ })
it('check tool_ellipse_change_rotation', function () {
- cy.get('#svg_3').click({ force: true });
- for(let n = 0; n < 5; n ++){
+ cy.get('#svg_3').click({ force: true })
+ for (let n = 0; n < 5; n++) {
cy.get('#angle').shadow().find('elix-number-spin-box').eq(0).shadow().find('#upButton').eq(0)
- .click({ force: true });
+ .click({ force: true })
}
- testSnapshot();
- });
+ testSnapshot()
+ })
it('check tool_ellipse_change_blur', function () {
- cy.get('#svg_3').click({ force: true });
- for(let n = 0; n < 10; n ++){
+ cy.get('#svg_3').click({ force: true })
+ for (let n = 0; n < 10; n++) {
cy.get('#blur').shadow().find('elix-number-spin-box').eq(0).shadow().find('#upButton').eq(0)
- .click({ force: true });
+ .click({ force: true })
}
- testSnapshot();
- });
+ testSnapshot()
+ })
it('check tool_ellipse_change_cx_cy_coordinate', function () {
- cy.get('#svg_3').click({ force: true });
- for(let n = 0; n < 25; n ++){
+ cy.get('#svg_3').click({ force: true })
+ for (let n = 0; n < 25; n++) {
cy.get('#ellipse_cx').shadow().find('elix-number-spin-box').eq(0).shadow().find('#upButton').eq(0)
- .click({ force: true });
+ .click({ force: true })
}
- for(let n = 0; n < 25; n ++){
+ for (let n = 0; n < 25; n++) {
cy.get('#ellipse_cy').shadow().find('elix-number-spin-box').eq(0).shadow().find('#upButton').eq(0)
- .click({ force: true });
+ .click({ force: true })
}
- testSnapshot();
- });
+ testSnapshot()
+ })
it('check tool_ellipse_change_rx_ry_radius', function () {
- cy.get('#svg_3').click({ force: true });
- for(let n = 0; n < 25; n ++){
+ cy.get('#svg_3').click({ force: true })
+ for (let n = 0; n < 25; n++) {
cy.get('#ellipse_rx').shadow().find('elix-number-spin-box').eq(0).shadow().find('#upButton').eq(0)
- .click({ force: true });
+ .click({ force: true })
}
- for(let n = 0; n < 25; n ++){
+ for (let n = 0; n < 25; n++) {
cy.get('#ellipse_ry').shadow().find('elix-number-spin-box').eq(0).shadow().find('#upButton').eq(0)
- .click({ force: true });
+ .click({ force: true })
}
- testSnapshot();
- });
+ testSnapshot()
+ })
it('check tool_ellipse_bring_to_back', function () {
- cy.get('#svg_2').click({ force: true });
- cy.get('#tool_move_bottom').click({ force: true });
- testSnapshot();
- });
+ cy.get('#svg_2').click({ force: true })
+ cy.get('#tool_move_bottom').click({ force: true })
+ testSnapshot()
+ })
it('check tool_ellipse_bring_to_front', function () {
- cy.get('#svg_2').click({ force: true });
- cy.get('#tool_move_top').click({ force: true });
- testSnapshot();
- });
+ cy.get('#svg_2').click({ force: true })
+ cy.get('#tool_move_top').click({ force: true })
+ testSnapshot()
+ })
it('check tool_ellipse_clone', function () {
- cy.get('#svg_2').click({ force: true });
- cy.get('#tool_clone').click({ force: true });
- testSnapshot();
- });
-});
+ cy.get('#svg_2').click({ force: true })
+ cy.get('#tool_clone').click({ force: true })
+ testSnapshot()
+ })
+})
diff --git a/cypress/integration/ui/scenario3.js b/cypress/integration/ui/scenario3.js
index 496d340c..0150466c 100644
--- a/cypress/integration/ui/scenario3.js
+++ b/cypress/integration/ui/scenario3.js
@@ -1,31 +1,31 @@
import {
visitAndApproveStorage
-} from '../../support/ui-test-helper.js';
+} from '../../support/ui-test-helper.js'
const testSnapshot = () => {
- cy.get('#svgcontent').cleanSnapshot();
-};
+ cy.get('#svgcontent').cleanSnapshot()
+}
describe('use all parts of svg-edit', function () {
before(() => {
- visitAndApproveStorage();
- });
+ visitAndApproveStorage()
+ })
it('check tool_source_set', function () {
- cy.get('#tool_source').click({ force: true });
+ cy.get('#tool_source').click({ force: true })
cy.get('#svg_source_textarea')
.type('{selectall}', { force: true })
.type(``, { force: true, parseSpecialCharSequences: false });
- cy.get('#tool_source_save').click({ force: true });
- testSnapshot();
- });
+ `, { force: true, parseSpecialCharSequences: false })
+ cy.get('#tool_source_save').click({ force: true })
+ testSnapshot()
+ })
it('check tool_path', function () {
cy.get('#tool_path')
- .click({ force: true });
+ .click({ force: true })
cy.get('#svgcontent')
.trigger('mousedown', 50, 50, { force: true })
.trigger('mouseup', { force: true })
@@ -37,49 +37,49 @@ describe('use all parts of svg-edit', function () {
.trigger('mouseup', { force: true })
.trigger('mousemove', 0, 0, { force: true })
.trigger('mousedown', 0, 0, { force: true })
- .trigger('mouseup', { force: true });
- testSnapshot();
- });
+ .trigger('mouseup', { force: true })
+ testSnapshot()
+ })
it('check tool_path_change_node_xy', function () {
- cy.get('#svg_1').click({ force: true });
- cy.get('#svg_1').dblclick({ force: true });
- for(let n = 0; n < 25; n ++){
+ cy.get('#svg_1').click({ force: true })
+ cy.get('#svg_1').dblclick({ force: true })
+ for (let n = 0; n < 25; n++) {
cy.get('#path_node_x').shadow().find('elix-number-spin-box').eq(0).shadow().find('#upButton').eq(0)
- .click({ force: true });
+ .click({ force: true })
}
- for(let n = 0; n < 25; n ++){
+ for (let n = 0; n < 25; n++) {
cy.get('#path_node_y').shadow().find('elix-number-spin-box').eq(0).shadow().find('#upButton').eq(0)
- .click({ force: true });
+ .click({ force: true })
}
- testSnapshot();
- });
+ testSnapshot()
+ })
it('check tool_path_change_seg_type', function () {
- cy.get('#svg_1').click({ force: true });
- cy.get('#svg_1').dblclick({ force: true });
- cy.get('#seg_type').shadow().find('select').select('6').should('have.value', '6');
+ cy.get('#svg_1').click({ force: true })
+ cy.get('#svg_1').dblclick({ force: true })
+ cy.get('#seg_type').shadow().find('select').select('6').should('have.value', '6')
cy.get('#ctrlpointgrip_3c1')
.trigger('mousedown', { force: true })
.trigger('mousemove', 130, 175, { force: true })
- .trigger('mouseup', { force: true });
- testSnapshot();
- });
+ .trigger('mouseup', { force: true })
+ testSnapshot()
+ })
it('check tool_path_change_clone_node', function () {
- cy.get('#svg_1').click({ force: true });
- cy.get('#svg_1').dblclick({ force: true });
- cy.get('#tool_node_clone').click({ force: true });
+ cy.get('#svg_1').click({ force: true })
+ cy.get('#svg_1').dblclick({ force: true })
+ cy.get('#tool_node_clone').click({ force: true })
cy.get('#pathpointgrip_4')
.trigger('mousedown', { force: true })
.trigger('mousemove', 130, 175, { force: true })
- .trigger('mouseup', { force: true });
- testSnapshot();
- });
+ .trigger('mouseup', { force: true })
+ testSnapshot()
+ })
it('check tool_path_openclose', function () {
- cy.get('#tool_select').click({ force: true });
- cy.get('#svg_1').click({ force: true });
- cy.get('#svg_1').dblclick({ force: true });
- cy.get('#tool_openclose_path').click({ force: true });
- testSnapshot();
- });
+ cy.get('#tool_select').click({ force: true })
+ cy.get('#svg_1').click({ force: true })
+ cy.get('#svg_1').dblclick({ force: true })
+ cy.get('#tool_openclose_path').click({ force: true })
+ testSnapshot()
+ })
/* it('check tool_path_add_subpath', function () {
cy.get('#tool_add_subpath').click({ force: true });
cy.get('#svgcontent')
@@ -97,4 +97,4 @@ describe('use all parts of svg-edit', function () {
cy.get('#tool_select').click({ force: true });
testSnapshot();
}); */
-});
+})
diff --git a/cypress/integration/ui/scenario4.js b/cypress/integration/ui/scenario4.js
index 51e0bea5..db3b91d8 100644
--- a/cypress/integration/ui/scenario4.js
+++ b/cypress/integration/ui/scenario4.js
@@ -1,164 +1,164 @@
import {
visitAndApproveStorage
-} from '../../support/ui-test-helper.js';
+} from '../../support/ui-test-helper.js'
const testSnapshot = () => {
- cy.get('#svgcontent').cleanSnapshot();
-};
+ cy.get('#svgcontent').cleanSnapshot()
+}
describe('use all parts of svg-edit', function () {
before(() => {
- visitAndApproveStorage();
- });
+ visitAndApproveStorage()
+ })
it('check tool_source_set', function () {
- cy.get('#tool_source').click({ force: true });
+ cy.get('#tool_source').click({ force: true })
cy.get('#svg_source_textarea')
.type('{selectall}', { force: true })
.type(``, { force: true, parseSpecialCharSequences: false });
- cy.get('#tool_source_save').click({ force: true });
- testSnapshot();
- });
+ `, { force: true, parseSpecialCharSequences: false })
+ cy.get('#tool_source_save').click({ force: true })
+ testSnapshot()
+ })
it('check tool_rect', function () {
cy.get('#tool_rect')
- .click({ force: true });
+ .click({ force: true })
cy.get('#svgcontent')
.trigger('mousedown', 150, 150, { force: true })
.trigger('mousemove', 250, 200, { force: true })
- .trigger('mouseup', { force: true });
- testSnapshot();
- });
+ .trigger('mouseup', { force: true })
+ testSnapshot()
+ })
it('check tool_fhrect', function () {
cy.get('#tool_fhrect')
- .click({ force: true });
+ .click({ force: true })
cy.get('#svgcontent')
.trigger('mousedown', 200, 80, { force: true })
.trigger('mousemove', 320, 80, { force: true })
.trigger('mousemove', 320, 180, { force: true })
.trigger('mousemove', 200, 180, { force: true })
.trigger('mousemove', 200, 80, { force: true })
- .trigger('mouseup', 200, 80, { force: true });
- testSnapshot();
- });
+ .trigger('mouseup', 200, 80, { force: true })
+ testSnapshot()
+ })
it('check tool_square', function () {
- cy.get('#tool_square').click({ force: true });
+ cy.get('#tool_square').click({ force: true })
cy.get('#svgcontent')
.trigger('mousedown', 75, 150, { force: true })
.trigger('mousemove', 125, 200, { force: true })
- .trigger('mouseup', { force: true });
- testSnapshot();
- });
+ .trigger('mouseup', { force: true })
+ testSnapshot()
+ })
it('check tool_rect_change_fill_color', function () {
- cy.get('#svg_1').click({ force: true });
+ cy.get('#svg_1').click({ force: true })
cy.get('#js-se-palette').find('.square').eq(8)
- .click({ force: true });
- testSnapshot();
- });
+ .click({ force: true })
+ testSnapshot()
+ })
it('check tool_rect_change_rotation', function () {
- cy.get('#svg_1').click({ force: true });
- for(let n = 0; n < 5; n ++){
+ cy.get('#svg_1').click({ force: true })
+ for (let n = 0; n < 5; n++) {
cy.get('#angle').shadow().find('elix-number-spin-box').eq(0).shadow().find('#upButton').eq(0)
- .click({ force: true });
+ .click({ force: true })
}
- testSnapshot();
- });
+ testSnapshot()
+ })
it('check tool_rect_change_blur', function () {
- cy.get('#svg_1').click({ force: true });
- for(let n = 0; n < 10; n ++){
+ cy.get('#svg_1').click({ force: true })
+ for (let n = 0; n < 10; n++) {
cy.get('#blur').shadow().find('elix-number-spin-box').eq(0).shadow().find('#upButton').eq(0)
- .click({ force: true });
+ .click({ force: true })
}
- testSnapshot();
- });
+ testSnapshot()
+ })
it('check tool_rect_change_opacity', function () {
- cy.get('#svg_1').click({ force: true });
- for(let n = 0; n < 10; n ++){
+ cy.get('#svg_1').click({ force: true })
+ for (let n = 0; n < 10; n++) {
cy.get('#opacity').shadow().find('elix-number-spin-box').eq(0).shadow().find('#downButton').eq(0)
- .click({ force: true });
+ .click({ force: true })
}
- testSnapshot();
- });
+ testSnapshot()
+ })
it('check tool_fhrect_change_x_y_coordinate', function () {
- cy.get('#svg_2').click({ force: true });
- for(let n = 0; n < 25; n ++){
+ cy.get('#svg_2').click({ force: true })
+ for (let n = 0; n < 25; n++) {
cy.get('#selected_x').shadow().find('elix-number-spin-box').eq(0).shadow().find('#upButton').eq(0)
- .click({ force: true });
+ .click({ force: true })
}
- for(let n = 0; n < 25; n ++){
+ for (let n = 0; n < 25; n++) {
cy.get('#selected_y').shadow().find('elix-number-spin-box').eq(0).shadow().find('#upButton').eq(0)
- .click({ force: true });
+ .click({ force: true })
}
- testSnapshot();
- });
+ testSnapshot()
+ })
it('check tool_fhrect_change_width_height', function () {
- cy.get('#svg_2').click({ force: true });
- for(let n = 0; n < 25; n ++){
+ cy.get('#svg_2').click({ force: true })
+ for (let n = 0; n < 25; n++) {
cy.get('#rect_width').shadow().find('elix-number-spin-box').eq(0).shadow().find('#upButton').eq(0)
- .click({ force: true });
+ .click({ force: true })
}
- for(let n = 0; n < 25; n ++){
+ for (let n = 0; n < 25; n++) {
cy.get('#rect_height').shadow().find('elix-number-spin-box').eq(0).shadow().find('#upButton').eq(0)
- .click({ force: true });
+ .click({ force: true })
}
- testSnapshot();
- });
+ testSnapshot()
+ })
it('check tool_square_clone', function () {
- cy.get('#svg_3').click({ force: true });
- cy.get('#tool_clone').click({ force: true });
- testSnapshot();
- });
+ cy.get('#svg_3').click({ force: true })
+ cy.get('#tool_clone').click({ force: true })
+ testSnapshot()
+ })
it('check tool_square_bring_to_back', function () {
- cy.get('#svg_3').click({ force: true });
- cy.get('#tool_move_bottom').click({ force: true });
- testSnapshot();
- });
+ cy.get('#svg_3').click({ force: true })
+ cy.get('#tool_move_bottom').click({ force: true })
+ testSnapshot()
+ })
it('check tool_square_bring_to_front', function () {
- cy.get('#svg_3').click({ force: true });
- cy.get('#tool_move_top').click({ force: true });
- testSnapshot();
- });
+ cy.get('#svg_3').click({ force: true })
+ cy.get('#tool_move_top').click({ force: true })
+ testSnapshot()
+ })
it('check tool_square_change_corner_radius', function () {
- cy.get('#svg_4').click({ force: true });
- for(let n = 0; n < 25; n ++){
+ cy.get('#svg_4').click({ force: true })
+ for (let n = 0; n < 25; n++) {
cy.get('#rect_rx').shadow().find('elix-number-spin-box').eq(0).shadow().find('#upButton').eq(0)
- .click({ force: true });
+ .click({ force: true })
}
- testSnapshot();
- });
+ testSnapshot()
+ })
it('check tool_rect_change_to_path', function () {
- cy.get('#svg_2').click({ force: true });
- cy.get('#tool_topath').click({ force: true });
- testSnapshot();
- });
+ cy.get('#svg_2').click({ force: true })
+ cy.get('#tool_topath').click({ force: true })
+ testSnapshot()
+ })
it('check tool_rect_delete', function () {
- cy.get('#svg_1').click({ force: true });
- cy.get('#tool_delete').click({ force: true });
- cy.get('#svg_3').click({ force: true });
- cy.get('#tool_delete').click({ force: true });
- testSnapshot();
- });
+ cy.get('#svg_1').click({ force: true })
+ cy.get('#tool_delete').click({ force: true })
+ cy.get('#svg_3').click({ force: true })
+ cy.get('#tool_delete').click({ force: true })
+ testSnapshot()
+ })
it('check tool_rect_change_class', function () {
- cy.get('#svg_2').click({ force: true });
+ cy.get('#svg_2').click({ force: true })
cy.get('#elem_class').shadow().find('elix-input').eq(0).shadow().find('#inner').eq(0)
- .type('svg_2_class{enter}', { force: true });
+ .type('svg_2_class{enter}', { force: true })
cy.get('#svg_2')
.should('satisfy', ($el) => {
- const classList = Array.from($el[0].classList);
- return classList.includes('svg_2_class');
- });
- });
+ const classList = Array.from($el[0].classList)
+ return classList.includes('svg_2_class')
+ })
+ })
it('check tool_rect_change_id', function () {
- cy.get('#svg_2').click({ force: true }).click({ force: true });
+ cy.get('#svg_2').click({ force: true }).click({ force: true })
cy.get('#elem_id').shadow().find('elix-input').eq(0).shadow().find('#inner').eq(0)
- .type('_id{enter}', { force: true });
+ .type('_id{enter}', { force: true })
cy.get('#svg_2_id')
.should('satisfy', ($el) => {
- const classList = Array.from($el[0].classList);
- return classList.includes('svg_2_class');
- });
- });
-});
+ const classList = Array.from($el[0].classList)
+ return classList.includes('svg_2_class')
+ })
+ })
+})
diff --git a/cypress/integration/ui/scenario5.js b/cypress/integration/ui/scenario5.js
index e6b5fd7f..8bee0396 100644
--- a/cypress/integration/ui/scenario5.js
+++ b/cypress/integration/ui/scenario5.js
@@ -1,153 +1,153 @@
import {
visitAndApproveStorage
-} from '../../support/ui-test-helper.js';
+} from '../../support/ui-test-helper.js'
const testSnapshot = () => {
- cy.get('#svgcontent').cleanSnapshot();
-};
+ cy.get('#svgcontent').cleanSnapshot()
+}
describe('use all parts of svg-edit', function () {
before(() => {
- visitAndApproveStorage();
- });
+ visitAndApproveStorage()
+ })
it('check tool_source_set', function () {
- cy.get('#tool_source').click({ force: true });
+ cy.get('#tool_source').click({ force: true })
cy.get('#svg_source_textarea')
.type('{selectall}', { force: true })
.type(``, { force: true, parseSpecialCharSequences: false });
- cy.get('#tool_source_save').click({ force: true });
- testSnapshot();
- });
+ `, { force: true, parseSpecialCharSequences: false })
+ cy.get('#tool_source_save').click({ force: true })
+ testSnapshot()
+ })
it('check tool_line', function () {
cy.get('#tool_line')
- .click({ force: true });
+ .click({ force: true })
cy.get('#svgcontent')
.trigger('mousemove', 200, 200, { force: true })
.trigger('mousedown', 200, 200, { force: true })
.trigger('mousemove', 250, 250, { force: true })
- .trigger('mouseup', { force: true });
- testSnapshot();
- });
+ .trigger('mouseup', { force: true })
+ testSnapshot()
+ })
it('check tool_line_change_class', function () {
- cy.get('#svg_1').click({ force: true });
+ cy.get('#svg_1').click({ force: true })
cy.get('#elem_class').shadow().find('elix-input').eq(0).shadow().find('#inner').eq(0)
- .type('svg_1_class{enter}', { force: true });
+ .type('svg_1_class{enter}', { force: true })
cy.get('#svg_1')
.should('satisfy', ($el) => {
- const classList = Array.from($el[0].classList);
- return classList.includes('svg_1_class');
- });
- });
+ const classList = Array.from($el[0].classList)
+ return classList.includes('svg_1_class')
+ })
+ })
it('check tool_line_change_id', function () {
- cy.get('#svg_1').click({ force: true }).click({ force: true });
+ cy.get('#svg_1').click({ force: true }).click({ force: true })
cy.get('#elem_id').shadow().find('elix-input').eq(0).shadow().find('#inner').eq(0)
- .type('_id{enter}', { force: true });
+ .type('_id{enter}', { force: true })
cy.get('#svg_1_id')
.should('satisfy', ($el) => {
- const classList = Array.from($el[0].classList);
- return classList.includes('svg_1_class');
- });
- });
+ const classList = Array.from($el[0].classList)
+ return classList.includes('svg_1_class')
+ })
+ })
it('check tool_line_change_rotation', function () {
- cy.get('#svg_1_id').click({ force: true });
- for(let n = 0; n < 5; n ++){
+ cy.get('#svg_1_id').click({ force: true })
+ for (let n = 0; n < 5; n++) {
cy.get('#angle').shadow().find('elix-number-spin-box').eq(0).shadow().find('#upButton').eq(0)
- .click({ force: true });
+ .click({ force: true })
}
- testSnapshot();
- });
+ testSnapshot()
+ })
it('check tool_line_change_blur', function () {
- cy.get('#svg_1_id').click({ force: true });
- for(let n = 0; n < 10; n ++){
+ cy.get('#svg_1_id').click({ force: true })
+ for (let n = 0; n < 10; n++) {
cy.get('#blur').shadow().find('elix-number-spin-box').eq(0).shadow().find('#upButton').eq(0)
- .click({ force: true });
+ .click({ force: true })
}
- testSnapshot();
- });
+ testSnapshot()
+ })
it('check tool_line_change_opacity', function () {
- cy.get('#svg_1_id').click({ force: true });
- for(let n = 0; n < 10; n ++){
+ cy.get('#svg_1_id').click({ force: true })
+ for (let n = 0; n < 10; n++) {
cy.get('#opacity').shadow().find('elix-number-spin-box').eq(0).shadow().find('#downButton').eq(0)
- .click({ force: true });
+ .click({ force: true })
}
- testSnapshot();
- });
+ testSnapshot()
+ })
it('check tool_line_delete', function () {
- cy.get('#svg_1_id').click({ force: true });
- cy.get('#tool_delete').click({ force: true });
- testSnapshot();
- });
+ cy.get('#svg_1_id').click({ force: true })
+ cy.get('#tool_delete').click({ force: true })
+ testSnapshot()
+ })
it('check tool_line_clone', function () {
cy.get('#tool_line')
- .click({ force: true });
+ .click({ force: true })
cy.get('#svgcontent')
.trigger('mousemove', 200, 200, { force: true })
.trigger('mousedown', 200, 200, { force: true })
.trigger('mousemove', 250, 250, { force: true })
- .trigger('mouseup', { force: true });
- cy.get('#svg_2').click({ force: true });
- cy.get('#tool_clone').click({ force: true });
- testSnapshot();
- });
+ .trigger('mouseup', { force: true })
+ cy.get('#svg_2').click({ force: true })
+ cy.get('#tool_clone').click({ force: true })
+ testSnapshot()
+ })
it('check tool_line_bring_to_back', function () {
- cy.get('#svg_2').click({ force: true });
- cy.get('#tool_move_bottom').click({ force: true });
- testSnapshot();
- });
+ cy.get('#svg_2').click({ force: true })
+ cy.get('#tool_move_bottom').click({ force: true })
+ testSnapshot()
+ })
it('check tool_line_bring_to_front', function () {
- cy.get('#svg_2').click({ force: true });
- cy.get('#tool_move_top').click({ force: true });
- testSnapshot();
- });
+ cy.get('#svg_2').click({ force: true })
+ cy.get('#tool_move_top').click({ force: true })
+ testSnapshot()
+ })
it('check tool_line_change_x_y_coordinate', function () {
- cy.get('#svg_2').click({ force: true });
- for(let n = 0; n < 25; n ++){
+ cy.get('#svg_2').click({ force: true })
+ for (let n = 0; n < 25; n++) {
cy.get('#line_x1').shadow().find('elix-number-spin-box').eq(0).shadow().find('#upButton').eq(0)
- .click({ force: true });
+ .click({ force: true })
}
- for(let n = 0; n < 25; n ++){
+ for (let n = 0; n < 25; n++) {
cy.get('#line_y1').shadow().find('elix-number-spin-box').eq(0).shadow().find('#downButton').eq(0)
- .click({ force: true });
+ .click({ force: true })
}
- for(let n = 0; n < 25; n ++){
+ for (let n = 0; n < 25; n++) {
cy.get('#line_x2').shadow().find('elix-number-spin-box').eq(0).shadow().find('#upButton').eq(0)
- .click({ force: true });
+ .click({ force: true })
}
- for(let n = 0; n < 25; n ++){
+ for (let n = 0; n < 25; n++) {
cy.get('#line_y2').shadow().find('elix-number-spin-box').eq(0).shadow().find('#downButton').eq(0)
- .click({ force: true });
+ .click({ force: true })
}
- testSnapshot();
- });
+ testSnapshot()
+ })
it('check tool_line_change_stroke_width', function () {
- cy.get('#svg_2').click({ force: true });
- for(let n = 0; n < 10; n ++){
+ cy.get('#svg_2').click({ force: true })
+ for (let n = 0; n < 10; n++) {
cy.get('#stroke_width').shadow().find('elix-number-spin-box').eq(0).shadow().find('#upButton').eq(0)
- .click({ force: true });
+ .click({ force: true })
}
- testSnapshot();
- });
+ testSnapshot()
+ })
it('check tool_line_change_stoke_color', function () {
- cy.get('#svg_3').click({ force: true });
- cy.get('#stroke_color').shadow().find('#picker').eq(0).click({ force: true });
+ cy.get('#svg_3').click({ force: true })
+ cy.get('#stroke_color').shadow().find('#picker').eq(0).click({ force: true })
cy.get('#stroke_color').shadow().find('#color_picker').eq(0)
.find('#jGraduate_colPick').eq(0).find('#jPicker-table').eq(0)
- .find('.QuickColor').eq(9).click({ force: true });
+ .find('.QuickColor').eq(9).click({ force: true })
cy.get('#stroke_color').shadow().find('#color_picker').eq(0)
.find('#jGraduate_colPick').eq(0).find('#jPicker-table').eq(0)
- .find('#Ok').eq(0).click({ force: true });
- testSnapshot();
- });
+ .find('#Ok').eq(0).click({ force: true })
+ testSnapshot()
+ })
it('check tool_line_align_to_page', function () {
- cy.get('#svg_3').click({ force: true });
- cy.get('#tool_position').shadow().find('elix-dropdown-list').eq(0).invoke('attr', 'opened', 'opened');
+ cy.get('#svg_3').click({ force: true })
+ cy.get('#tool_position').shadow().find('elix-dropdown-list').eq(0).invoke('attr', 'opened', 'opened')
cy.get('#tool_position').find('se-list-item').eq(2).shadow().find('elix-option').eq(0)
- .click({ force: true });
- testSnapshot();
- });
-});
+ .click({ force: true })
+ testSnapshot()
+ })
+})
diff --git a/cypress/integration/ui/scenario6.js b/cypress/integration/ui/scenario6.js
index 992393de..240931b5 100644
--- a/cypress/integration/ui/scenario6.js
+++ b/cypress/integration/ui/scenario6.js
@@ -1,108 +1,108 @@
import {
visitAndApproveStorage
-} from '../../support/ui-test-helper.js';
+} from '../../support/ui-test-helper.js'
const testSnapshot = () => {
- cy.get('#svgcontent').cleanSnapshot();
-};
+ cy.get('#svgcontent').cleanSnapshot()
+}
describe('use all parts of svg-edit', function () {
before(() => {
- visitAndApproveStorage();
- });
+ visitAndApproveStorage()
+ })
it('check tool_source_set', function () {
- cy.get('#tool_source').click({ force: true });
+ cy.get('#tool_source').click({ force: true })
cy.get('#svg_source_textarea')
.type('{selectall}', { force: true })
.type(``, { force: true, parseSpecialCharSequences: false });
- cy.get('#tool_source_save').click({ force: true });
- testSnapshot();
- });
+ `, { force: true, parseSpecialCharSequences: false })
+ cy.get('#tool_source_save').click({ force: true })
+ testSnapshot()
+ })
it('check tool_polygon', function () {
cy.get('#tool_polygon')
- .click({ force: true });
+ .click({ force: true })
cy.get('#svgcontent')
.trigger('mousedown', 325, 250, { force: true })
.trigger('mousemove', 325, 345, { force: true })
- .trigger('mouseup', { force: true });
- testSnapshot();
- });
+ .trigger('mouseup', { force: true })
+ testSnapshot()
+ })
it('check tool_polygon_clone', function () {
- cy.get('#svg_1').click({ force: true });
- cy.get('#tool_clone').click({ force: true });
- testSnapshot();
- });
+ cy.get('#svg_1').click({ force: true })
+ cy.get('#tool_clone').click({ force: true })
+ testSnapshot()
+ })
it('check tool_polygon_change_class', function () {
- cy.get('#svg_2').click({ force: true });
+ cy.get('#svg_2').click({ force: true })
cy.get('#elem_class').shadow().find('elix-input').eq(0).shadow().find('#inner').eq(0)
- .type('svg_2_class{enter}', { force: true });
+ .type('svg_2_class{enter}', { force: true })
cy.get('#svg_2')
.should('satisfy', ($el) => {
- const classList = Array.from($el[0].classList);
- return classList.includes('svg_2_class');
- });
- });
+ const classList = Array.from($el[0].classList)
+ return classList.includes('svg_2_class')
+ })
+ })
it('check tool_polygon_change_id', function () {
- cy.get('#svg_2').click({ force: true }).click({ force: true });
+ cy.get('#svg_2').click({ force: true }).click({ force: true })
cy.get('#elem_id').shadow().find('elix-input').eq(0).shadow().find('#inner').eq(0)
- .type('_id{enter}', { force: true });
+ .type('_id{enter}', { force: true })
cy.get('#svg_2_id')
.should('satisfy', ($el) => {
- const classList = Array.from($el[0].classList);
- return classList.includes('svg_2_class');
- });
- });
+ const classList = Array.from($el[0].classList)
+ return classList.includes('svg_2_class')
+ })
+ })
it('check tool_polygon_change_rotation', function () {
- cy.get('#svg_2_id').click({ force: true });
- for(let n = 0; n < 5; n ++){
+ cy.get('#svg_2_id').click({ force: true })
+ for (let n = 0; n < 5; n++) {
cy.get('#angle').shadow().find('elix-number-spin-box').eq(0).shadow().find('#upButton').eq(0)
- .click({ force: true });
+ .click({ force: true })
}
- testSnapshot();
- });
+ testSnapshot()
+ })
it('check tool_polygon_change_blur', function () {
- cy.get('#svg_2_id').click({ force: true });
- for(let n = 0; n < 10; n ++){
+ cy.get('#svg_2_id').click({ force: true })
+ for (let n = 0; n < 10; n++) {
cy.get('#blur').shadow().find('elix-number-spin-box').eq(0).shadow().find('#upButton').eq(0)
- .click({ force: true });
+ .click({ force: true })
}
- testSnapshot();
- });
+ testSnapshot()
+ })
it('check tool_polygon_change_opacity', function () {
- cy.get('#svg_2_id').click({ force: true });
- for(let n = 0; n < 10; n ++){
+ cy.get('#svg_2_id').click({ force: true })
+ for (let n = 0; n < 10; n++) {
cy.get('#opacity').shadow().find('elix-number-spin-box').eq(0).shadow().find('#downButton').eq(0)
- .click({ force: true });
+ .click({ force: true })
}
- testSnapshot();
- });
+ testSnapshot()
+ })
it('check tool_polygon_bring_to_back', function () {
- cy.get('#svg_2_id').click({ force: true });
- cy.get('#tool_move_bottom').click({ force: true });
- testSnapshot();
- });
+ cy.get('#svg_2_id').click({ force: true })
+ cy.get('#tool_move_bottom').click({ force: true })
+ testSnapshot()
+ })
it('check tool_polygon_bring_to_front', function () {
- cy.get('#svg_2_id').click({ force: true });
- cy.get('#tool_move_top').click({ force: true });
- testSnapshot();
- });
+ cy.get('#svg_2_id').click({ force: true })
+ cy.get('#tool_move_top').click({ force: true })
+ testSnapshot()
+ })
it('check tool_polygon_delete', function () {
- cy.get('#svg_2_id').click({ force: true });
- cy.get('#tool_delete').click({ force: true });
- testSnapshot();
- });
+ cy.get('#svg_2_id').click({ force: true })
+ cy.get('#tool_delete').click({ force: true })
+ testSnapshot()
+ })
it('check tool_polygon_align_to_page', function () {
- cy.get('#svg_1').click({ force: true });
- cy.get('#tool_position').shadow().find('elix-dropdown-list').eq(0).invoke('attr', 'opened', 'opened');
+ cy.get('#svg_1').click({ force: true })
+ cy.get('#tool_position').shadow().find('elix-dropdown-list').eq(0).invoke('attr', 'opened', 'opened')
cy.get('#tool_position').find('se-list-item').eq(0).shadow().find('elix-option').eq(0)
- .click({ force: true });
- testSnapshot();
- });
+ .click({ force: true })
+ testSnapshot()
+ })
/* it('check tool_polygon_change_x_y_coordinate', function () {
cy.get('#svg_1').click({ force: true });
for(let n = 0; n < 25; n ++){
@@ -116,35 +116,35 @@ describe('use all parts of svg-edit', function () {
testSnapshot();
}); */
it('check tool_polygon_change_stroke_width', function () {
- cy.get('#svg_1').click({ force: true });
- for(let n = 0; n < 10; n ++){
+ cy.get('#svg_1').click({ force: true })
+ for (let n = 0; n < 10; n++) {
cy.get('#stroke_width').shadow().find('elix-number-spin-box').eq(0).shadow().find('#upButton').eq(0)
- .click({ force: true });
+ .click({ force: true })
}
- testSnapshot();
- });
+ testSnapshot()
+ })
it('check tool_polygon_change_stoke_fill_color', function () {
- cy.get('#svg_1').click({ force: true });
- cy.get('#stroke_color').shadow().find('#picker').eq(0).click({ force: true });
+ cy.get('#svg_1').click({ force: true })
+ cy.get('#stroke_color').shadow().find('#picker').eq(0).click({ force: true })
cy.get('#stroke_color').shadow().find('#color_picker').eq(0)
.find('#jGraduate_colPick').eq(0).find('#jPicker-table').eq(0)
- .find('.QuickColor').eq(51).click({ force: true });
+ .find('.QuickColor').eq(51).click({ force: true })
cy.get('#stroke_color').shadow().find('#color_picker').eq(0)
.find('#jGraduate_colPick').eq(0).find('#jPicker-table').eq(0)
- .find('#Ok').eq(0).click({ force: true });
- cy.get('#fill_color').shadow().find('#picker').eq(0).click({ force: true });
+ .find('#Ok').eq(0).click({ force: true })
+ cy.get('#fill_color').shadow().find('#picker').eq(0).click({ force: true })
cy.get('#fill_color').shadow().find('#color_picker').eq(0)
.find('#jGraduate_colPick').eq(0).find('#jPicker-table').eq(0)
- .find('.QuickColor').eq(3).click({ force: true });
+ .find('.QuickColor').eq(3).click({ force: true })
cy.get('#fill_color').shadow().find('#color_picker').eq(0)
.find('#jGraduate_colPick').eq(0).find('#jPicker-table').eq(0)
- .find('#Ok').eq(0).click({ force: true });
- testSnapshot();
- });
+ .find('#Ok').eq(0).click({ force: true })
+ testSnapshot()
+ })
it('check tool_polygon_change_sides', function () {
- cy.get('#svg_1').click({ force: true });
+ cy.get('#svg_1').click({ force: true })
cy.get('#polySides').shadow().find('elix-number-spin-box').eq(0).shadow().find('#upButton').eq(0)
- .click({ force: true });
- testSnapshot();
- });
-});
+ .click({ force: true })
+ testSnapshot()
+ })
+})
diff --git a/cypress/integration/ui/scenario7.js b/cypress/integration/ui/scenario7.js
index f2925506..30886f6f 100644
--- a/cypress/integration/ui/scenario7.js
+++ b/cypress/integration/ui/scenario7.js
@@ -1,138 +1,138 @@
import {
visitAndApproveStorage
-} from '../../support/ui-test-helper.js';
+} from '../../support/ui-test-helper.js'
const testSnapshot = () => {
- cy.get('#svgcontent').cleanSnapshot();
-};
+ cy.get('#svgcontent').cleanSnapshot()
+}
describe('use all parts of svg-edit', function () {
before(() => {
- visitAndApproveStorage();
- });
+ visitAndApproveStorage()
+ })
it('check tool_source_set', function () {
- cy.get('#tool_source').click({ force: true });
+ cy.get('#tool_source').click({ force: true })
cy.get('#svg_source_textarea')
.type('{selectall}', { force: true })
.type(``, { force: true, parseSpecialCharSequences: false });
- cy.get('#tool_source_save').click({ force: true });
- testSnapshot();
- });
+ `, { force: true, parseSpecialCharSequences: false })
+ cy.get('#tool_source_save').click({ force: true })
+ testSnapshot()
+ })
it('check tool_star', function () {
cy.get('#tool_star')
- .click({ force: true });
+ .click({ force: true })
cy.get('#svgcontent')
.trigger('mousedown', 300, 150, { force: true })
.trigger('mousemove', 300, 250, { force: true })
- .trigger('mouseup', { force: true });
- testSnapshot();
- });
+ .trigger('mouseup', { force: true })
+ testSnapshot()
+ })
it('check tool_star_clone', function () {
- cy.get('#svg_1').click({ force: true });
- cy.get('#tool_clone').click({ force: true });
- testSnapshot();
- });
+ cy.get('#svg_1').click({ force: true })
+ cy.get('#tool_clone').click({ force: true })
+ testSnapshot()
+ })
it('check tool_star_change_class', function () {
- cy.get('#svg_2').click({ force: true });
+ cy.get('#svg_2').click({ force: true })
cy.get('#elem_class').shadow().find('elix-input').eq(0).shadow().find('#inner').eq(0)
- .type('svg_2_class{enter}', { force: true });
+ .type('svg_2_class{enter}', { force: true })
cy.get('#svg_2')
.should('satisfy', ($el) => {
- const classList = Array.from($el[0].classList);
- return classList.includes('svg_2_class');
- });
- });
+ const classList = Array.from($el[0].classList)
+ return classList.includes('svg_2_class')
+ })
+ })
it('check tool_star_change_id', function () {
- cy.get('#svg_2').click({ force: true }).click({ force: true });
+ cy.get('#svg_2').click({ force: true }).click({ force: true })
cy.get('#elem_id').shadow().find('elix-input').eq(0).shadow().find('#inner').eq(0)
- .type('_id{enter}', { force: true });
+ .type('_id{enter}', { force: true })
cy.get('#svg_2_id')
.should('satisfy', ($el) => {
- const classList = Array.from($el[0].classList);
- return classList.includes('svg_2_class');
- });
- });
+ const classList = Array.from($el[0].classList)
+ return classList.includes('svg_2_class')
+ })
+ })
it('check tool_star_change_rotation', function () {
- cy.get('#svg_2_id').click({ force: true });
- for(let n = 0; n < 5; n ++){
+ cy.get('#svg_2_id').click({ force: true })
+ for (let n = 0; n < 5; n++) {
cy.get('#angle').shadow().find('elix-number-spin-box').eq(0).shadow().find('#upButton').eq(0)
- .click({ force: true });
+ .click({ force: true })
}
- testSnapshot();
- });
+ testSnapshot()
+ })
it('check tool_star_change_blur', function () {
- cy.get('#svg_2_id').click({ force: true });
- for(let n = 0; n < 10; n ++){
+ cy.get('#svg_2_id').click({ force: true })
+ for (let n = 0; n < 10; n++) {
cy.get('#blur').shadow().find('elix-number-spin-box').eq(0).shadow().find('#upButton').eq(0)
- .click({ force: true });
+ .click({ force: true })
}
- testSnapshot();
- });
+ testSnapshot()
+ })
it('check tool_star_change_opacity', function () {
- cy.get('#svg_2_id').click({ force: true });
- for(let n = 0; n < 10; n ++){
+ cy.get('#svg_2_id').click({ force: true })
+ for (let n = 0; n < 10; n++) {
cy.get('#opacity').shadow().find('elix-number-spin-box').eq(0).shadow().find('#downButton').eq(0)
- .click({ force: true });
+ .click({ force: true })
}
- testSnapshot();
- });
+ testSnapshot()
+ })
it('check tool_star_bring_to_back', function () {
- cy.get('#svg_2_id').click({ force: true });
- cy.get('#tool_move_bottom').click({ force: true });
- testSnapshot();
- });
+ cy.get('#svg_2_id').click({ force: true })
+ cy.get('#tool_move_bottom').click({ force: true })
+ testSnapshot()
+ })
it('check tool_star_bring_to_front', function () {
- cy.get('#svg_2_id').click({ force: true });
- cy.get('#tool_move_top').click({ force: true });
- testSnapshot();
- });
+ cy.get('#svg_2_id').click({ force: true })
+ cy.get('#tool_move_top').click({ force: true })
+ testSnapshot()
+ })
it('check tool_star_delete', function () {
- cy.get('#svg_2_id').click({ force: true });
- cy.get('#tool_delete').click({ force: true });
- testSnapshot();
- });
+ cy.get('#svg_2_id').click({ force: true })
+ cy.get('#tool_delete').click({ force: true })
+ testSnapshot()
+ })
it('check tool_star_align_to_page', function () {
- cy.get('#svg_1').click({ force: true });
- cy.get('#tool_position').shadow().find('elix-dropdown-list').eq(0).invoke('attr', 'opened', 'opened');
+ cy.get('#svg_1').click({ force: true })
+ cy.get('#tool_position').shadow().find('elix-dropdown-list').eq(0).invoke('attr', 'opened', 'opened')
cy.get('#tool_position').find('se-list-item').eq(0).shadow().find('elix-option').eq(0)
- .click({ force: true });
- testSnapshot();
- });
+ .click({ force: true })
+ testSnapshot()
+ })
it('check tool_star_change_stroke_width', function () {
- cy.get('#svg_1').click({ force: true });
- for(let n = 0; n < 10; n ++){
+ cy.get('#svg_1').click({ force: true })
+ for (let n = 0; n < 10; n++) {
cy.get('#stroke_width').shadow().find('elix-number-spin-box').eq(0).shadow().find('#upButton').eq(0)
- .click({ force: true });
+ .click({ force: true })
}
- testSnapshot();
- });
+ testSnapshot()
+ })
it('check tool_star_change_stoke_fill_color', function () {
- cy.get('#svg_1').click({ force: true });
- cy.get('#stroke_color').shadow().find('#picker').eq(0).click({ force: true });
+ cy.get('#svg_1').click({ force: true })
+ cy.get('#stroke_color').shadow().find('#picker').eq(0).click({ force: true })
cy.get('#stroke_color').shadow().find('#color_picker').eq(0)
.find('#jGraduate_colPick').eq(0).find('#jPicker-table').eq(0)
- .find('.QuickColor').eq(51).click({ force: true });
+ .find('.QuickColor').eq(51).click({ force: true })
cy.get('#stroke_color').shadow().find('#color_picker').eq(0)
.find('#jGraduate_colPick').eq(0).find('#jPicker-table').eq(0)
- .find('#Ok').eq(0).click({ force: true });
- cy.get('#fill_color').shadow().find('#picker').eq(0).click({ force: true });
+ .find('#Ok').eq(0).click({ force: true })
+ cy.get('#fill_color').shadow().find('#picker').eq(0).click({ force: true })
cy.get('#fill_color').shadow().find('#color_picker').eq(0)
.find('#jGraduate_colPick').eq(0).find('#jPicker-table').eq(0)
- .find('.QuickColor').eq(3).click({ force: true });
+ .find('.QuickColor').eq(3).click({ force: true })
cy.get('#fill_color').shadow().find('#color_picker').eq(0)
.find('#jGraduate_colPick').eq(0).find('#jPicker-table').eq(0)
- .find('#Ok').eq(0).click({ force: true });
- testSnapshot();
- });
+ .find('#Ok').eq(0).click({ force: true })
+ testSnapshot()
+ })
it('check tool_star_change_sides', function () {
- cy.get('#svg_1').click({ force: true });
+ cy.get('#svg_1').click({ force: true })
cy.get('#starNumPoints').shadow().find('elix-number-spin-box').eq(0).shadow().find('#upButton').eq(0)
- .click({ force: true });
- testSnapshot();
- });
-});
+ .click({ force: true })
+ testSnapshot()
+ })
+})
diff --git a/cypress/integration/ui/tool-selection.js b/cypress/integration/ui/tool-selection.js
index c2e63289..98510bfe 100644
--- a/cypress/integration/ui/tool-selection.js
+++ b/cypress/integration/ui/tool-selection.js
@@ -1,17 +1,17 @@
import {
visitAndApproveStorage
-} from '../../support/ui-test-helper.js';
+} from '../../support/ui-test-helper.js'
describe('UI - Tool selection', function () {
beforeEach(() => {
- visitAndApproveStorage();
- });
+ visitAndApproveStorage()
+ })
it('should set rectangle selection by click', function () {
cy.get('#tools_rect')
- .should('not.have.attr', 'pressed');
+ .should('not.have.attr', 'pressed')
cy.get('#tools_rect')
.trigger('click', { force: true })
- .should('have.attr', 'pressed');
- });
-});
+ .should('have.attr', 'pressed')
+ })
+})
diff --git a/cypress/integration/unit/browser-bugs/removeItem-setAttribute.js b/cypress/integration/unit/browser-bugs/removeItem-setAttribute.js
index 49648ebe..b7d68898 100644
--- a/cypress/integration/unit/browser-bugs/removeItem-setAttribute.js
+++ b/cypress/integration/unit/browser-bugs/removeItem-setAttribute.js
@@ -2,10 +2,10 @@
describe('Browser bugs', function () {
it('removeItem and setAttribute test (Chromium 843901; now fixed)', function () {
// See https://bugs.chromium.org/p/chromium/issues/detail?id=843901
- const elem = document.createElementNS('http://www.w3.org/2000/svg', 'rect');
- elem.setAttribute('transform', 'matrix(1,0,0,1,0,0)');
- elem.transform.baseVal.removeItem(0);
- elem.removeAttribute('transform');
- assert.equal(elem.hasAttribute('transform'), false);
- });
-});
+ const elem = document.createElementNS('http://www.w3.org/2000/svg', 'rect')
+ elem.setAttribute('transform', 'matrix(1,0,0,1,0,0)')
+ elem.transform.baseVal.removeItem(0)
+ elem.removeAttribute('transform')
+ assert.equal(elem.hasAttribute('transform'), false)
+ })
+})
diff --git a/cypress/integration/unit/contextmenu.js b/cypress/integration/unit/contextmenu.js
index b906ebcf..6bc728fb 100644
--- a/cypress/integration/unit/contextmenu.js
+++ b/cypress/integration/unit/contextmenu.js
@@ -1,4 +1,4 @@
-import * as contextmenu from '../../../instrumented/editor/contextmenu.js';
+import * as contextmenu from '../../../instrumented/editor/contextmenu.js'
describe('contextmenu', function () {
/**
@@ -6,53 +6,53 @@ describe('contextmenu', function () {
* @returns {void}
*/
afterEach(() => {
- contextmenu.resetCustomMenus();
- });
+ contextmenu.resetCustomMenus()
+ })
it('Test svgedit.contextmenu package', function () {
- assert.ok(contextmenu, 'contextmenu registered correctly');
- assert.ok(contextmenu.add, 'add registered correctly');
- assert.ok(contextmenu.hasCustomHandler, 'contextmenu hasCustomHandler registered correctly');
- assert.ok(contextmenu.getCustomHandler, 'contextmenu getCustomHandler registered correctly');
- });
+ assert.ok(contextmenu, 'contextmenu registered correctly')
+ assert.ok(contextmenu.add, 'add registered correctly')
+ assert.ok(contextmenu.hasCustomHandler, 'contextmenu hasCustomHandler registered correctly')
+ assert.ok(contextmenu.getCustomHandler, 'contextmenu getCustomHandler registered correctly')
+ })
it('Test svgedit.contextmenu does not add invalid menu item', function () {
assert.throws(
() => contextmenu.add({ id: 'justanid' }),
null, null,
'menu item with just an id is invalid'
- );
+ )
assert.throws(
() => contextmenu.add({ id: 'idandlabel', label: 'anicelabel' }),
null, null,
'menu item with just an id and label is invalid'
- );
+ )
assert.throws(
() => contextmenu.add({ id: 'idandlabel', label: 'anicelabel', action: 'notafunction' }),
null, null,
'menu item with action that is not a function is invalid'
- );
- });
+ )
+ })
it('Test svgedit.contextmenu adds valid menu item', function () {
- const validItem = { id: 'valid', label: 'anicelabel', action () { /* empty fn */ } };
- contextmenu.add(validItem);
+ const validItem = { id: 'valid', label: 'anicelabel', action () { /* empty fn */ } }
+ contextmenu.add(validItem)
- assert.ok(contextmenu.hasCustomHandler('valid'), 'Valid menu item is added.');
- assert.equal(contextmenu.getCustomHandler('valid'), validItem.action, 'Valid menu action is added.');
- });
+ assert.ok(contextmenu.hasCustomHandler('valid'), 'Valid menu item is added.')
+ assert.equal(contextmenu.getCustomHandler('valid'), validItem.action, 'Valid menu action is added.')
+ })
it('Test svgedit.contextmenu rejects valid duplicate menu item id', function () {
- const validItem1 = { id: 'valid', label: 'anicelabel', action () { /* empty fn */ } };
- const validItem2 = { id: 'valid', label: 'anicelabel', action () { /* empty fn */ } };
- contextmenu.add(validItem1);
+ const validItem1 = { id: 'valid', label: 'anicelabel', action () { /* empty fn */ } }
+ const validItem2 = { id: 'valid', label: 'anicelabel', action () { /* empty fn */ } }
+ contextmenu.add(validItem1)
assert.throws(
() => contextmenu.add(validItem2),
null, null,
'duplicate menu item is rejected.'
- );
- });
-});
+ )
+ })
+})
diff --git a/cypress/integration/unit/coords.js b/cypress/integration/unit/coords.js
index bee9e241..8b99e700 100644
--- a/cypress/integration/unit/coords.js
+++ b/cypress/integration/unit/coords.js
@@ -1,25 +1,25 @@
-import { NS } from '../../../instrumented/svgcanvas/namespaces.js';
-import * as utilities from '../../../instrumented/svgcanvas/utilities.js';
-import * as coords from '../../../instrumented/svgcanvas/coords.js';
+import { NS } from '../../../instrumented/svgcanvas/namespaces.js'
+import * as utilities from '../../../instrumented/svgcanvas/utilities.js'
+import * as coords from '../../../instrumented/svgcanvas/coords.js'
describe('coords', function () {
- let elemId = 1;
+ let elemId = 1
- const root = document.createElement('div');
- root.id = 'root';
- root.style.visibility = 'hidden';
- document.body.append(root);
+ const root = document.createElement('div')
+ root.id = 'root'
+ root.style.visibility = 'hidden'
+ document.body.append(root)
/**
* Set up tests with mock data.
* @returns {void}
*/
beforeEach(function () {
- const svgroot = document.createElementNS(NS.SVG, 'svg');
- svgroot.id = 'svgroot';
- root.append(svgroot);
- this.svg = document.createElementNS(NS.SVG, 'svg');
- svgroot.append(this.svg);
+ const svgroot = document.createElementNS(NS.SVG, 'svg')
+ svgroot.id = 'svgroot'
+ root.append(svgroot)
+ this.svg = document.createElementNS(NS.SVG, 'svg')
+ svgroot.append(this.svg)
// Mock out editor context.
utilities.init(
@@ -27,25 +27,25 @@ describe('coords', function () {
* @implements {module:utilities.EditorContext}
*/
{
- getSvgRoot: () => { return this.svg; },
- getDOMDocument () { return null; },
- getDOMContainer () { return null; }
+ getSvgRoot: () => { return this.svg },
+ getDOMDocument () { return null },
+ getDOMContainer () { return null }
}
- );
+ )
coords.init(
/**
* @implements {module:coords.EditorContext}
*/
{
- getGridSnapping () { return false; },
+ getGridSnapping () { return false },
getDrawing () {
return {
- getNextId () { return String(elemId++); }
- };
+ getNextId () { return String(elemId++) }
+ }
}
}
- );
- });
+ )
+ })
/**
* Tear down tests, removing elements.
@@ -53,255 +53,255 @@ describe('coords', function () {
*/
afterEach(function () {
while (this.svg.hasChildNodes()) {
- this.svg.firstChild.remove();
+ this.svg.firstChild.remove()
}
- });
+ })
it('Test remapElement(translate) for rect', function () {
- const rect = document.createElementNS(NS.SVG, 'rect');
- rect.setAttribute('x', '200');
- rect.setAttribute('y', '150');
- rect.setAttribute('width', '250');
- rect.setAttribute('height', '120');
- this.svg.append(rect);
+ const rect = document.createElementNS(NS.SVG, 'rect')
+ rect.setAttribute('x', '200')
+ rect.setAttribute('y', '150')
+ rect.setAttribute('width', '250')
+ rect.setAttribute('height', '120')
+ this.svg.append(rect)
const attrs = {
x: '200',
y: '150',
width: '125',
height: '75'
- };
+ }
// Create a translate.
- const m = this.svg.createSVGMatrix();
- m.a = 1; m.b = 0;
- m.c = 0; m.d = 1;
- m.e = 100; m.f = -50;
+ const m = this.svg.createSVGMatrix()
+ m.a = 1; m.b = 0
+ m.c = 0; m.d = 1
+ m.e = 100; m.f = -50
- coords.remapElement(rect, attrs, m);
+ coords.remapElement(rect, attrs, m)
- assert.equal(rect.getAttribute('x'), '300');
- assert.equal(rect.getAttribute('y'), '100');
- assert.equal(rect.getAttribute('width'), '125');
- assert.equal(rect.getAttribute('height'), '75');
- });
+ assert.equal(rect.getAttribute('x'), '300')
+ assert.equal(rect.getAttribute('y'), '100')
+ assert.equal(rect.getAttribute('width'), '125')
+ assert.equal(rect.getAttribute('height'), '75')
+ })
it('Test remapElement(scale) for rect', function () {
- const rect = document.createElementNS(NS.SVG, 'rect');
- rect.setAttribute('width', '250');
- rect.setAttribute('height', '120');
- this.svg.append(rect);
+ const rect = document.createElementNS(NS.SVG, 'rect')
+ rect.setAttribute('width', '250')
+ rect.setAttribute('height', '120')
+ this.svg.append(rect)
const attrs = {
x: '0',
y: '0',
width: '250',
height: '120'
- };
+ }
// Create a translate.
- const m = this.svg.createSVGMatrix();
- m.a = 2; m.b = 0;
- m.c = 0; m.d = 0.5;
- m.e = 0; m.f = 0;
+ const m = this.svg.createSVGMatrix()
+ m.a = 2; m.b = 0
+ m.c = 0; m.d = 0.5
+ m.e = 0; m.f = 0
- coords.remapElement(rect, attrs, m);
+ coords.remapElement(rect, attrs, m)
- assert.equal(rect.getAttribute('x'), '0');
- assert.equal(rect.getAttribute('y'), '0');
- assert.equal(rect.getAttribute('width'), '500');
- assert.equal(rect.getAttribute('height'), '60');
- });
+ assert.equal(rect.getAttribute('x'), '0')
+ assert.equal(rect.getAttribute('y'), '0')
+ assert.equal(rect.getAttribute('width'), '500')
+ assert.equal(rect.getAttribute('height'), '60')
+ })
it('Test remapElement(translate) for circle', function () {
- const circle = document.createElementNS(NS.SVG, 'circle');
- circle.setAttribute('cx', '200');
- circle.setAttribute('cy', '150');
- circle.setAttribute('r', '125');
- this.svg.append(circle);
+ const circle = document.createElementNS(NS.SVG, 'circle')
+ circle.setAttribute('cx', '200')
+ circle.setAttribute('cy', '150')
+ circle.setAttribute('r', '125')
+ this.svg.append(circle)
const attrs = {
cx: '200',
cy: '150',
r: '125'
- };
+ }
// Create a translate.
- const m = this.svg.createSVGMatrix();
- m.a = 1; m.b = 0;
- m.c = 0; m.d = 1;
- m.e = 100; m.f = -50;
+ const m = this.svg.createSVGMatrix()
+ m.a = 1; m.b = 0
+ m.c = 0; m.d = 1
+ m.e = 100; m.f = -50
- coords.remapElement(circle, attrs, m);
+ coords.remapElement(circle, attrs, m)
- assert.equal(circle.getAttribute('cx'), '300');
- assert.equal(circle.getAttribute('cy'), '100');
- assert.equal(circle.getAttribute('r'), '125');
- });
+ assert.equal(circle.getAttribute('cx'), '300')
+ assert.equal(circle.getAttribute('cy'), '100')
+ assert.equal(circle.getAttribute('r'), '125')
+ })
it('Test remapElement(scale) for circle', function () {
- const circle = document.createElementNS(NS.SVG, 'circle');
- circle.setAttribute('cx', '200');
- circle.setAttribute('cy', '150');
- circle.setAttribute('r', '250');
- this.svg.append(circle);
+ const circle = document.createElementNS(NS.SVG, 'circle')
+ circle.setAttribute('cx', '200')
+ circle.setAttribute('cy', '150')
+ circle.setAttribute('r', '250')
+ this.svg.append(circle)
const attrs = {
cx: '200',
cy: '150',
r: '250'
- };
+ }
// Create a translate.
- const m = this.svg.createSVGMatrix();
- m.a = 2; m.b = 0;
- m.c = 0; m.d = 0.5;
- m.e = 0; m.f = 0;
+ const m = this.svg.createSVGMatrix()
+ m.a = 2; m.b = 0
+ m.c = 0; m.d = 0.5
+ m.e = 0; m.f = 0
- coords.remapElement(circle, attrs, m);
+ coords.remapElement(circle, attrs, m)
- assert.equal(circle.getAttribute('cx'), '400');
- assert.equal(circle.getAttribute('cy'), '75');
+ assert.equal(circle.getAttribute('cx'), '400')
+ assert.equal(circle.getAttribute('cy'), '75')
// Radius is the minimum that fits in the new bounding box.
- assert.equal(circle.getAttribute('r'), '125');
- });
+ assert.equal(circle.getAttribute('r'), '125')
+ })
it('Test remapElement(translate) for ellipse', function () {
- const ellipse = document.createElementNS(NS.SVG, 'ellipse');
- ellipse.setAttribute('cx', '200');
- ellipse.setAttribute('cy', '150');
- ellipse.setAttribute('rx', '125');
- ellipse.setAttribute('ry', '75');
- this.svg.append(ellipse);
+ const ellipse = document.createElementNS(NS.SVG, 'ellipse')
+ ellipse.setAttribute('cx', '200')
+ ellipse.setAttribute('cy', '150')
+ ellipse.setAttribute('rx', '125')
+ ellipse.setAttribute('ry', '75')
+ this.svg.append(ellipse)
const attrs = {
cx: '200',
cy: '150',
rx: '125',
ry: '75'
- };
+ }
// Create a translate.
- const m = this.svg.createSVGMatrix();
- m.a = 1; m.b = 0;
- m.c = 0; m.d = 1;
- m.e = 100; m.f = -50;
+ const m = this.svg.createSVGMatrix()
+ m.a = 1; m.b = 0
+ m.c = 0; m.d = 1
+ m.e = 100; m.f = -50
- coords.remapElement(ellipse, attrs, m);
+ coords.remapElement(ellipse, attrs, m)
- assert.equal(ellipse.getAttribute('cx'), '300');
- assert.equal(ellipse.getAttribute('cy'), '100');
- assert.equal(ellipse.getAttribute('rx'), '125');
- assert.equal(ellipse.getAttribute('ry'), '75');
- });
+ assert.equal(ellipse.getAttribute('cx'), '300')
+ assert.equal(ellipse.getAttribute('cy'), '100')
+ assert.equal(ellipse.getAttribute('rx'), '125')
+ assert.equal(ellipse.getAttribute('ry'), '75')
+ })
it('Test remapElement(scale) for ellipse', function () {
- const ellipse = document.createElementNS(NS.SVG, 'ellipse');
- ellipse.setAttribute('cx', '200');
- ellipse.setAttribute('cy', '150');
- ellipse.setAttribute('rx', '250');
- ellipse.setAttribute('ry', '120');
- this.svg.append(ellipse);
+ const ellipse = document.createElementNS(NS.SVG, 'ellipse')
+ ellipse.setAttribute('cx', '200')
+ ellipse.setAttribute('cy', '150')
+ ellipse.setAttribute('rx', '250')
+ ellipse.setAttribute('ry', '120')
+ this.svg.append(ellipse)
const attrs = {
cx: '200',
cy: '150',
rx: '250',
ry: '120'
- };
+ }
// Create a translate.
- const m = this.svg.createSVGMatrix();
- m.a = 2; m.b = 0;
- m.c = 0; m.d = 0.5;
- m.e = 0; m.f = 0;
+ const m = this.svg.createSVGMatrix()
+ m.a = 2; m.b = 0
+ m.c = 0; m.d = 0.5
+ m.e = 0; m.f = 0
- coords.remapElement(ellipse, attrs, m);
+ coords.remapElement(ellipse, attrs, m)
- assert.equal(ellipse.getAttribute('cx'), '400');
- assert.equal(ellipse.getAttribute('cy'), '75');
- assert.equal(ellipse.getAttribute('rx'), '500');
- assert.equal(ellipse.getAttribute('ry'), '60');
- });
+ assert.equal(ellipse.getAttribute('cx'), '400')
+ assert.equal(ellipse.getAttribute('cy'), '75')
+ assert.equal(ellipse.getAttribute('rx'), '500')
+ assert.equal(ellipse.getAttribute('ry'), '60')
+ })
it('Test remapElement(translate) for line', function () {
- const line = document.createElementNS(NS.SVG, 'line');
- line.setAttribute('x1', '50');
- line.setAttribute('y1', '100');
- line.setAttribute('x2', '120');
- line.setAttribute('y2', '200');
- this.svg.append(line);
+ const line = document.createElementNS(NS.SVG, 'line')
+ line.setAttribute('x1', '50')
+ line.setAttribute('y1', '100')
+ line.setAttribute('x2', '120')
+ line.setAttribute('y2', '200')
+ this.svg.append(line)
const attrs = {
x1: '50',
y1: '100',
x2: '120',
y2: '200'
- };
+ }
// Create a translate.
- const m = this.svg.createSVGMatrix();
- m.a = 1; m.b = 0;
- m.c = 0; m.d = 1;
- m.e = 100; m.f = -50;
+ const m = this.svg.createSVGMatrix()
+ m.a = 1; m.b = 0
+ m.c = 0; m.d = 1
+ m.e = 100; m.f = -50
- coords.remapElement(line, attrs, m);
+ coords.remapElement(line, attrs, m)
- assert.equal(line.getAttribute('x1'), '150');
- assert.equal(line.getAttribute('y1'), '50');
- assert.equal(line.getAttribute('x2'), '220');
- assert.equal(line.getAttribute('y2'), '150');
- });
+ assert.equal(line.getAttribute('x1'), '150')
+ assert.equal(line.getAttribute('y1'), '50')
+ assert.equal(line.getAttribute('x2'), '220')
+ assert.equal(line.getAttribute('y2'), '150')
+ })
it('Test remapElement(scale) for line', function () {
- const line = document.createElementNS(NS.SVG, 'line');
- line.setAttribute('x1', '50');
- line.setAttribute('y1', '100');
- line.setAttribute('x2', '120');
- line.setAttribute('y2', '200');
- this.svg.append(line);
+ const line = document.createElementNS(NS.SVG, 'line')
+ line.setAttribute('x1', '50')
+ line.setAttribute('y1', '100')
+ line.setAttribute('x2', '120')
+ line.setAttribute('y2', '200')
+ this.svg.append(line)
const attrs = {
x1: '50',
y1: '100',
x2: '120',
y2: '200'
- };
+ }
// Create a translate.
- const m = this.svg.createSVGMatrix();
- m.a = 2; m.b = 0;
- m.c = 0; m.d = 0.5;
- m.e = 0; m.f = 0;
+ const m = this.svg.createSVGMatrix()
+ m.a = 2; m.b = 0
+ m.c = 0; m.d = 0.5
+ m.e = 0; m.f = 0
- coords.remapElement(line, attrs, m);
+ coords.remapElement(line, attrs, m)
- assert.equal(line.getAttribute('x1'), '100');
- assert.equal(line.getAttribute('y1'), '50');
- assert.equal(line.getAttribute('x2'), '240');
- assert.equal(line.getAttribute('y2'), '100');
- });
+ assert.equal(line.getAttribute('x1'), '100')
+ assert.equal(line.getAttribute('y1'), '50')
+ assert.equal(line.getAttribute('x2'), '240')
+ assert.equal(line.getAttribute('y2'), '100')
+ })
it('Test remapElement(translate) for text', function () {
- const text = document.createElementNS(NS.SVG, 'text');
- text.setAttribute('x', '50');
- text.setAttribute('y', '100');
- this.svg.append(text);
+ const text = document.createElementNS(NS.SVG, 'text')
+ text.setAttribute('x', '50')
+ text.setAttribute('y', '100')
+ this.svg.append(text)
const attrs = {
x: '50',
y: '100'
- };
+ }
// Create a translate.
- const m = this.svg.createSVGMatrix();
- m.a = 1; m.b = 0;
- m.c = 0; m.d = 1;
- m.e = 100; m.f = -50;
+ const m = this.svg.createSVGMatrix()
+ m.a = 1; m.b = 0
+ m.c = 0; m.d = 1
+ m.e = 100; m.f = -50
- coords.remapElement(text, attrs, m);
+ coords.remapElement(text, attrs, m)
- assert.equal(text.getAttribute('x'), '150');
- assert.equal(text.getAttribute('y'), '50');
- });
-});
+ assert.equal(text.getAttribute('x'), '150')
+ assert.equal(text.getAttribute('y'), '50')
+ })
+})
diff --git a/cypress/integration/unit/draw.js b/cypress/integration/unit/draw.js
index 17fb5850..411fa8f2 100644
--- a/cypress/integration/unit/draw.js
+++ b/cypress/integration/unit/draw.js
@@ -1,21 +1,21 @@
-import 'pathseg';
-import { NS } from '../../../instrumented/svgcanvas/namespaces.js';
-import * as draw from '../../../instrumented/svgcanvas/draw.js';
-import * as units from '../../../instrumented/common/units.js';
+import 'pathseg'
+import { NS } from '../../../instrumented/svgcanvas/namespaces.js'
+import * as draw from '../../../instrumented/svgcanvas/draw.js'
+import * as units from '../../../instrumented/common/units.js'
describe('draw.Drawing', function () {
const addOwnSpies = (obj) => {
- const methods = Object.keys(obj);
+ const methods = Object.keys(obj)
methods.forEach((method) => {
- cy.spy(obj, method);
- });
- };
+ cy.spy(obj, method)
+ })
+ }
- const LAYER_CLASS = draw.Layer.CLASS_NAME;
- const NONCE = 'foo';
- const LAYER1 = 'Layer 1';
- const LAYER2 = 'Layer 2';
- const LAYER3 = 'Layer 3';
+ const LAYER_CLASS = draw.Layer.CLASS_NAME
+ const NONCE = 'foo'
+ const LAYER1 = 'Layer 1'
+ const LAYER2 = 'Layer 2'
+ const LAYER3 = 'Layer 3'
const PATH_ATTR = {
// clone will convert relative to absolute, so the test for equality fails.
// d: 'm7.38867,57.38867c0,-27.62431 22.37569,-50 50,-50c27.62431,0 50,22.37569 50,50c0,27.62431 -22.37569,50 -50,50c-27.62431,0 -50,-22.37569 -50,-50z',
@@ -24,7 +24,7 @@ describe('draw.Drawing', function () {
'stroke-width': '5',
stroke: '#660000',
fill: '#ff0000'
- };
+ }
units.init(
/**
@@ -32,17 +32,17 @@ describe('draw.Drawing', function () {
*/
{
// used by units.shortFloat - call path: cloneLayer -> copyElem -> convertPath -> pathDSegment -> shortFloat
- getRoundDigits () { return 3; }
+ getRoundDigits () { return 3 }
}
- );
+ )
// Simplifying from svgcanvas.js usage
- const idprefix = 'svg_';
+ const idprefix = 'svg_'
const getCurrentDrawing = function () {
- return currentDrawing_;
- };
- const setCurrentGroup = () => { /* empty fn */ };
+ return currentDrawing_
+ }
+ const setCurrentGroup = () => { /* empty fn */ }
draw.init(
/**
* @implements {module:draw.DrawCanvasInit}
@@ -51,41 +51,41 @@ describe('draw.Drawing', function () {
getCurrentDrawing,
setCurrentGroup
}
- );
+ )
/**
* @param {module:utilities.SVGElementJSON} jsonMap
* @returns {SVGElement}
*/
function createSVGElement (jsonMap) {
- const elem = document.createElementNS(NS.SVG, jsonMap.element);
- Object.entries(jsonMap.attr).forEach(([ attr, value ]) => {
- elem.setAttribute(attr, value);
- });
- return elem;
+ const elem = document.createElementNS(NS.SVG, jsonMap.element)
+ Object.entries(jsonMap.attr).forEach(([attr, value]) => {
+ elem.setAttribute(attr, value)
+ })
+ return elem
}
const setupSVGWith3Layers = function (svgElem) {
- const layer1 = document.createElementNS(NS.SVG, 'g');
- const layer1Title = document.createElementNS(NS.SVG, 'title');
- layer1Title.append(LAYER1);
- layer1.append(layer1Title);
- svgElem.append(layer1);
+ const layer1 = document.createElementNS(NS.SVG, 'g')
+ const layer1Title = document.createElementNS(NS.SVG, 'title')
+ layer1Title.append(LAYER1)
+ layer1.append(layer1Title)
+ svgElem.append(layer1)
- const layer2 = document.createElementNS(NS.SVG, 'g');
- const layer2Title = document.createElementNS(NS.SVG, 'title');
- layer2Title.append(LAYER2);
- layer2.append(layer2Title);
- svgElem.append(layer2);
+ const layer2 = document.createElementNS(NS.SVG, 'g')
+ const layer2Title = document.createElementNS(NS.SVG, 'title')
+ layer2Title.append(LAYER2)
+ layer2.append(layer2Title)
+ svgElem.append(layer2)
- const layer3 = document.createElementNS(NS.SVG, 'g');
- const layer3Title = document.createElementNS(NS.SVG, 'title');
- layer3Title.append(LAYER3);
- layer3.append(layer3Title);
- svgElem.append(layer3);
+ const layer3 = document.createElementNS(NS.SVG, 'g')
+ const layer3Title = document.createElementNS(NS.SVG, 'title')
+ layer3Title.append(LAYER3)
+ layer3.append(layer3Title)
+ svgElem.append(layer3)
- return [ layer1, layer2, layer3 ];
- };
+ return [layer1, layer2, layer3]
+ }
const createSomeElementsInGroup = function (group) {
group.append(
@@ -105,399 +105,399 @@ describe('draw.Drawing', function () {
element: 'line',
attr: { x1: '0', y1: '1', x2: '5', y2: '6' }
})
- );
+ )
const g = createSVGElement({
element: 'g',
attr: {}
- });
+ })
g.append(createSVGElement({
element: 'rect',
attr: { x: '0', y: '1', width: '5', height: '10' }
- }));
- group.append(g);
- return 4;
- };
+ }))
+ group.append(g)
+ return 4
+ }
const cleanupSVG = function (svgElem) {
- while (svgElem.firstChild) { svgElem.firstChild.remove(); }
- };
+ while (svgElem.firstChild) { svgElem.firstChild.remove() }
+ }
- let sandbox; let currentDrawing_; let svg; let svgN;
+ let sandbox; let currentDrawing_; let svg; let svgN
beforeEach(() => {
- sandbox = document.createElement('div');
- sandbox.id = 'sandbox';
- sandbox.style.visibility = 'hidden';
+ sandbox = document.createElement('div')
+ sandbox.id = 'sandbox'
+ sandbox.style.visibility = 'hidden'
- svg = document.createElementNS(NS.SVG, 'svg');
+ svg = document.createElementNS(NS.SVG, 'svg')
// Firefox throws exception in getBBox() when svg is not attached to DOM.
- sandbox.append(svg);
+ sandbox.append(svg)
// Set up '
- );
+ )
svgCanvas.importSvgString(
'' +
@@ -240,24 +240,24 @@ describe('Basic Module', function () {
'' +
'' +
''
- );
+ )
- const svgContent = document.getElementById('svgcontent');
- const circles = svgContent.getElementsByTagNameNS(svgns, 'circle');
- const rects = svgContent.getElementsByTagNameNS(svgns, 'rect');
+ const svgContent = document.getElementById('svgcontent')
+ const circles = svgContent.getElementsByTagNameNS(svgns, 'circle')
+ const rects = svgContent.getElementsByTagNameNS(svgns, 'rect')
// ellipses = svgContent.getElementsByTagNameNS(svgns, 'ellipse'),
- const defs = svgContent.getElementsByTagNameNS(svgns, 'defs');
+ const defs = svgContent.getElementsByTagNameNS(svgns, 'defs')
// grads = svgContent.getElementsByTagNameNS(svgns, 'linearGradient'),
- const uses = svgContent.getElementsByTagNameNS(svgns, 'use');
- assert.notEqual(circles.item(0).id, 'svg_1', 'Circle not re-identified');
- assert.notEqual(rects.item(0).id, 'svg_3', 'Rectangle not re-identified');
+ const uses = svgContent.getElementsByTagNameNS(svgns, 'use')
+ assert.notEqual(circles.item(0).id, 'svg_1', 'Circle not re-identified')
+ assert.notEqual(rects.item(0).id, 'svg_3', 'Rectangle not re-identified')
// TODO: determine why this test fails in WebKit browsers
// assert.equal(grads.length, 1, 'Linear gradient imported');
- const grad = defs.item(0).firstChild;
- assert.notEqual(grad.id, 'svg_2', 'Linear gradient not re-identified');
- assert.notEqual(circles.item(0).getAttribute('fill'), 'url(#svg_2)', 'Circle fill value not remapped');
- assert.notEqual(rects.item(0).getAttribute('stroke'), 'url(#svg_2)', 'Rectangle stroke value not remapped');
- assert.notEqual(uses.item(0).getAttributeNS(xlinkns, 'href'), '#svg_3');
- });
- });
-});
+ const grad = defs.item(0).firstChild
+ assert.notEqual(grad.id, 'svg_2', 'Linear gradient not re-identified')
+ assert.notEqual(circles.item(0).getAttribute('fill'), 'url(#svg_2)', 'Circle fill value not remapped')
+ assert.notEqual(rects.item(0).getAttribute('stroke'), 'url(#svg_2)', 'Rectangle stroke value not remapped')
+ assert.notEqual(uses.item(0).getAttributeNS(xlinkns, 'href'), '#svg_3')
+ })
+ })
+})
diff --git a/cypress/integration/unit/units.js b/cypress/integration/unit/units.js
index 99e2e7bd..91b1412a 100644
--- a/cypress/integration/unit/units.js
+++ b/cypress/integration/unit/units.js
@@ -1,4 +1,4 @@
-import * as units from '../../../instrumented/common/units.js';
+import * as units from '../../../instrumented/common/units.js'
describe('units', function () {
/**
@@ -6,86 +6,86 @@ describe('units', function () {
* @returns {void}
*/
beforeEach(() => {
- document.body.textContent = '';
- const anchor = document.createElement('div');
- anchor.id = 'anchor';
- anchor.style.visibility = 'hidden';
+ document.body.textContent = ''
+ const anchor = document.createElement('div')
+ anchor.id = 'anchor'
+ anchor.style.visibility = 'hidden'
- const elementsContainer = document.createElement('div');
- elementsContainer.id = 'elementsContainer';
+ const elementsContainer = document.createElement('div')
+ elementsContainer.id = 'elementsContainer'
- const uniqueId = document.createElement('div');
- uniqueId.id = 'uniqueId';
- uniqueId.style.visibility = 'hidden';
+ const uniqueId = document.createElement('div')
+ uniqueId.id = 'uniqueId'
+ uniqueId.style.visibility = 'hidden'
- const nonUniqueId = document.createElement('div');
- nonUniqueId.id = 'nonUniqueId';
- nonUniqueId.style.visibility = 'hidden';
+ const nonUniqueId = document.createElement('div')
+ nonUniqueId.id = 'nonUniqueId'
+ nonUniqueId.style.visibility = 'hidden'
- elementsContainer.append(uniqueId, nonUniqueId);
+ elementsContainer.append(uniqueId, nonUniqueId)
- document.body.append(anchor, elementsContainer);
+ document.body.append(anchor, elementsContainer)
units.init(
/**
* @implements {module:units.ElementContainer}
*/
{
- getBaseUnit () { return 'cm'; },
- getHeight () { return 600; },
- getWidth () { return 800; },
- getRoundDigits () { return 4; },
- getElement (elementId) { return document.getElementById(elementId); }
+ getBaseUnit () { return 'cm' },
+ getHeight () { return 600 },
+ getWidth () { return 800 },
+ getRoundDigits () { return 4 },
+ getElement (elementId) { return document.getElementById(elementId) }
}
- );
- });
+ )
+ })
it('Test svgedit.units package', function () {
- assert.ok(units);
- assert.equal(typeof units, typeof {});
- });
+ assert.ok(units)
+ assert.equal(typeof units, typeof {})
+ })
it('Test svgedit.units.shortFloat()', function () {
- assert.ok(units.shortFloat);
- assert.equal(typeof units.shortFloat, typeof function () { /* empty fn */ });
+ assert.ok(units.shortFloat)
+ assert.equal(typeof units.shortFloat, typeof function () { /* empty fn */ })
- const { shortFloat } = units;
- assert.equal(shortFloat(0.00000001), 0);
- assert.equal(shortFloat(1), 1);
- assert.equal(shortFloat(3.45678), 3.4568);
- assert.equal(shortFloat(1.23443), 1.2344);
- assert.equal(shortFloat(1.23455), 1.2346);
- });
+ const { shortFloat } = units
+ assert.equal(shortFloat(0.00000001), 0)
+ assert.equal(shortFloat(1), 1)
+ assert.equal(shortFloat(3.45678), 3.4568)
+ assert.equal(shortFloat(1.23443), 1.2344)
+ assert.equal(shortFloat(1.23455), 1.2346)
+ })
it('Test svgedit.units.isValidUnit()', function () {
- assert.ok(units.isValidUnit);
- assert.equal(typeof units.isValidUnit, typeof function () { /* empty fn */ });
+ assert.ok(units.isValidUnit)
+ assert.equal(typeof units.isValidUnit, typeof function () { /* empty fn */ })
- const { isValidUnit } = units;
- assert.ok(isValidUnit('0'));
- assert.ok(isValidUnit('1'));
- assert.ok(isValidUnit('1.1'));
- assert.ok(isValidUnit('-1.1'));
- assert.ok(isValidUnit('.6mm'));
- assert.ok(isValidUnit('-.6cm'));
- assert.ok(isValidUnit('6000in'));
- assert.ok(isValidUnit('6px'));
- assert.ok(isValidUnit('6.3pc'));
- assert.ok(isValidUnit('-0.4em'));
- assert.ok(isValidUnit('-0.ex'));
- assert.ok(isValidUnit('40.123%'));
+ const { isValidUnit } = units
+ assert.ok(isValidUnit('0'))
+ assert.ok(isValidUnit('1'))
+ assert.ok(isValidUnit('1.1'))
+ assert.ok(isValidUnit('-1.1'))
+ assert.ok(isValidUnit('.6mm'))
+ assert.ok(isValidUnit('-.6cm'))
+ assert.ok(isValidUnit('6000in'))
+ assert.ok(isValidUnit('6px'))
+ assert.ok(isValidUnit('6.3pc'))
+ assert.ok(isValidUnit('-0.4em'))
+ assert.ok(isValidUnit('-0.ex'))
+ assert.ok(isValidUnit('40.123%'))
- assert.equal(isValidUnit('id', 'uniqueId', document.getElementById('uniqueId')), true);
- assert.equal(isValidUnit('id', 'newId', document.getElementById('uniqueId')), true);
- assert.equal(isValidUnit('id', 'uniqueId'), false);
- assert.equal(isValidUnit('id', 'uniqueId', document.getElementById('nonUniqueId')), false);
- });
+ assert.equal(isValidUnit('id', 'uniqueId', document.getElementById('uniqueId')), true)
+ assert.equal(isValidUnit('id', 'newId', document.getElementById('uniqueId')), true)
+ assert.equal(isValidUnit('id', 'uniqueId'), false)
+ assert.equal(isValidUnit('id', 'uniqueId', document.getElementById('nonUniqueId')), false)
+ })
it('Test svgedit.units.convertUnit()', function () {
- assert.ok(units.convertUnit);
- assert.equal(typeof units.convertUnit, typeof function () { /* empty fn */ });
+ assert.ok(units.convertUnit)
+ assert.equal(typeof units.convertUnit, typeof function () { /* empty fn */ })
// cm in default setup
- assert.equal(units.convertUnit(42), 1.1113);
- assert.equal(units.convertUnit(42, 'px'), 42);
- });
-});
+ assert.equal(units.convertUnit(42), 1.1113)
+ assert.equal(units.convertUnit(42, 'px'), 42)
+ })
+})
diff --git a/cypress/integration/unit/utilities-bbox.js b/cypress/integration/unit/utilities-bbox.js
index 40786c82..1f43f78e 100644
--- a/cypress/integration/unit/utilities-bbox.js
+++ b/cypress/integration/unit/utilities-bbox.js
@@ -1,12 +1,13 @@
-import 'pathseg';
+import 'pathseg'
-import { NS } from '../../../instrumented/svgcanvas/namespaces.js';
-import * as utilities from '../../../instrumented/svgcanvas/utilities.js';
-import * as math from '../../../instrumented/svgcanvas/math.js';
-import * as path from '../../../instrumented/svgcanvas/path.js';
-import setAssertionMethods from '../../support/assert-close.js';
+import { NS } from '../../../instrumented/svgcanvas/namespaces.js'
+import * as utilities from '../../../instrumented/svgcanvas/utilities.js'
+import * as math from '../../../instrumented/svgcanvas/math.js'
+import * as path from '../../../instrumented/svgcanvas/path.js'
+import setAssertionMethods from '../../support/assert-close.js'
-chai.use(setAssertionMethods);
+// eslint-disable-next-line
+chai.use(setAssertionMethods)
describe('utilities bbox', function () {
/**
@@ -15,13 +16,13 @@ describe('utilities bbox', function () {
* @returns {SVGElement}
*/
function mockCreateSVGElement (jsonMap) {
- const elem = document.createElementNS(NS.SVG, jsonMap.element);
- Object.entries(jsonMap.attr).forEach(([ attr, value ]) => {
- elem.setAttribute(attr, value);
- });
- return elem;
+ const elem = document.createElementNS(NS.SVG, jsonMap.element)
+ Object.entries(jsonMap.attr).forEach(([attr, value]) => {
+ elem.setAttribute(attr, value)
+ })
+ return elem
}
- let mockaddSVGElemensFromJsonCallCount = 0;
+ let mockaddSVGElemensFromJsonCallCount = 0
/**
* Mock of {@link module:utilities.EditorContext#addSVGElemensFromJson}.
@@ -29,435 +30,435 @@ describe('utilities bbox', function () {
* @returns {SVGElement}
*/
function mockaddSVGElemensFromJson (json) {
- const elem = mockCreateSVGElement(json);
- svgroot.append(elem);
- mockaddSVGElemensFromJsonCallCount++;
- return elem;
+ const elem = mockCreateSVGElement(json)
+ svgroot.append(elem)
+ mockaddSVGElemensFromJsonCallCount++
+ return elem
}
const mockPathActions = {
resetOrientation (pth) {
- if (utilities.isNullish(pth) || pth.nodeName !== 'path') { return false; }
- const tlist = pth.transform.baseVal;
- const m = math.transformListToTransform(tlist).matrix;
- tlist.clear();
- pth.removeAttribute('transform');
- const segList = pth.pathSegList;
+ if (utilities.isNullish(pth) || pth.nodeName !== 'path') { return false }
+ const tlist = pth.transform.baseVal
+ const m = math.transformListToTransform(tlist).matrix
+ tlist.clear()
+ pth.removeAttribute('transform')
+ const segList = pth.pathSegList
- const len = segList.numberOfItems;
+ const len = segList.numberOfItems
// let lastX, lastY;
for (let i = 0; i < len; ++i) {
- const seg = segList.getItem(i);
- const type = seg.pathSegType;
- if (type === 1) { continue; }
+ const seg = segList.getItem(i)
+ const type = seg.pathSegType
+ if (type === 1) { continue }
const pts = [];
- [ '', 1, 2 ].forEach(function (n) {
- const x = seg['x' + n]; const y = seg['y' + n];
+ ['', 1, 2].forEach(function (n) {
+ const x = seg['x' + n]; const y = seg['y' + n]
if (x !== undefined && y !== undefined) {
- const pt = math.transformPoint(x, y, m);
- pts.splice(pts.length, 0, pt.x, pt.y);
+ const pt = math.transformPoint(x, y, m)
+ pts.splice(pts.length, 0, pt.x, pt.y)
}
- });
- path.replacePathSeg(type, i, pts, pth);
+ })
+ path.replacePathSeg(type, i, pts, pth)
}
- return undefined;
+ return undefined
}
- };
+ }
- const EPSILON = 0.001;
+ const EPSILON = 0.001
- let svgroot;
+ let svgroot
beforeEach(() => {
- document.body.textContent = '';
+ document.body.textContent = ''
// const svg = document.createElementNS(NS.SVG, 'svg');
- const sandbox = document.createElement('div');
- sandbox.id = 'sandbox';
- document.body.append(sandbox);
+ const sandbox = document.createElement('div')
+ sandbox.id = 'sandbox'
+ document.body.append(sandbox)
svgroot = mockCreateSVGElement({
element: 'svg',
attr: { id: 'svgroot' }
- });
- sandbox.append(svgroot);
+ })
+ sandbox.append(svgroot)
const mockSvgCanvas = {
createSVGElement (jsonMap) {
- const elem = document.createElementNS(NS.SVG, jsonMap.element);
- Object.entries(jsonMap.attr).forEach(([ attr, value ]) => {
- elem.setAttribute(attr, value);
- });
- return elem;
+ const elem = document.createElementNS(NS.SVG, jsonMap.element)
+ Object.entries(jsonMap.attr).forEach(([attr, value]) => {
+ elem.setAttribute(attr, value)
+ })
+ return elem
},
- getSvgRoot () { return svgroot; }
- };
+ getSvgRoot () { return svgroot }
+ }
- path.init(mockSvgCanvas);
- mockaddSVGElemensFromJsonCallCount = 0;
- });
+ path.init(mockSvgCanvas)
+ mockaddSVGElemensFromJsonCallCount = 0
+ })
it('Test svgedit.utilities package', function () {
- assert.ok(utilities);
- assert.ok(utilities.getBBoxWithTransform);
- assert.ok(utilities.getStrokedBBox);
- assert.ok(utilities.getRotationAngleFromTransformList);
- assert.ok(utilities.getRotationAngle);
- });
+ assert.ok(utilities)
+ assert.ok(utilities.getBBoxWithTransform)
+ assert.ok(utilities.getStrokedBBox)
+ assert.ok(utilities.getRotationAngleFromTransformList)
+ assert.ok(utilities.getRotationAngle)
+ })
it('Test getBBoxWithTransform and no transform', function () {
- const { getBBoxWithTransform } = utilities;
+ const { getBBoxWithTransform } = utilities
let elem = mockCreateSVGElement({
element: 'path',
attr: { id: 'path', d: 'M0,1 L2,3' }
- });
- svgroot.append(elem);
- let bbox = getBBoxWithTransform(elem, mockaddSVGElemensFromJson, mockPathActions);
- assert.deepEqual(bbox, { x: 0, y: 1, width: 2, height: 2 });
- assert.equal(mockaddSVGElemensFromJsonCallCount, 0);
- elem.remove();
+ })
+ svgroot.append(elem)
+ let bbox = getBBoxWithTransform(elem, mockaddSVGElemensFromJson, mockPathActions)
+ assert.deepEqual(bbox, { x: 0, y: 1, width: 2, height: 2 })
+ assert.equal(mockaddSVGElemensFromJsonCallCount, 0)
+ elem.remove()
elem = mockCreateSVGElement({
element: 'rect',
attr: { id: 'rect', x: '0', y: '1', width: '5', height: '10' }
- });
- svgroot.append(elem);
- bbox = getBBoxWithTransform(elem, mockaddSVGElemensFromJson, mockPathActions);
- assert.deepEqual(bbox, { x: 0, y: 1, width: 5, height: 10 });
- assert.equal(mockaddSVGElemensFromJsonCallCount, 0);
- elem.remove();
+ })
+ svgroot.append(elem)
+ bbox = getBBoxWithTransform(elem, mockaddSVGElemensFromJson, mockPathActions)
+ assert.deepEqual(bbox, { x: 0, y: 1, width: 5, height: 10 })
+ assert.equal(mockaddSVGElemensFromJsonCallCount, 0)
+ elem.remove()
elem = mockCreateSVGElement({
element: 'line',
attr: { id: 'line', x1: '0', y1: '1', x2: '5', y2: '6' }
- });
- svgroot.append(elem);
- bbox = getBBoxWithTransform(elem, mockaddSVGElemensFromJson, mockPathActions);
- assert.deepEqual(bbox, { x: 0, y: 1, width: 5, height: 5 });
- assert.equal(mockaddSVGElemensFromJsonCallCount, 0);
- elem.remove();
+ })
+ svgroot.append(elem)
+ bbox = getBBoxWithTransform(elem, mockaddSVGElemensFromJson, mockPathActions)
+ assert.deepEqual(bbox, { x: 0, y: 1, width: 5, height: 5 })
+ assert.equal(mockaddSVGElemensFromJsonCallCount, 0)
+ elem.remove()
elem = mockCreateSVGElement({
element: 'rect',
attr: { id: 'rect', x: '0', y: '1', width: '5', height: '10' }
- });
+ })
const g = mockCreateSVGElement({
element: 'g',
attr: {}
- });
- g.append(elem);
- svgroot.append(g);
- bbox = getBBoxWithTransform(elem, mockaddSVGElemensFromJson, mockPathActions);
- assert.deepEqual(bbox, { x: 0, y: 1, width: 5, height: 10 });
- assert.equal(mockaddSVGElemensFromJsonCallCount, 0);
- g.remove();
- });
+ })
+ g.append(elem)
+ svgroot.append(g)
+ bbox = getBBoxWithTransform(elem, mockaddSVGElemensFromJson, mockPathActions)
+ assert.deepEqual(bbox, { x: 0, y: 1, width: 5, height: 10 })
+ assert.equal(mockaddSVGElemensFromJsonCallCount, 0)
+ g.remove()
+ })
it('Test getBBoxWithTransform and a rotation transform', function () {
- const { getBBoxWithTransform } = utilities;
+ const { getBBoxWithTransform } = utilities
let elem = mockCreateSVGElement({
element: 'path',
attr: { id: 'path', d: 'M10,10 L20,20', transform: 'rotate(45 10,10)' }
- });
- svgroot.append(elem);
- let bbox = getBBoxWithTransform(elem, mockaddSVGElemensFromJson, mockPathActions);
- assert.close(bbox.x, 10, EPSILON);
- assert.close(bbox.y, 10, EPSILON);
- assert.close(bbox.width, 0, EPSILON);
- assert.close(bbox.height, Math.sqrt(100 + 100), EPSILON);
- elem.remove();
+ })
+ svgroot.append(elem)
+ let bbox = getBBoxWithTransform(elem, mockaddSVGElemensFromJson, mockPathActions)
+ assert.close(bbox.x, 10, EPSILON)
+ assert.close(bbox.y, 10, EPSILON)
+ assert.close(bbox.width, 0, EPSILON)
+ assert.close(bbox.height, Math.sqrt(100 + 100), EPSILON)
+ elem.remove()
elem = mockCreateSVGElement({
element: 'rect',
attr: { id: 'rect', x: '10', y: '10', width: '10', height: '20', transform: 'rotate(90 15,20)' }
- });
- svgroot.append(elem);
- bbox = getBBoxWithTransform(elem, mockaddSVGElemensFromJson, mockPathActions);
- assert.close(bbox.x, 5, EPSILON);
- assert.close(bbox.y, 15, EPSILON);
- assert.close(bbox.width, 20, EPSILON);
- assert.close(bbox.height, 10, EPSILON);
- assert.equal(mockaddSVGElemensFromJsonCallCount, 1);
- elem.remove();
+ })
+ svgroot.append(elem)
+ bbox = getBBoxWithTransform(elem, mockaddSVGElemensFromJson, mockPathActions)
+ assert.close(bbox.x, 5, EPSILON)
+ assert.close(bbox.y, 15, EPSILON)
+ assert.close(bbox.width, 20, EPSILON)
+ assert.close(bbox.height, 10, EPSILON)
+ assert.equal(mockaddSVGElemensFromJsonCallCount, 1)
+ elem.remove()
- const rect = { x: 10, y: 10, width: 10, height: 20 };
- const angle = 45;
- const origin = { x: 15, y: 20 };
+ const rect = { x: 10, y: 10, width: 10, height: 20 }
+ const angle = 45
+ const origin = { x: 15, y: 20 }
elem = mockCreateSVGElement({
element: 'rect',
attr: { id: 'rect2', x: rect.x, y: rect.y, width: rect.width, height: rect.height, transform: 'rotate(' + angle + ' ' + origin.x + ',' + origin.y + ')' }
- });
- svgroot.append(elem);
- mockaddSVGElemensFromJsonCallCount = 0;
- bbox = getBBoxWithTransform(elem, mockaddSVGElemensFromJson, mockPathActions);
- const r2 = rotateRect(rect, angle, origin);
- assert.close(bbox.x, r2.x, EPSILON, 'rect2 x is ' + r2.x);
- assert.close(bbox.y, r2.y, EPSILON, 'rect2 y is ' + r2.y);
- assert.close(bbox.width, r2.width, EPSILON, 'rect2 width is' + r2.width);
- assert.close(bbox.height, r2.height, EPSILON, 'rect2 height is ' + r2.height);
- assert.equal(mockaddSVGElemensFromJsonCallCount, 0);
- elem.remove();
+ })
+ svgroot.append(elem)
+ mockaddSVGElemensFromJsonCallCount = 0
+ bbox = getBBoxWithTransform(elem, mockaddSVGElemensFromJson, mockPathActions)
+ const r2 = rotateRect(rect, angle, origin)
+ assert.close(bbox.x, r2.x, EPSILON, 'rect2 x is ' + r2.x)
+ assert.close(bbox.y, r2.y, EPSILON, 'rect2 y is ' + r2.y)
+ assert.close(bbox.width, r2.width, EPSILON, 'rect2 width is' + r2.width)
+ assert.close(bbox.height, r2.height, EPSILON, 'rect2 height is ' + r2.height)
+ assert.equal(mockaddSVGElemensFromJsonCallCount, 0)
+ elem.remove()
// Same as previous but wrapped with g and the transform is with the g.
elem = mockCreateSVGElement({
element: 'rect',
attr: { id: 'rect3', x: rect.x, y: rect.y, width: rect.width, height: rect.height }
- });
+ })
const g = mockCreateSVGElement({
element: 'g',
attr: { transform: 'rotate(' + angle + ' ' + origin.x + ',' + origin.y + ')' }
- });
- g.append(elem);
- svgroot.append(g);
- mockaddSVGElemensFromJsonCallCount = 0;
- bbox = getBBoxWithTransform(g, mockaddSVGElemensFromJson, mockPathActions);
- assert.close(bbox.x, r2.x, EPSILON, 'rect2 x is ' + r2.x);
- assert.close(bbox.y, r2.y, EPSILON, 'rect2 y is ' + r2.y);
- assert.close(bbox.width, r2.width, EPSILON, 'rect2 width is' + r2.width);
- assert.close(bbox.height, r2.height, EPSILON, 'rect2 height is ' + r2.height);
- assert.equal(mockaddSVGElemensFromJsonCallCount, 0);
- g.remove();
+ })
+ g.append(elem)
+ svgroot.append(g)
+ mockaddSVGElemensFromJsonCallCount = 0
+ bbox = getBBoxWithTransform(g, mockaddSVGElemensFromJson, mockPathActions)
+ assert.close(bbox.x, r2.x, EPSILON, 'rect2 x is ' + r2.x)
+ assert.close(bbox.y, r2.y, EPSILON, 'rect2 y is ' + r2.y)
+ assert.close(bbox.width, r2.width, EPSILON, 'rect2 width is' + r2.width)
+ assert.close(bbox.height, r2.height, EPSILON, 'rect2 height is ' + r2.height)
+ assert.equal(mockaddSVGElemensFromJsonCallCount, 0)
+ g.remove()
elem = mockCreateSVGElement({
element: 'ellipse',
attr: { id: 'ellipse1', cx: '100', cy: '100', rx: '50', ry: '50', transform: 'rotate(45 100,100)' }
- });
- svgroot.append(elem);
- mockaddSVGElemensFromJsonCallCount = 0;
- bbox = getBBoxWithTransform(elem, mockaddSVGElemensFromJson, mockPathActions);
+ })
+ svgroot.append(elem)
+ mockaddSVGElemensFromJsonCallCount = 0
+ bbox = getBBoxWithTransform(elem, mockaddSVGElemensFromJson, mockPathActions)
/** @todo: Review these test the BBox algorithm is using the bezier control points to calculate the bounding box. Should be 50, 50, 100, 100. */
// assert.ok(bbox.x > 45 && bbox.x <= 50);
- assert.ok(bbox.y > 45 && bbox.y <= 50);
+ assert.ok(bbox.y > 45 && bbox.y <= 50)
// assert.ok(bbox.width >= 100 && bbox.width < 110);
// assert.ok(bbox.height >= 100 && bbox.height < 110);
- assert.equal(mockaddSVGElemensFromJsonCallCount, 1);
- elem.remove();
- });
+ assert.equal(mockaddSVGElemensFromJsonCallCount, 1)
+ elem.remove()
+ })
it('Test getBBoxWithTransform with rotation and matrix transforms', function () {
- const { getBBoxWithTransform } = utilities;
+ const { getBBoxWithTransform } = utilities
- let tx = 10; // tx right
- let ty = 10; // tx down
- let txInRotatedSpace = Math.sqrt(tx * tx + ty * ty); // translate in rotated 45 space.
- let tyInRotatedSpace = 0;
- let matrix = 'matrix(1,0,0,1,' + txInRotatedSpace + ',' + tyInRotatedSpace + ')';
+ let tx = 10 // tx right
+ let ty = 10 // tx down
+ let txInRotatedSpace = Math.sqrt(tx * tx + ty * ty) // translate in rotated 45 space.
+ let tyInRotatedSpace = 0
+ let matrix = 'matrix(1,0,0,1,' + txInRotatedSpace + ',' + tyInRotatedSpace + ')'
let elem = mockCreateSVGElement({
element: 'path',
attr: { id: 'path', d: 'M10,10 L20,20', transform: 'rotate(45 10,10) ' + matrix }
- });
- svgroot.append(elem);
- let bbox = getBBoxWithTransform(elem, mockaddSVGElemensFromJson, mockPathActions);
- assert.close(bbox.x, 10 + tx, EPSILON);
- assert.close(bbox.y, 10 + ty, EPSILON);
- assert.close(bbox.width, 0, EPSILON);
- assert.close(bbox.height, Math.sqrt(100 + 100), EPSILON);
- elem.remove();
+ })
+ svgroot.append(elem)
+ let bbox = getBBoxWithTransform(elem, mockaddSVGElemensFromJson, mockPathActions)
+ assert.close(bbox.x, 10 + tx, EPSILON)
+ assert.close(bbox.y, 10 + ty, EPSILON)
+ assert.close(bbox.width, 0, EPSILON)
+ assert.close(bbox.height, Math.sqrt(100 + 100), EPSILON)
+ elem.remove()
- txInRotatedSpace = tx; // translate in rotated 90 space.
- tyInRotatedSpace = -ty;
- matrix = 'matrix(1,0,0,1,' + txInRotatedSpace + ',' + tyInRotatedSpace + ')';
+ txInRotatedSpace = tx // translate in rotated 90 space.
+ tyInRotatedSpace = -ty
+ matrix = 'matrix(1,0,0,1,' + txInRotatedSpace + ',' + tyInRotatedSpace + ')'
elem = mockCreateSVGElement({
element: 'rect',
attr: { id: 'rect', x: '10', y: '10', width: '10', height: '20', transform: 'rotate(90 15,20) ' + matrix }
- });
- svgroot.append(elem);
- bbox = getBBoxWithTransform(elem, mockaddSVGElemensFromJson, mockPathActions);
- assert.close(bbox.x, 5 + tx, EPSILON);
- assert.close(bbox.y, 15 + ty, EPSILON);
- assert.close(bbox.width, 20, EPSILON);
- assert.close(bbox.height, 10, EPSILON);
- elem.remove();
+ })
+ svgroot.append(elem)
+ bbox = getBBoxWithTransform(elem, mockaddSVGElemensFromJson, mockPathActions)
+ assert.close(bbox.x, 5 + tx, EPSILON)
+ assert.close(bbox.y, 15 + ty, EPSILON)
+ assert.close(bbox.width, 20, EPSILON)
+ assert.close(bbox.height, 10, EPSILON)
+ elem.remove()
- const rect = { x: 10, y: 10, width: 10, height: 20 };
- const angle = 45;
- const origin = { x: 15, y: 20 };
- tx = 10; // tx right
- ty = 10; // tx down
- txInRotatedSpace = Math.sqrt(tx * tx + ty * ty); // translate in rotated 45 space.
- tyInRotatedSpace = 0;
- matrix = 'matrix(1,0,0,1,' + txInRotatedSpace + ',' + tyInRotatedSpace + ')';
+ const rect = { x: 10, y: 10, width: 10, height: 20 }
+ const angle = 45
+ const origin = { x: 15, y: 20 }
+ tx = 10 // tx right
+ ty = 10 // tx down
+ txInRotatedSpace = Math.sqrt(tx * tx + ty * ty) // translate in rotated 45 space.
+ tyInRotatedSpace = 0
+ matrix = 'matrix(1,0,0,1,' + txInRotatedSpace + ',' + tyInRotatedSpace + ')'
elem = mockCreateSVGElement({
element: 'rect',
attr: { id: 'rect2', x: rect.x, y: rect.y, width: rect.width, height: rect.height, transform: 'rotate(' + angle + ' ' + origin.x + ',' + origin.y + ') ' + matrix }
- });
- svgroot.append(elem);
- bbox = getBBoxWithTransform(elem, mockaddSVGElemensFromJson, mockPathActions);
- const r2 = rotateRect(rect, angle, origin);
- assert.close(bbox.x, r2.x + tx, EPSILON, 'rect2 x is ' + r2.x);
- assert.close(bbox.y, r2.y + ty, EPSILON, 'rect2 y is ' + r2.y);
- assert.close(bbox.width, r2.width, EPSILON, 'rect2 width is' + r2.width);
- assert.close(bbox.height, r2.height, EPSILON, 'rect2 height is ' + r2.height);
- elem.remove();
+ })
+ svgroot.append(elem)
+ bbox = getBBoxWithTransform(elem, mockaddSVGElemensFromJson, mockPathActions)
+ const r2 = rotateRect(rect, angle, origin)
+ assert.close(bbox.x, r2.x + tx, EPSILON, 'rect2 x is ' + r2.x)
+ assert.close(bbox.y, r2.y + ty, EPSILON, 'rect2 y is ' + r2.y)
+ assert.close(bbox.width, r2.width, EPSILON, 'rect2 width is' + r2.width)
+ assert.close(bbox.height, r2.height, EPSILON, 'rect2 height is ' + r2.height)
+ elem.remove()
// Same as previous but wrapped with g and the transform is with the g.
elem = mockCreateSVGElement({
element: 'rect',
attr: { id: 'rect3', x: rect.x, y: rect.y, width: rect.width, height: rect.height }
- });
+ })
const g = mockCreateSVGElement({
element: 'g',
attr: { transform: 'rotate(' + angle + ' ' + origin.x + ',' + origin.y + ') ' + matrix }
- });
- g.append(elem);
- svgroot.append(g);
- bbox = getBBoxWithTransform(g, mockaddSVGElemensFromJson, mockPathActions);
- assert.close(bbox.x, r2.x + tx, EPSILON, 'rect2 x is ' + r2.x);
- assert.close(bbox.y, r2.y + ty, EPSILON, 'rect2 y is ' + r2.y);
- assert.close(bbox.width, r2.width, EPSILON, 'rect2 width is' + r2.width);
- assert.close(bbox.height, r2.height, EPSILON, 'rect2 height is ' + r2.height);
- g.remove();
+ })
+ g.append(elem)
+ svgroot.append(g)
+ bbox = getBBoxWithTransform(g, mockaddSVGElemensFromJson, mockPathActions)
+ assert.close(bbox.x, r2.x + tx, EPSILON, 'rect2 x is ' + r2.x)
+ assert.close(bbox.y, r2.y + ty, EPSILON, 'rect2 y is ' + r2.y)
+ assert.close(bbox.width, r2.width, EPSILON, 'rect2 width is' + r2.width)
+ assert.close(bbox.height, r2.height, EPSILON, 'rect2 height is ' + r2.height)
+ g.remove()
elem = mockCreateSVGElement({
element: 'ellipse',
attr: { id: 'ellipse1', cx: '100', cy: '100', rx: '50', ry: '50', transform: 'rotate(45 100,100) ' + matrix }
- });
- svgroot.append(elem);
- bbox = getBBoxWithTransform(elem, mockaddSVGElemensFromJson, mockPathActions);
+ })
+ svgroot.append(elem)
+ bbox = getBBoxWithTransform(elem, mockaddSVGElemensFromJson, mockPathActions)
/** @todo: the BBox algorithm is using the bezier control points to calculate the bounding box. Should be 50, 50, 100, 100. */
// assert.ok(bbox.x > 45 + tx && bbox.x <= 50 + tx);
- assert.ok(bbox.y > 45 + ty && bbox.y <= 50 + ty);
+ assert.ok(bbox.y > 45 + ty && bbox.y <= 50 + ty)
// assert.ok(bbox.width >= 100 && bbox.width < 110);
// assert.ok(bbox.height >= 100 && bbox.height < 110);
- elem.remove();
- });
+ elem.remove()
+ })
it('Test getStrokedBBox with stroke-width 10', function () {
- const { getStrokedBBox } = utilities;
+ const { getStrokedBBox } = utilities
- const strokeWidth = 10;
+ const strokeWidth = 10
let elem = mockCreateSVGElement({
element: 'path',
attr: { id: 'path', d: 'M0,1 L2,3', 'stroke-width': strokeWidth }
- });
- svgroot.append(elem);
- let bbox = getStrokedBBox([ elem ], mockaddSVGElemensFromJson, mockPathActions);
- assert.deepEqual(bbox, { x: 0 - strokeWidth / 2, y: 1 - strokeWidth / 2, width: 2 + strokeWidth, height: 2 + strokeWidth });
- elem.remove();
+ })
+ svgroot.append(elem)
+ let bbox = getStrokedBBox([elem], mockaddSVGElemensFromJson, mockPathActions)
+ assert.deepEqual(bbox, { x: 0 - strokeWidth / 2, y: 1 - strokeWidth / 2, width: 2 + strokeWidth, height: 2 + strokeWidth })
+ elem.remove()
elem = mockCreateSVGElement({
element: 'rect',
attr: { id: 'rect', x: '0', y: '1', width: '5', height: '10', 'stroke-width': strokeWidth }
- });
- svgroot.append(elem);
- bbox = getStrokedBBox([ elem ], mockaddSVGElemensFromJson, mockPathActions);
- assert.deepEqual(bbox, { x: 0 - strokeWidth / 2, y: 1 - strokeWidth / 2, width: 5 + strokeWidth, height: 10 + strokeWidth });
- elem.remove();
+ })
+ svgroot.append(elem)
+ bbox = getStrokedBBox([elem], mockaddSVGElemensFromJson, mockPathActions)
+ assert.deepEqual(bbox, { x: 0 - strokeWidth / 2, y: 1 - strokeWidth / 2, width: 5 + strokeWidth, height: 10 + strokeWidth })
+ elem.remove()
elem = mockCreateSVGElement({
element: 'line',
attr: { id: 'line', x1: '0', y1: '1', x2: '5', y2: '6', 'stroke-width': strokeWidth }
- });
- svgroot.append(elem);
- bbox = getStrokedBBox([ elem ], mockaddSVGElemensFromJson, mockPathActions);
- assert.deepEqual(bbox, { x: 0 - strokeWidth / 2, y: 1 - strokeWidth / 2, width: 5 + strokeWidth, height: 5 + strokeWidth });
- elem.remove();
+ })
+ svgroot.append(elem)
+ bbox = getStrokedBBox([elem], mockaddSVGElemensFromJson, mockPathActions)
+ assert.deepEqual(bbox, { x: 0 - strokeWidth / 2, y: 1 - strokeWidth / 2, width: 5 + strokeWidth, height: 5 + strokeWidth })
+ elem.remove()
elem = mockCreateSVGElement({
element: 'rect',
attr: { id: 'rect', x: '0', y: '1', width: '5', height: '10', 'stroke-width': strokeWidth }
- });
+ })
const g = mockCreateSVGElement({
element: 'g',
attr: {}
- });
- g.append(elem);
- svgroot.append(g);
- bbox = getStrokedBBox([ elem ], mockaddSVGElemensFromJson, mockPathActions);
- assert.deepEqual(bbox, { x: 0 - strokeWidth / 2, y: 1 - strokeWidth / 2, width: 5 + strokeWidth, height: 10 + strokeWidth });
- g.remove();
- });
+ })
+ g.append(elem)
+ svgroot.append(g)
+ bbox = getStrokedBBox([elem], mockaddSVGElemensFromJson, mockPathActions)
+ assert.deepEqual(bbox, { x: 0 - strokeWidth / 2, y: 1 - strokeWidth / 2, width: 5 + strokeWidth, height: 10 + strokeWidth })
+ g.remove()
+ })
it("Test getStrokedBBox with stroke-width 'none'", function () {
- const { getStrokedBBox } = utilities;
+ const { getStrokedBBox } = utilities
let elem = mockCreateSVGElement({
element: 'path',
attr: { id: 'path', d: 'M0,1 L2,3', 'stroke-width': 'none' }
- });
- svgroot.append(elem);
- let bbox = getStrokedBBox([ elem ], mockaddSVGElemensFromJson, mockPathActions);
- assert.deepEqual(bbox, { x: 0, y: 1, width: 2, height: 2 });
- elem.remove();
+ })
+ svgroot.append(elem)
+ let bbox = getStrokedBBox([elem], mockaddSVGElemensFromJson, mockPathActions)
+ assert.deepEqual(bbox, { x: 0, y: 1, width: 2, height: 2 })
+ elem.remove()
elem = mockCreateSVGElement({
element: 'rect',
attr: { id: 'rect', x: '0', y: '1', width: '5', height: '10', 'stroke-width': 'none' }
- });
- svgroot.append(elem);
- bbox = getStrokedBBox([ elem ], mockaddSVGElemensFromJson, mockPathActions);
- assert.deepEqual(bbox, { x: 0, y: 1, width: 5, height: 10 });
- elem.remove();
+ })
+ svgroot.append(elem)
+ bbox = getStrokedBBox([elem], mockaddSVGElemensFromJson, mockPathActions)
+ assert.deepEqual(bbox, { x: 0, y: 1, width: 5, height: 10 })
+ elem.remove()
elem = mockCreateSVGElement({
element: 'line',
attr: { id: 'line', x1: '0', y1: '1', x2: '5', y2: '6', 'stroke-width': 'none' }
- });
- svgroot.append(elem);
- bbox = getStrokedBBox([ elem ], mockaddSVGElemensFromJson, mockPathActions);
- assert.deepEqual(bbox, { x: 0, y: 1, width: 5, height: 5 });
- elem.remove();
+ })
+ svgroot.append(elem)
+ bbox = getStrokedBBox([elem], mockaddSVGElemensFromJson, mockPathActions)
+ assert.deepEqual(bbox, { x: 0, y: 1, width: 5, height: 5 })
+ elem.remove()
elem = mockCreateSVGElement({
element: 'rect',
attr: { id: 'rect', x: '0', y: '1', width: '5', height: '10', 'stroke-width': 'none' }
- });
+ })
const g = mockCreateSVGElement({
element: 'g',
attr: {}
- });
- g.append(elem);
- svgroot.append(g);
- bbox = getStrokedBBox([ elem ], mockaddSVGElemensFromJson, mockPathActions);
- assert.deepEqual(bbox, { x: 0, y: 1, width: 5, height: 10 });
- g.remove();
- });
+ })
+ g.append(elem)
+ svgroot.append(g)
+ bbox = getStrokedBBox([elem], mockaddSVGElemensFromJson, mockPathActions)
+ assert.deepEqual(bbox, { x: 0, y: 1, width: 5, height: 10 })
+ g.remove()
+ })
it('Test getStrokedBBox with no stroke-width attribute', function () {
- const { getStrokedBBox } = utilities;
+ const { getStrokedBBox } = utilities
let elem = mockCreateSVGElement({
element: 'path',
attr: { id: 'path', d: 'M0,1 L2,3' }
- });
- svgroot.append(elem);
- let bbox = getStrokedBBox([ elem ], mockaddSVGElemensFromJson, mockPathActions);
- assert.deepEqual(bbox, { x: 0, y: 1, width: 2, height: 2 });
- elem.remove();
+ })
+ svgroot.append(elem)
+ let bbox = getStrokedBBox([elem], mockaddSVGElemensFromJson, mockPathActions)
+ assert.deepEqual(bbox, { x: 0, y: 1, width: 2, height: 2 })
+ elem.remove()
elem = mockCreateSVGElement({
element: 'rect',
attr: { id: 'rect', x: '0', y: '1', width: '5', height: '10' }
- });
- svgroot.append(elem);
- bbox = getStrokedBBox([ elem ], mockaddSVGElemensFromJson, mockPathActions);
- assert.deepEqual(bbox, { x: 0, y: 1, width: 5, height: 10 });
- elem.remove();
+ })
+ svgroot.append(elem)
+ bbox = getStrokedBBox([elem], mockaddSVGElemensFromJson, mockPathActions)
+ assert.deepEqual(bbox, { x: 0, y: 1, width: 5, height: 10 })
+ elem.remove()
elem = mockCreateSVGElement({
element: 'line',
attr: { id: 'line', x1: '0', y1: '1', x2: '5', y2: '6' }
- });
- svgroot.append(elem);
- bbox = getStrokedBBox([ elem ], mockaddSVGElemensFromJson, mockPathActions);
- assert.deepEqual(bbox, { x: 0, y: 1, width: 5, height: 5 });
- elem.remove();
+ })
+ svgroot.append(elem)
+ bbox = getStrokedBBox([elem], mockaddSVGElemensFromJson, mockPathActions)
+ assert.deepEqual(bbox, { x: 0, y: 1, width: 5, height: 5 })
+ elem.remove()
elem = mockCreateSVGElement({
element: 'rect',
attr: { id: 'rect', x: '0', y: '1', width: '5', height: '10' }
- });
+ })
const g = mockCreateSVGElement({
element: 'g',
attr: {}
- });
- g.append(elem);
- svgroot.append(g);
- bbox = getStrokedBBox([ elem ], mockaddSVGElemensFromJson, mockPathActions);
- assert.deepEqual(bbox, { x: 0, y: 1, width: 5, height: 10 });
- g.remove();
- });
+ })
+ g.append(elem)
+ svgroot.append(g)
+ bbox = getStrokedBBox([elem], mockaddSVGElemensFromJson, mockPathActions)
+ assert.deepEqual(bbox, { x: 0, y: 1, width: 5, height: 10 })
+ g.remove()
+ })
/**
* Returns radians for degrees.
@@ -465,7 +466,7 @@ describe('utilities bbox', function () {
* @returns {Float}
*/
function radians (degrees) {
- return degrees * Math.PI / 180;
+ return degrees * Math.PI / 180
}
/**
@@ -477,15 +478,15 @@ describe('utilities bbox', function () {
*/
function rotatePoint (point, angle, origin) {
if (!origin) {
- origin = { x: 0, y: 0 };
+ origin = { x: 0, y: 0 }
}
- const x = point.x - origin.x;
- const y = point.y - origin.y;
- const theta = radians(angle);
+ const x = point.x - origin.x
+ const y = point.y - origin.y
+ const theta = radians(angle)
return {
x: x * Math.cos(theta) + y * Math.sin(theta) + origin.x,
y: x * Math.sin(theta) + y * Math.cos(theta) + origin.y
- };
+ }
}
/**
*
@@ -495,21 +496,21 @@ describe('utilities bbox', function () {
* @returns {module:utilities.BBoxObject}
*/
function rotateRect (rect, angle, origin) {
- const tl = rotatePoint({ x: rect.x, y: rect.y }, angle, origin);
- const tr = rotatePoint({ x: rect.x + rect.width, y: rect.y }, angle, origin);
- const br = rotatePoint({ x: rect.x + rect.width, y: rect.y + rect.height }, angle, origin);
- const bl = rotatePoint({ x: rect.x, y: rect.y + rect.height }, angle, origin);
+ const tl = rotatePoint({ x: rect.x, y: rect.y }, angle, origin)
+ const tr = rotatePoint({ x: rect.x + rect.width, y: rect.y }, angle, origin)
+ const br = rotatePoint({ x: rect.x + rect.width, y: rect.y + rect.height }, angle, origin)
+ const bl = rotatePoint({ x: rect.x, y: rect.y + rect.height }, angle, origin)
- const minx = Math.min(tl.x, tr.x, bl.x, br.x);
- const maxx = Math.max(tl.x, tr.x, bl.x, br.x);
- const miny = Math.min(tl.y, tr.y, bl.y, br.y);
- const maxy = Math.max(tl.y, tr.y, bl.y, br.y);
+ const minx = Math.min(tl.x, tr.x, bl.x, br.x)
+ const maxx = Math.max(tl.x, tr.x, bl.x, br.x)
+ const miny = Math.min(tl.y, tr.y, bl.y, br.y)
+ const maxy = Math.max(tl.y, tr.y, bl.y, br.y)
return {
x: minx,
y: miny,
width: (maxx - minx),
height: (maxy - miny)
- };
+ }
}
-});
+})
diff --git a/cypress/integration/unit/utilities-performance.js b/cypress/integration/unit/utilities-performance.js
index b095b8f2..386f4b6d 100644
--- a/cypress/integration/unit/utilities-performance.js
+++ b/cypress/integration/unit/utilities-performance.js
@@ -1,17 +1,17 @@
/* eslint-disable max-len, no-console */
-import 'pathseg';
+import 'pathseg'
-import { NS } from '../../../instrumented/svgcanvas/namespaces.js';
-import * as utilities from '../../../instrumented/svgcanvas/utilities.js';
-import * as math from '../../../instrumented/svgcanvas/math.js';
+import { NS } from '../../../instrumented/svgcanvas/namespaces.js'
+import * as utilities from '../../../instrumented/svgcanvas/utilities.js'
+import * as math from '../../../instrumented/svgcanvas/math.js'
describe('utilities performance', function () {
- let currentLayer; let groupWithMatrixTransform; let textWithMatrixTransform;
+ let currentLayer; let groupWithMatrixTransform; let textWithMatrixTransform
beforeEach(() => {
- document.body.textContent = '';
- const style = document.createElement('style');
- style.id = 'styleoverrides';
- style.media = 'screen';
+ document.body.textContent = ''
+ const style = document.createElement('style')
+ style.id = 'styleoverrides'
+ style.media = 'screen'
style.textContent = `
#svgcanvas svg * {
cursor: move;
@@ -19,9 +19,9 @@ describe('utilities performance', function () {
}
#svgcanvas svg {
cursor: default
- }`;
+ }`
- document.head.append(style);
+ document.head.append(style)
const editor = new DOMParser().parseFromString(`
@@ -64,14 +64,14 @@ describe('utilities performance', function () {
-
`, 'application/xml');
- const newNode = document.body.ownerDocument.importNode(editor.documentElement, true);
- document.body.append(newNode);
+ `, 'application/xml')
+ const newNode = document.body.ownerDocument.importNode(editor.documentElement, true)
+ document.body.append(newNode)
- currentLayer = document.getElementById('layer1');
- groupWithMatrixTransform = document.getElementById('svg_group_with_matrix_transform');
- textWithMatrixTransform = document.getElementById('svg_text_with_matrix_transform');
- });
+ currentLayer = document.getElementById('layer1')
+ groupWithMatrixTransform = document.getElementById('svg_group_with_matrix_transform')
+ textWithMatrixTransform = document.getElementById('svg_text_with_matrix_transform')
+ })
/**
* Create an SVG element for a mock.
@@ -79,11 +79,11 @@ describe('utilities performance', function () {
* @returns {SVGElement}
*/
function mockCreateSVGElement (jsonMap) {
- const elem = document.createElementNS(NS.SVG, jsonMap.element);
- Object.entries(jsonMap.attr).forEach(([ attr, value ]) => {
- elem.setAttribute(attr, value);
- });
- return elem;
+ const elem = document.createElementNS(NS.SVG, jsonMap.element)
+ Object.entries(jsonMap.attr).forEach(([attr, value]) => {
+ elem.setAttribute(attr, value)
+ })
+ return elem
}
/**
@@ -92,9 +92,9 @@ describe('utilities performance', function () {
* @returns {SVGElement}
*/
function mockaddSVGElemensFromJson (json) {
- const elem = mockCreateSVGElement(json);
- currentLayer.append(elem);
- return elem;
+ const elem = mockCreateSVGElement(json)
+ currentLayer.append(elem)
+ return elem
}
/**
@@ -104,49 +104,49 @@ describe('utilities performance', function () {
* @returns {void}
*/
function fillDocumentByCloningElement (elem, count) {
- const elemId = elem.getAttribute('id') + '-';
+ const elemId = elem.getAttribute('id') + '-'
for (let index = 0; index < count; index++) {
- const clone = elem.cloneNode(true); // t: deep clone
+ const clone = elem.cloneNode(true) // t: deep clone
// Make sure you set a unique ID like a real document.
- clone.setAttribute('id', elemId + index);
- const { parentNode } = elem;
- parentNode.append(clone);
+ clone.setAttribute('id', elemId + index)
+ const { parentNode } = elem
+ parentNode.append(clone)
}
}
const mockPathActions = {
resetOrientation (path) {
- if (utilities.isNullish(path) || path.nodeName !== 'path') { return false; }
- const tlist = path.transform.baseVal;
- const m = math.transformListToTransform(tlist).matrix;
- tlist.clear();
- path.removeAttribute('transform');
- const segList = path.pathSegList;
+ if (utilities.isNullish(path) || path.nodeName !== 'path') { return false }
+ const tlist = path.transform.baseVal
+ const m = math.transformListToTransform(tlist).matrix
+ tlist.clear()
+ path.removeAttribute('transform')
+ const segList = path.pathSegList
- const len = segList.numberOfItems;
+ const len = segList.numberOfItems
// let lastX, lastY;
for (let i = 0; i < len; ++i) {
- const seg = segList.getItem(i);
- const type = seg.pathSegType;
+ const seg = segList.getItem(i)
+ const type = seg.pathSegType
if (type === 1) {
- continue;
+ continue
}
const pts = [];
- [ '', 1, 2 ].forEach(function (n) {
- const x = seg['x' + n];
- const y = seg['y' + n];
+ ['', 1, 2].forEach(function (n) {
+ const x = seg['x' + n]
+ const y = seg['y' + n]
if (x !== undefined && y !== undefined) {
- const pt = math.transformPoint(x, y, m);
- pts.splice(pts.length, 0, pt.x, pt.y);
+ const pt = math.transformPoint(x, y, m)
+ pts.splice(pts.length, 0, pt.x, pt.y)
}
- });
+ })
// path.replacePathSeg(type, i, pts, path);
}
- return undefined;
+ return undefined
}
- };
+ }
// //////////////////////////////////////////////////////////
// Performance times with various browsers on Macbook 2011 8MB RAM OS X El Capitan 10.11.4
@@ -180,57 +180,57 @@ describe('utilities performance', function () {
// Pass2 svgCanvas.getStrokedBBox total ms 17, ave ms 0.2, min/max 0 23
it('Test svgCanvas.getStrokedBBox() performance with matrix transforms', function () {
- const { getStrokedBBox } = utilities;
- const { children } = currentLayer;
+ const { getStrokedBBox } = utilities
+ const { children } = currentLayer
- let lastTime; let now;
- let min = Number.MAX_VALUE;
- let max = 0;
- let total = 0;
+ let lastTime; let now
+ let min = Number.MAX_VALUE
+ let max = 0
+ let total = 0
- fillDocumentByCloningElement(groupWithMatrixTransform, 50);
- fillDocumentByCloningElement(textWithMatrixTransform, 50);
+ fillDocumentByCloningElement(groupWithMatrixTransform, 50)
+ fillDocumentByCloningElement(textWithMatrixTransform, 50)
// The first pass through all elements is slower.
- const count = children.length;
- const start = lastTime = now = Date.now();
+ const count = children.length
+ const start = lastTime = now = Date.now()
// Skip the first child which is the title.
for (let index = 1; index < count; index++) {
- const child = children[index];
- /* const obj = */ getStrokedBBox([ child ], mockaddSVGElemensFromJson, mockPathActions);
- now = Date.now(); const delta = now - lastTime; lastTime = now;
- total += delta;
- min = Math.min(min, delta);
- max = Math.max(max, delta);
+ const child = children[index]
+ /* const obj = */ getStrokedBBox([child], mockaddSVGElemensFromJson, mockPathActions)
+ now = Date.now(); const delta = now - lastTime; lastTime = now
+ total += delta
+ min = Math.min(min, delta)
+ max = Math.max(max, delta)
}
- total = lastTime - start;
- const ave = total / count;
- assert.isBelow(ave, 20, 'svgedit.utilities.getStrokedBBox average execution time is less than 20 ms');
- console.log('Pass1 svgCanvas.getStrokedBBox total ms ' + total + ', ave ms ' + ave.toFixed(1) + ',\t min/max ' + min + ' ' + max);
+ total = lastTime - start
+ const ave = total / count
+ assert.isBelow(ave, 20, 'svgedit.utilities.getStrokedBBox average execution time is less than 20 ms')
+ console.log('Pass1 svgCanvas.getStrokedBBox total ms ' + total + ', ave ms ' + ave.toFixed(1) + ',\t min/max ' + min + ' ' + max)
return new Promise((resolve) => {
// The second pass is two to ten times faster.
setTimeout(function () {
- const ct = children.length;
+ const ct = children.length
- const strt = lastTime = now = Date.now();
+ const strt = lastTime = now = Date.now()
// Skip the first child which is the title.
for (let index = 1; index < ct; index++) {
- const child = children[index];
- /* const obj = */ getStrokedBBox([ child ], mockaddSVGElemensFromJson, mockPathActions);
- now = Date.now(); const delta = now - lastTime; lastTime = now;
- total += delta;
- min = Math.min(min, delta);
- max = Math.max(max, delta);
+ const child = children[index]
+ /* const obj = */ getStrokedBBox([child], mockaddSVGElemensFromJson, mockPathActions)
+ now = Date.now(); const delta = now - lastTime; lastTime = now
+ total += delta
+ min = Math.min(min, delta)
+ max = Math.max(max, delta)
}
- total = lastTime - strt;
- const avg = total / ct;
- assert.isBelow(avg, 2, 'svgedit.utilities.getStrokedBBox average execution time is less than 1 ms');
- console.log('Pass2 svgCanvas.getStrokedBBox total ms ' + total + ', ave ms ' + avg.toFixed(1) + ',\t min/max ' + min + ' ' + max);
+ total = lastTime - strt
+ const avg = total / ct
+ assert.isBelow(avg, 2, 'svgedit.utilities.getStrokedBBox average execution time is less than 1 ms')
+ console.log('Pass2 svgCanvas.getStrokedBBox total ms ' + total + ', ave ms ' + avg.toFixed(1) + ',\t min/max ' + min + ' ' + max)
- resolve();
- });
- });
- });
-});
+ resolve()
+ })
+ })
+ })
+})
diff --git a/cypress/integration/unit/utilities.js b/cypress/integration/unit/utilities.js
index aa1616cc..5d8a2cc1 100644
--- a/cypress/integration/unit/utilities.js
+++ b/cypress/integration/unit/utilities.js
@@ -1,5 +1,5 @@
-import * as utilities from '../../../instrumented/svgcanvas/utilities.js';
-import { NS } from '../../../instrumented/svgcanvas/namespaces.js';
+import * as utilities from '../../../instrumented/svgcanvas/utilities.js'
+import { NS } from '../../../instrumented/svgcanvas/namespaces.js'
describe('utilities', function () {
/**
@@ -8,11 +8,11 @@ describe('utilities', function () {
* @returns {SVGElement}
*/
function mockCreateSVGElement (jsonMap) {
- const elem = document.createElementNS(NS.SVG, jsonMap.element);
- Object.entries(jsonMap.attr).forEach(([ attr, value ]) => {
- elem.setAttribute(attr, value);
- });
- return elem;
+ const elem = document.createElementNS(NS.SVG, jsonMap.element)
+ Object.entries(jsonMap.attr).forEach(([attr, value]) => {
+ elem.setAttribute(attr, value)
+ })
+ return elem
}
/**
* Adds SVG Element per parameters and appends to root.
@@ -20,225 +20,225 @@ describe('utilities', function () {
* @returns {SVGElement}
*/
function mockaddSVGElemensFromJson (json) {
- const elem = mockCreateSVGElement(json);
- svgroot.append(elem);
- return elem;
+ const elem = mockCreateSVGElement(json)
+ svgroot.append(elem)
+ return elem
}
- const mockPathActions = { resetOrientation () { /* empty fn */ } };
- let mockHistorySubCommands = [];
+ const mockPathActions = { resetOrientation () { /* empty fn */ } }
+ let mockHistorySubCommands = []
const mockHistory = {
BatchCommand: class {
addSubCommand (cmd) {
- mockHistorySubCommands.push(cmd);
+ mockHistorySubCommands.push(cmd)
}
},
RemoveElementCommand: class {
// Longhand needed since used as a constructor
constructor (elem, nextSibling, parent) {
- this.elem = elem;
- this.nextSibling = nextSibling;
- this.parent = parent;
+ this.elem = elem
+ this.nextSibling = nextSibling
+ this.parent = parent
}
},
InsertElementCommand: class {
constructor (path) { // Longhand needed since used as a constructor
- this.path = path;
+ this.path = path
}
}
- };
+ }
const mockCount = {
clearSelection: 0,
addToSelection: 0,
addCommandToHistory: 0
- };
+ }
/**
* Increments clear seleciton count for mock test.
* @returns {void}
*/
function mockClearSelection () {
- mockCount.clearSelection++;
+ mockCount.clearSelection++
}
/**
* Increments add selection count for mock test.
* @returns {void}
*/
function mockAddToSelection () {
- mockCount.addToSelection++;
+ mockCount.addToSelection++
}
/**
* Increments add command to history count for mock test.
* @returns {void}
*/
function mockAddCommandToHistory () {
- mockCount.addCommandToHistory++;
+ mockCount.addCommandToHistory++
}
- let svg; let svgroot;
+ let svg; let svgroot
beforeEach(() => {
- document.body.textContent = '';
+ document.body.textContent = ''
- mockHistorySubCommands = [];
- mockCount.clearSelection = 0;
- mockCount.addToSelection = 0;
- mockCount.addCommandToHistory = 0;
+ mockHistorySubCommands = []
+ mockCount.clearSelection = 0
+ mockCount.addToSelection = 0
+ mockCount.addCommandToHistory = 0
- const sandbox = document.createElement('div');
- svg = document.createElementNS(NS.SVG, 'svg');
+ const sandbox = document.createElement('div')
+ svg = document.createElementNS(NS.SVG, 'svg')
svgroot = mockCreateSVGElement({
element: 'svg',
attr: { id: 'svgroot' }
- });
- sandbox.append(svgroot);
- document.body.append(sandbox);
- });
+ })
+ sandbox.append(svgroot)
+ document.body.append(sandbox)
+ })
it('Test svgedit.utilities package', function () {
- assert.ok(utilities);
- assert.ok(utilities.toXml);
- assert.equal(typeof utilities.toXml, typeof function () { /* empty fn */ });
- });
+ assert.ok(utilities)
+ assert.ok(utilities.toXml)
+ assert.equal(typeof utilities.toXml, typeof function () { /* empty fn */ })
+ })
it('Test svgedit.utilities.toXml() function', function () {
- const { toXml } = utilities;
+ const { toXml } = utilities
- assert.equal(toXml('a'), 'a');
- assert.equal(toXml('ABC_'), 'ABC_');
- assert.equal(toXml('PB&J'), 'PB&J');
- assert.equal(toXml('2 < 5'), '2 < 5');
- assert.equal(toXml('5 > 2'), '5 > 2');
- assert.equal(toXml('\'<&>"'), ''<&>"');
- });
+ assert.equal(toXml('a'), 'a')
+ assert.equal(toXml('ABC_'), 'ABC_')
+ assert.equal(toXml('PB&J'), 'PB&J')
+ assert.equal(toXml('2 < 5'), '2 < 5')
+ assert.equal(toXml('5 > 2'), '5 > 2')
+ assert.equal(toXml('\'<&>"'), ''<&>"')
+ })
it('Test svgedit.utilities.encode64() function', function () {
- const { encode64 } = utilities;
+ const { encode64 } = utilities
- assert.equal(encode64('abcdef'), 'YWJjZGVm');
- assert.equal(encode64('12345'), 'MTIzNDU=');
- assert.equal(encode64(' '), 'IA==');
- assert.equal(encode64('`~!@#$%^&*()-_=+[{]}\\|;:\'",<.>/?'), 'YH4hQCMkJV4mKigpLV89K1t7XX1cfDs6JyIsPC4+Lz8=');
- });
+ assert.equal(encode64('abcdef'), 'YWJjZGVm')
+ assert.equal(encode64('12345'), 'MTIzNDU=')
+ assert.equal(encode64(' '), 'IA==')
+ assert.equal(encode64('`~!@#$%^&*()-_=+[{]}\\|;:\'",<.>/?'), 'YH4hQCMkJV4mKigpLV89K1t7XX1cfDs6JyIsPC4+Lz8=')
+ })
it('Test svgedit.utilities.decode64() function', function () {
- const { decode64 } = utilities;
+ const { decode64 } = utilities
- assert.equal(decode64('YWJjZGVm'), 'abcdef');
- assert.equal(decode64('MTIzNDU='), '12345');
- assert.equal(decode64('IA=='), ' ');
- assert.equal(decode64('YH4hQCMkJV4mKigpLV89K1t7XX1cfDs6JyIsPC4+Lz8='), '`~!@#$%^&*()-_=+[{]}\\|;:\'",<.>/?');
- });
+ assert.equal(decode64('YWJjZGVm'), 'abcdef')
+ assert.equal(decode64('MTIzNDU='), '12345')
+ assert.equal(decode64('IA=='), ' ')
+ assert.equal(decode64('YH4hQCMkJV4mKigpLV89K1t7XX1cfDs6JyIsPC4+Lz8='), '`~!@#$%^&*()-_=+[{]}\\|;:\'",<.>/?')
+ })
it('Test svgedit.utilities.convertToXMLReferences() function', function () {
- const convert = utilities.convertToXMLReferences;
- assert.equal(convert('ABC'), 'ABC');
+ const convert = utilities.convertToXMLReferences
+ assert.equal(convert('ABC'), 'ABC')
// assert.equal(convert('�BC'), 'ÀBC');
- });
+ })
it('Test svgedit.utilities.bboxToObj() function', function () {
- const { bboxToObj } = utilities;
+ const { bboxToObj } = utilities
- const rect = svg.createSVGRect();
- rect.x = 1;
- rect.y = 2;
- rect.width = 3;
- rect.height = 4;
+ const rect = svg.createSVGRect()
+ rect.x = 1
+ rect.y = 2
+ rect.width = 3
+ rect.height = 4
- const obj = bboxToObj(rect);
- assert.equal(typeof obj, typeof {});
- assert.equal(obj.x, 1);
- assert.equal(obj.y, 2);
- assert.equal(obj.width, 3);
- assert.equal(obj.height, 4);
- });
+ const obj = bboxToObj(rect)
+ assert.equal(typeof obj, typeof {})
+ assert.equal(obj.x, 1)
+ assert.equal(obj.y, 2)
+ assert.equal(obj.width, 3)
+ assert.equal(obj.height, 4)
+ })
it('Test getUrlFromAttr', function () {
- assert.equal(utilities.getUrlFromAttr('url(#foo)'), '#foo');
- assert.equal(utilities.getUrlFromAttr('url(somefile.svg#foo)'), 'somefile.svg#foo');
- assert.equal(utilities.getUrlFromAttr('url("#foo")'), '#foo');
- assert.equal(utilities.getUrlFromAttr('url("#foo")'), '#foo');
- });
+ assert.equal(utilities.getUrlFromAttr('url(#foo)'), '#foo')
+ assert.equal(utilities.getUrlFromAttr('url(somefile.svg#foo)'), 'somefile.svg#foo')
+ assert.equal(utilities.getUrlFromAttr('url("#foo")'), '#foo')
+ assert.equal(utilities.getUrlFromAttr('url("#foo")'), '#foo')
+ })
it('Test getPathDFromSegments', function () {
- const { getPathDFromSegments } = utilities;
+ const { getPathDFromSegments } = utilities
- const doc = utilities.text2xml('');
- const path = doc.createElementNS(NS.SVG, 'path');
- path.setAttribute('d', 'm0,0l5,0l0,5l-5,0l0,-5z');
+ const doc = utilities.text2xml('')
+ const path = doc.createElementNS(NS.SVG, 'path')
+ path.setAttribute('d', 'm0,0l5,0l0,5l-5,0l0,-5z')
let d = getPathDFromSegments([
- [ 'M', [ 1, 2 ] ],
- [ 'Z', [] ]
- ]);
- assert.equal(d, 'M1,2 Z');
+ ['M', [1, 2]],
+ ['Z', []]
+ ])
+ assert.equal(d, 'M1,2 Z')
d = getPathDFromSegments([
- [ 'M', [ 1, 2 ] ],
- [ 'M', [ 3, 4 ] ],
- [ 'Z', [] ]
- ]);
- assert.equal(d, 'M1,2 M3,4 Z');
+ ['M', [1, 2]],
+ ['M', [3, 4]],
+ ['Z', []]
+ ])
+ assert.equal(d, 'M1,2 M3,4 Z')
d = getPathDFromSegments([
- [ 'M', [ 1, 2 ] ],
- [ 'C', [ 3, 4, 5, 6 ] ],
- [ 'Z', [] ]
- ]);
- assert.equal(d, 'M1,2 C3,4 5,6 Z');
- });
+ ['M', [1, 2]],
+ ['C', [3, 4, 5, 6]],
+ ['Z', []]
+ ])
+ assert.equal(d, 'M1,2 C3,4 5,6 Z')
+ })
it('Test getPathDFromElement', function () {
- const { getPathDFromElement } = utilities;
+ const { getPathDFromElement } = utilities
let elem = mockCreateSVGElement({
element: 'path',
attr: { id: 'path', d: 'M0,1 Z' }
- });
- svgroot.append(elem);
- assert.equal(getPathDFromElement(elem), 'M0,1 Z');
- elem.remove();
+ })
+ svgroot.append(elem)
+ assert.equal(getPathDFromElement(elem), 'M0,1 Z')
+ elem.remove()
elem = mockCreateSVGElement({
element: 'rect',
attr: { id: 'rect', x: '0', y: '1', width: '5', height: '10' }
- });
- svgroot.append(elem);
- assert.equal(getPathDFromElement(elem), 'M0,1 L5,1 L5,11 L0,11 L0,1 Z');
- elem.remove();
+ })
+ svgroot.append(elem)
+ assert.equal(getPathDFromElement(elem), 'M0,1 L5,1 L5,11 L0,11 L0,1 Z')
+ elem.remove()
elem = mockCreateSVGElement({
element: 'rect',
attr: { id: 'roundrect', x: '0', y: '1', rx: '2', ry: '3', width: '10', height: '11' }
- });
- svgroot.append(elem);
- const closeEnough = /M0,4 C0,2.3\d* 0.9\d*,1 2,1 L8,1 C9.0\d*,1 10,2.3\d* 10,4 L10,9 C10,10.6\d* 9.0\d*,12 8,12 L2,12 C0.9\d*,12 0,10.6\d* 0,9 L0,4 Z/;
- assert.equal(closeEnough.test(getPathDFromElement(elem)), true);
- elem.remove();
+ })
+ svgroot.append(elem)
+ const closeEnough = /M0,4 C0,2.3\d* 0.9\d*,1 2,1 L8,1 C9.0\d*,1 10,2.3\d* 10,4 L10,9 C10,10.6\d* 9.0\d*,12 8,12 L2,12 C0.9\d*,12 0,10.6\d* 0,9 L0,4 Z/
+ assert.equal(closeEnough.test(getPathDFromElement(elem)), true)
+ elem.remove()
elem = mockCreateSVGElement({
element: 'line',
attr: { id: 'line', x1: '0', y1: '1', x2: '5', y2: '6' }
- });
- svgroot.append(elem);
- assert.equal(getPathDFromElement(elem), 'M0,1L5,6');
- elem.remove();
+ })
+ svgroot.append(elem)
+ assert.equal(getPathDFromElement(elem), 'M0,1L5,6')
+ elem.remove()
elem = mockCreateSVGElement({
element: 'circle',
attr: { id: 'circle', cx: '10', cy: '11', rx: '5', ry: '10' }
- });
- svgroot.append(elem);
- assert.equal(getPathDFromElement(elem), 'M5,11 C5,5.475138121546961 7.237569060773481,1 10,1 C12.762430939226519,1 15,5.475138121546961 15,11 C15,16.524861878453038 12.762430939226519,21 10,21 C7.237569060773481,21 5,16.524861878453038 5,11 Z');
- elem.remove();
+ })
+ svgroot.append(elem)
+ assert.equal(getPathDFromElement(elem), 'M5,11 C5,5.475138121546961 7.237569060773481,1 10,1 C12.762430939226519,1 15,5.475138121546961 15,11 C15,16.524861878453038 12.762430939226519,21 10,21 C7.237569060773481,21 5,16.524861878453038 5,11 Z')
+ elem.remove()
elem = mockCreateSVGElement({
element: 'polyline',
attr: { id: 'polyline', points: '0,1 5,1 5,11 0,11' }
- });
- svgroot.append(elem);
- assert.equal(getPathDFromElement(elem), 'M0,1 5,1 5,11 0,11');
- elem.remove();
+ })
+ svgroot.append(elem)
+ assert.equal(getPathDFromElement(elem), 'M0,1 5,1 5,11 0,11')
+ elem.remove()
- assert.equal(getPathDFromElement({ tagName: 'something unknown' }), undefined);
- });
+ assert.equal(getPathDFromElement({ tagName: 'something unknown' }), undefined)
+ })
it('Test getBBoxOfElementAsPath', function () {
/**
@@ -246,88 +246,88 @@ describe('utilities', function () {
* @type {module:utilities.getBBoxOfElementAsPath}
*/
function getBBoxOfElementAsPath (elem, addSVGElemensFromJson, pathActions) {
- const bbox = utilities.getBBoxOfElementAsPath(elem, addSVGElemensFromJson, pathActions);
- return utilities.bboxToObj(bbox); // need this for assert.equal() to work.
+ const bbox = utilities.getBBoxOfElementAsPath(elem, addSVGElemensFromJson, pathActions)
+ return utilities.bboxToObj(bbox) // need this for assert.equal() to work.
}
let elem = mockCreateSVGElement({
element: 'path',
attr: { id: 'path', d: 'M0,1 Z' }
- });
- svgroot.append(elem);
- let bbox = getBBoxOfElementAsPath(elem, mockaddSVGElemensFromJson, mockPathActions);
- assert.deepEqual(bbox, { x: 0, y: 1, width: 0, height: 0 });
- elem.remove();
+ })
+ svgroot.append(elem)
+ let bbox = getBBoxOfElementAsPath(elem, mockaddSVGElemensFromJson, mockPathActions)
+ assert.deepEqual(bbox, { x: 0, y: 1, width: 0, height: 0 })
+ elem.remove()
elem = mockCreateSVGElement({
element: 'rect',
attr: { id: 'rect', x: '0', y: '1', width: '5', height: '10' }
- });
- svgroot.append(elem);
- bbox = getBBoxOfElementAsPath(elem, mockaddSVGElemensFromJson, mockPathActions);
- assert.deepEqual(bbox, { x: 0, y: 1, width: 5, height: 10 });
- elem.remove();
+ })
+ svgroot.append(elem)
+ bbox = getBBoxOfElementAsPath(elem, mockaddSVGElemensFromJson, mockPathActions)
+ assert.deepEqual(bbox, { x: 0, y: 1, width: 5, height: 10 })
+ elem.remove()
elem = mockCreateSVGElement({
element: 'line',
attr: { id: 'line', x1: '0', y1: '1', x2: '5', y2: '6' }
- });
- svgroot.append(elem);
- bbox = getBBoxOfElementAsPath(elem, mockaddSVGElemensFromJson, mockPathActions);
- assert.deepEqual(bbox, { x: 0, y: 1, width: 5, height: 5 });
- elem.remove();
+ })
+ svgroot.append(elem)
+ bbox = getBBoxOfElementAsPath(elem, mockaddSVGElemensFromJson, mockPathActions)
+ assert.deepEqual(bbox, { x: 0, y: 1, width: 5, height: 5 })
+ elem.remove()
// TODO: test element with transform. Need resetOrientation above to be working or mock it.
- });
+ })
it('Test convertToPath rect', function () {
- const { convertToPath } = utilities;
+ const { convertToPath } = utilities
const attrs = {
fill: 'red',
stroke: 'white',
'stroke-width': '1',
visibility: 'hidden'
- };
+ }
const elem = mockCreateSVGElement({
element: 'rect',
attr: { id: 'rect', x: '0', y: '1', width: '5', height: '10' }
- });
- svgroot.append(elem);
- const path = convertToPath(elem, attrs, mockaddSVGElemensFromJson, mockPathActions, mockClearSelection, mockAddToSelection, mockHistory, mockAddCommandToHistory);
- assert.equal(path.getAttribute('d'), 'M0,1 L5,1 L5,11 L0,11 L0,1 Z');
- assert.equal(path.getAttribute('visibilituy'), null);
- assert.equal(path.id, 'rect');
- assert.equal(path.parentNode, svgroot);
- assert.equal(elem.parentNode, null);
- assert.equal(mockHistorySubCommands.length, 2);
- assert.equal(mockCount.clearSelection, 1);
- assert.equal(mockCount.addToSelection, 1);
- assert.equal(mockCount.addCommandToHistory, 1);
- path.remove();
- });
+ })
+ svgroot.append(elem)
+ const path = convertToPath(elem, attrs, mockaddSVGElemensFromJson, mockPathActions, mockClearSelection, mockAddToSelection, mockHistory, mockAddCommandToHistory)
+ assert.equal(path.getAttribute('d'), 'M0,1 L5,1 L5,11 L0,11 L0,1 Z')
+ assert.equal(path.getAttribute('visibilituy'), null)
+ assert.equal(path.id, 'rect')
+ assert.equal(path.parentNode, svgroot)
+ assert.equal(elem.parentNode, null)
+ assert.equal(mockHistorySubCommands.length, 2)
+ assert.equal(mockCount.clearSelection, 1)
+ assert.equal(mockCount.addToSelection, 1)
+ assert.equal(mockCount.addCommandToHistory, 1)
+ path.remove()
+ })
it('Test convertToPath unknown element', function () {
- const { convertToPath } = utilities;
+ const { convertToPath } = utilities
const attrs = {
fill: 'red',
stroke: 'white',
'stroke-width': '1',
visibility: 'hidden'
- };
+ }
const elem = {
tagName: 'something unknown',
id: 'something-unknown',
- getAttribute () { return ''; },
+ getAttribute () { return '' },
parentNode: svgroot
- };
- const path = convertToPath(elem, attrs, mockaddSVGElemensFromJson, mockPathActions, mockClearSelection, mockAddToSelection, mockHistory, mockAddCommandToHistory);
- assert.equal(path, null);
- assert.equal(elem.parentNode, svgroot);
- assert.equal(mockHistorySubCommands.length, 0);
- assert.equal(mockCount.clearSelection, 0);
- assert.equal(mockCount.addToSelection, 0);
- assert.equal(mockCount.addCommandToHistory, 0);
- });
-});
+ }
+ const path = convertToPath(elem, attrs, mockaddSVGElemensFromJson, mockPathActions, mockClearSelection, mockAddToSelection, mockHistory, mockAddCommandToHistory)
+ assert.equal(path, null)
+ assert.equal(elem.parentNode, svgroot)
+ assert.equal(mockHistorySubCommands.length, 0)
+ assert.equal(mockCount.clearSelection, 0)
+ assert.equal(mockCount.addToSelection, 0)
+ assert.equal(mockCount.addCommandToHistory, 0)
+ })
+})
diff --git a/cypress/plugins/index.js b/cypress/plugins/index.js
index b0a4e8cc..e4ddb633 100644
--- a/cypress/plugins/index.js
+++ b/cypress/plugins/index.js
@@ -1,4 +1,4 @@
-'use strict';
+'use strict'
// ***********************************************************
// This example plugins/index.js can be used to load plugins
@@ -11,6 +11,6 @@
// ***********************************************************
require('@babel/register')({
- plugins: [ '@babel/plugin-transform-modules-commonjs' ]
-});
-module.exports = require('./main.js').default;
+ plugins: ['@babel/plugin-transform-modules-commonjs']
+})
+module.exports = require('./main.js').default
diff --git a/cypress/plugins/main.js b/cypress/plugins/main.js
index 33100766..e2a29a7e 100644
--- a/cypress/plugins/main.js
+++ b/cypress/plugins/main.js
@@ -1,8 +1,8 @@
// This function is called when a project is opened or re-opened (e.g. due to
// the project's config changing)
-import codeCoverageTask from "@cypress/code-coverage/task.js";
-import { initPlugin } from "cypress-plugin-snapshots/plugin.js";
+import codeCoverageTask from '@cypress/code-coverage/task.js'
+import { initPlugin } from 'cypress-plugin-snapshots/plugin.js'
export default (on, config) => {
// `on` is used to hook into various events Cypress emits
@@ -12,35 +12,35 @@ export default (on, config) => {
// `config` is the resolved Cypress config
// https://docs.cypress.io/guides/tooling/code-coverage.html#Install-the-plugin
- codeCoverageTask(on, config);
- initPlugin(on, config);
- on("before:browser:launch", (browser, launchOptions) => {
- if (browser.name === "chrome" && browser.isHeadless) {
+ codeCoverageTask(on, config)
+ initPlugin(on, config)
+ on('before:browser:launch', (browser, launchOptions) => {
+ if (browser.name === 'chrome' && browser.isHeadless) {
// fullPage screenshot size is 1400x1200 on non-retina screens
// and 2800x2400 on retina screens
- launchOptions.args.push("--window-size=1400,1200");
+ launchOptions.args.push('--window-size=1400,1200')
// force screen to be non-retina (1400x1200 size)
- launchOptions.args.push("--force-device-scale-factor=1");
+ launchOptions.args.push('--force-device-scale-factor=1')
// force screen to be retina (2800x2400 size)
// launchOptions.args.push('--force-device-scale-factor=2')
}
- if (browser.name === "electron" && browser.isHeadless) {
+ if (browser.name === 'electron' && browser.isHeadless) {
// fullPage screenshot size is 1400x1200
- launchOptions.preferences.width = 1400;
- launchOptions.preferences.height = 1200;
+ launchOptions.preferences.width = 1400
+ launchOptions.preferences.height = 1200
}
- if (browser.name === "firefox" && browser.isHeadless) {
+ if (browser.name === 'firefox' && browser.isHeadless) {
// menubars take up height on the screen
// so fullPage screenshot size is 1400x1126
- launchOptions.args.push("--width=1400");
- launchOptions.args.push("--height=1200");
+ launchOptions.args.push('--width=1400')
+ launchOptions.args.push('--height=1200')
}
- return launchOptions;
- });
- return config;
-};
+ return launchOptions
+ })
+ return config
+}
diff --git a/cypress/support/assert-almostEquals.js b/cypress/support/assert-almostEquals.js
index b2b42c73..bc828110 100644
--- a/cypress/support/assert-almostEquals.js
+++ b/cypress/support/assert-almostEquals.js
@@ -1,6 +1,6 @@
-import assertionWrapper from './assertion-wrapper.js';
+import assertionWrapper from './assertion-wrapper.js'
-const NEAR_ZERO = 5e-6; // 0.000005, Firefox fails at higher levels of precision.
+const NEAR_ZERO = 5e-6 // 0.000005, Firefox fails at higher levels of precision.
/**
* Checks that the supplied values are equal with a high though not absolute degree of precision.
@@ -10,9 +10,9 @@ const NEAR_ZERO = 5e-6; // 0.000005, Firefox fails at higher levels of precision
* @returns {void}
*/
function almostEquals (actual, expected, message) {
- message = message || (actual + ' did not equal ' + expected);
- const result = Math.abs(actual - expected) < NEAR_ZERO;
- return { result, message, actual, expected };
+ message = message || (actual + ' did not equal ' + expected)
+ const result = Math.abs(actual - expected) < NEAR_ZERO
+ return { result, message, actual, expected }
}
/**
@@ -21,9 +21,9 @@ function almostEquals (actual, expected, message) {
* @returns {void}
*/
function setAssertionMethods (_chai, utils) {
- const wrap = assertionWrapper(_chai, utils);
+ const wrap = assertionWrapper(_chai, utils)
- assert.almostEquals = wrap(almostEquals);
+ assert.almostEquals = wrap(almostEquals)
}
-export default setAssertionMethods;
+export default setAssertionMethods
diff --git a/cypress/support/assert-close.js b/cypress/support/assert-close.js
index 4f617bbb..e18b4cd1 100644
--- a/cypress/support/assert-close.js
+++ b/cypress/support/assert-close.js
@@ -1,4 +1,4 @@
-import assertionWrapper from './assertion-wrapper.js';
+import assertionWrapper from './assertion-wrapper.js'
/**
* @typedef {PlainObject} InfoObject
@@ -21,10 +21,10 @@ import assertionWrapper from './assertion-wrapper.js';
* @returns {InfoObject}
*/
function close (actual, expected, maxDifference, message) {
- const actualDiff = (actual === expected) ? 0 : Math.abs(actual - expected);
- const result = actualDiff <= maxDifference;
- message = message || (actual + ' should be within ' + maxDifference + ' (inclusive) of ' + expected + (result ? '' : '. Actual: ' + actualDiff));
- return { result, message, actual, expected };
+ const actualDiff = (actual === expected) ? 0 : Math.abs(actual - expected)
+ const result = actualDiff <= maxDifference
+ message = message || (actual + ' should be within ' + maxDifference + ' (inclusive) of ' + expected + (result ? '' : '. Actual: ' + actualDiff))
+ return { result, message, actual, expected }
}
/**
@@ -40,21 +40,21 @@ function close (actual, expected, maxDifference, message) {
* @returns {InfoObject}
*/
function closePercent (actual, expected, maxPercentDifference, message) {
- let actualDiff; let result;
+ let actualDiff; let result
if (actual === expected) {
- actualDiff = 0;
- result = actualDiff <= maxPercentDifference;
+ actualDiff = 0
+ result = actualDiff <= maxPercentDifference
} else if (actual !== 0 && expected !== 0 && expected !== Infinity && expected !== -Infinity) {
- actualDiff = Math.abs(100 * (actual - expected) / expected);
- result = actualDiff <= maxPercentDifference;
+ actualDiff = Math.abs(100 * (actual - expected) / expected)
+ result = actualDiff <= maxPercentDifference
} else {
// Dividing by zero (0)! Should return `false` unless the max percentage was `Infinity`
- actualDiff = Infinity;
- result = maxPercentDifference === Infinity;
+ actualDiff = Infinity
+ result = maxPercentDifference === Infinity
}
- message = message || (actual + ' should be within ' + maxPercentDifference + '% (inclusive) of ' + expected + (result ? '' : '. Actual: ' + actualDiff + '%'));
+ message = message || (actual + ' should be within ' + maxPercentDifference + '% (inclusive) of ' + expected + (result ? '' : '. Actual: ' + actualDiff + '%'))
- return { result, message, actual, expected };
+ return { result, message, actual, expected }
}
/**
@@ -70,10 +70,10 @@ function closePercent (actual, expected, maxPercentDifference, message) {
* @returns {InfoObject}
*/
function notClose (actual, expected, minDifference, message) {
- const actualDiff = Math.abs(actual - expected);
- const result = actualDiff > minDifference;
- message = message || (actual + ' should not be within ' + minDifference + ' (exclusive) of ' + expected + (result ? '' : '. Actual: ' + actualDiff));
- return { result, message, actual, expected };
+ const actualDiff = Math.abs(actual - expected)
+ const result = actualDiff > minDifference
+ message = message || (actual + ' should not be within ' + minDifference + ' (exclusive) of ' + expected + (result ? '' : '. Actual: ' + actualDiff))
+ return { result, message, actual, expected }
}
/**
@@ -89,21 +89,21 @@ function notClose (actual, expected, minDifference, message) {
* @returns {InfoObject}
*/
function notClosePercent (actual, expected, minPercentDifference, message) {
- let actualDiff; let result;
+ let actualDiff; let result
if (actual === expected) {
- actualDiff = 0;
- result = actualDiff > minPercentDifference;
+ actualDiff = 0
+ result = actualDiff > minPercentDifference
} else if (actual !== 0 && expected !== 0 && expected !== Infinity && expected !== -Infinity) {
- actualDiff = Math.abs(100 * (actual - expected) / expected);
- result = actualDiff > minPercentDifference;
+ actualDiff = Math.abs(100 * (actual - expected) / expected)
+ result = actualDiff > minPercentDifference
} else {
// Dividing by zero (0)! Should only return `true` if the min percentage was `Infinity`
- actualDiff = Infinity;
- result = minPercentDifference !== Infinity;
+ actualDiff = Infinity
+ result = minPercentDifference !== Infinity
}
- message = message || (actual + ' should not be within ' + minPercentDifference + '% (exclusive) of ' + expected + (result ? '' : '. Actual: ' + actualDiff + '%'));
+ message = message || (actual + ' should not be within ' + minPercentDifference + '% (exclusive) of ' + expected + (result ? '' : '. Actual: ' + actualDiff + '%'))
- return { result, message, actual, expected };
+ return { result, message, actual, expected }
}
/**
@@ -112,12 +112,12 @@ function notClosePercent (actual, expected, minPercentDifference, message) {
* @returns {void}
*/
function setAssertionMethods (_chai, utils) {
- const wrap = assertionWrapper(_chai, utils);
+ const wrap = assertionWrapper(_chai, utils)
- assert.close = wrap(close);
- assert.closePercent = wrap(closePercent);
- assert.notClose = wrap(notClose);
- assert.notClosePercent = wrap(notClosePercent);
+ assert.close = wrap(close)
+ assert.closePercent = wrap(closePercent)
+ assert.notClose = wrap(notClose)
+ assert.notClosePercent = wrap(notClosePercent)
}
-export default setAssertionMethods;
+export default setAssertionMethods
diff --git a/cypress/support/assert-expectOutOfBoundsException.js b/cypress/support/assert-expectOutOfBoundsException.js
index de884e1f..8a3242e2 100644
--- a/cypress/support/assert-expectOutOfBoundsException.js
+++ b/cypress/support/assert-expectOutOfBoundsException.js
@@ -1,4 +1,4 @@
-import assertionWrapper from './assertion-wrapper.js';
+import assertionWrapper from './assertion-wrapper.js'
/**
* Expects an out of bounds `INDEX_SIZE_ERR` exception.
@@ -8,18 +8,18 @@ import assertionWrapper from './assertion-wrapper.js';
* @returns {void}
*/
function expectOutOfBoundsException (obj, fn, arg1) {
- const expected = true;
- const message = 'Caught an INDEX_SIZE_ERR exception';
- let result = false;
+ const expected = true
+ const message = 'Caught an INDEX_SIZE_ERR exception'
+ let result = false
try {
- obj[fn](arg1);
+ obj[fn](arg1)
} catch (e) {
if (e.code === 1) {
- result = true;
+ result = true
}
}
- const actual = result;
- return { result, message, actual, expected };
+ const actual = result
+ return { result, message, actual, expected }
}
/**
@@ -28,9 +28,9 @@ function expectOutOfBoundsException (obj, fn, arg1) {
* @returns {void}
*/
function setAssertionMethods (_chai, utils) {
- const wrap = assertionWrapper(_chai, utils);
+ const wrap = assertionWrapper(_chai, utils)
- assert.expectOutOfBoundsException = wrap(expectOutOfBoundsException);
+ assert.expectOutOfBoundsException = wrap(expectOutOfBoundsException)
}
-export default setAssertionMethods;
+export default setAssertionMethods
diff --git a/cypress/support/assertion-wrapper.js b/cypress/support/assertion-wrapper.js
index 65a02776..e38905fc 100644
--- a/cypress/support/assertion-wrapper.js
+++ b/cypress/support/assertion-wrapper.js
@@ -6,10 +6,10 @@
function setAssertionMethods (_chai, _utils) {
return (method) => {
return (...args) => {
- const { result, message, actual, expected } = method(...args);
- const assertion = new _chai.Assertion();
- assertion.assert(result, `Expected ${actual} to be ${expected}`, message);
- };
- };
+ const { result, message, actual, expected } = method(...args)
+ const assertion = new _chai.Assertion()
+ assertion.assert(result, `Expected ${actual} to be ${expected}`, message)
+ }
+ }
}
-export default setAssertionMethods;
+export default setAssertionMethods
diff --git a/cypress/support/commands.js b/cypress/support/commands.js
index 2384dcbf..33de4769 100644
--- a/cypress/support/commands.js
+++ b/cypress/support/commands.js
@@ -23,9 +23,9 @@
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })
-
+/* globals Cypress */
// remove the style attributes that is causing differences in snapshots
-const ngAttributes = [ 'style' ];
+const ngAttributes = ['style']
Cypress.Commands.add(
'cleanSnapshot',
@@ -33,16 +33,16 @@ Cypress.Commands.add(
prevSubject: true
},
(subject, _snapshotOptions) => {
- let html = subject[0].outerHTML;
+ let html = subject[0].outerHTML
for (const attribute of ngAttributes) {
- const expression = new RegExp(`${attribute}[^= ]*="[^"]*"`, 'g');
- html = html.replace(expression, '');
+ const expression = new RegExp(`${attribute}[^= ]*="[^"]*"`, 'g')
+ html = html.replace(expression, '')
}
- html = html.replace(//g, '');
+ html = html.replace(//g, '')
- const sanitisedBody = new DOMParser().parseFromString(html, 'text/html').querySelector('body');
+ const sanitisedBody = new DOMParser().parseFromString(html, 'text/html').querySelector('body')
- return cy.wrap(sanitisedBody.firstChild).toMatchSnapshot();
+ return cy.wrap(sanitisedBody.firstChild).toMatchSnapshot()
}
-);
+)
diff --git a/cypress/support/index.js b/cypress/support/index.js
index 27fcdbe3..f4f9cc0c 100644
--- a/cypress/support/index.js
+++ b/cypress/support/index.js
@@ -14,7 +14,7 @@
// ***********************************************************
// Import commands.js using ES2015 syntax:
-import './commands.js';
+import './commands.js'
// Alternatively you can use CommonJS syntax:
// require('./commands')
@@ -29,17 +29,17 @@ import './commands.js';
* @see https://github.com/cypress-io/cypress-fiddle
* @example import {testExamples} from '@cypress/fiddle';
*/
-import '@cypress/fiddle';
+import '@cypress/fiddle'
/**
* COVERAGE.
* @see https://docs.cypress.io/guides/tooling/code-coverage.html#Install-the-plugin
*/
-import '@cypress/code-coverage/support.js';
+import '@cypress/code-coverage/support.js'
/*****
* SNAPSHOTS
* @see https://www.npmjs.com/package/cypress-plugin-snapshots
*/
-import 'cypress-plugin-snapshots/commands.js';
+import 'cypress-plugin-snapshots/commands.js'
diff --git a/cypress/support/ui-test-helper.js b/cypress/support/ui-test-helper.js
index 80ca022f..1276cebd 100644
--- a/cypress/support/ui-test-helper.js
+++ b/cypress/support/ui-test-helper.js
@@ -1,24 +1,24 @@
export const approveStorage = () => {
// JFH will need to be chnaged when dialog is changed...
- cy.get('#storage_ok').click();
-};
+ cy.get('#storage_ok').click()
+}
export const visitAndApproveStorage = () => {
- cy.visit('/instrumented/editor/index.html');
- approveStorage();
-};
+ cy.visit('/instrumented/editor/index.html')
+ approveStorage()
+}
export const openMainMenu = () => {
- return cy.get('#main_button').click({ force: true });
-};
+ return cy.get('#main_button').click({ force: true })
+}
export const openEditorPreferences = () => {
- openMainMenu();
- return cy.get('#tool_editor_prefs').click();
-};
+ openMainMenu()
+ return cy.get('#tool_editor_prefs').click()
+}
export const selectEnglish = () => {
- openEditorPreferences();
- cy.get('#lang_select').select('en');
- cy.get('#tool_prefs_save').click();
-};
+ openEditorPreferences()
+ cy.get('#lang_select').select('en')
+ cy.get('#tool_prefs_save').click()
+}
diff --git a/demos/canvas.html b/demos/canvas.html
index 0a903806..c98aee3d 100644
--- a/demos/canvas.html
+++ b/demos/canvas.html
@@ -27,14 +27,14 @@