summaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2023-06-13 01:43:37 +0200
committerUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2023-06-13 01:43:37 +0200
commit03322672782a6318b019eff33fe44ec800d6f12c (patch)
tree9d807e1585cf28a1ea98e87b855932dba00f1880 /spec
parent8e18b4698edd00f83af0be05bb3374f92fecaeb9 (diff)
downloadsvg.js-03322672782a6318b019eff33fe44ec800d6f12c.tar.gz
svg.js-03322672782a6318b019eff33fe44ec800d6f12c.zip
dependency updates, easier formatting
Diffstat (limited to 'spec')
-rw-r--r--spec/RAFPlugin.js31
-rw-r--r--spec/SpecRunner.html52
-rw-r--r--spec/SpecRunnerEs6.html81
-rw-r--r--spec/checkForAllTests.js8
-rw-r--r--spec/fixtures/fixture.css8
-rw-r--r--spec/helpers.js225
-rw-r--r--spec/runSVGDomTest.js8
-rw-r--r--spec/setupSVGDom.js4
-rw-r--r--spec/spec/animation/Animator.js2
-rw-r--r--spec/spec/animation/Controller.js11
-rw-r--r--spec/spec/animation/Morphable.js277
-rw-r--r--spec/spec/animation/Queue.js4
-rw-r--r--spec/spec/animation/Runner.js516
-rw-r--r--spec/spec/animation/Timeline.js22
-rw-r--r--spec/spec/elements/A.js4
-rw-r--r--spec/spec/elements/ClipPath.js4
-rw-r--r--spec/spec/elements/Container.js38
-rw-r--r--spec/spec/elements/Dom.js125
-rw-r--r--spec/spec/elements/Element.js17
-rw-r--r--spec/spec/elements/ForeignObject.js1
-rw-r--r--spec/spec/elements/Fragment.js12
-rw-r--r--spec/spec/elements/G.js1
-rw-r--r--spec/spec/elements/Gradient.js6
-rw-r--r--spec/spec/elements/Image.js49
-rw-r--r--spec/spec/elements/Line.js73
-rw-r--r--spec/spec/elements/Marker.js9
-rw-r--r--spec/spec/elements/Mask.js5
-rw-r--r--spec/spec/elements/Path.js78
-rw-r--r--spec/spec/elements/Pattern.js13
-rw-r--r--spec/spec/elements/Polygon.js9
-rw-r--r--spec/spec/elements/Polyline.js9
-rw-r--r--spec/spec/elements/Rect.js5
-rw-r--r--spec/spec/elements/Stop.js6
-rw-r--r--spec/spec/elements/Style.js12
-rw-r--r--spec/spec/elements/Svg.js7
-rw-r--r--spec/spec/elements/Symbol.js2
-rw-r--r--spec/spec/elements/Text.js9
-rw-r--r--spec/spec/elements/TextPath.js6
-rw-r--r--spec/spec/elements/Tspan.js5
-rw-r--r--spec/spec/modules/core/attr.js10
-rw-r--r--spec/spec/modules/core/circled.js1
-rw-r--r--spec/spec/modules/core/containerGeometry.js24
-rw-r--r--spec/spec/modules/core/event.js27
-rw-r--r--spec/spec/modules/core/gradiented.js2
-rw-r--r--spec/spec/modules/core/pointed.js7
-rw-r--r--spec/spec/modules/core/poly.js78
-rw-r--r--spec/spec/modules/core/regex.js20
-rw-r--r--spec/spec/modules/core/selector.js18
-rw-r--r--spec/spec/modules/core/textable.js27
-rw-r--r--spec/spec/modules/optional/arrange.js26
-rw-r--r--spec/spec/modules/optional/class.js34
-rw-r--r--spec/spec/modules/optional/css.js51
-rw-r--r--spec/spec/modules/optional/data.js77
-rw-r--r--spec/spec/modules/optional/memory.js66
-rw-r--r--spec/spec/modules/optional/sugar.js110
-rw-r--r--spec/spec/modules/optional/transform.js31
-rw-r--r--spec/spec/types/Box.js185
-rw-r--r--spec/spec/types/Color.js21
-rw-r--r--spec/spec/types/EventTarget.js4
-rw-r--r--spec/spec/types/List.js42
-rw-r--r--spec/spec/types/Matrix.js141
-rw-r--r--spec/spec/types/PathArray.js46
-rw-r--r--spec/spec/types/Point.js19
-rw-r--r--spec/spec/types/PointArray.js107
-rw-r--r--spec/spec/types/SVGArray.js42
-rw-r--r--spec/spec/types/SVGNumber.js10
-rw-r--r--spec/spec/utils/adopter.js30
-rw-r--r--spec/spec/utils/methods.js6
-rw-r--r--spec/spec/utils/pathParser.js211
-rw-r--r--spec/spec/utils/utils.js50
-rw-r--r--spec/spec/utils/window.js9
71 files changed, 2165 insertions, 1121 deletions
diff --git a/spec/RAFPlugin.js b/spec/RAFPlugin.js
index 770212c..c6b96e2 100644
--- a/spec/RAFPlugin.js
+++ b/spec/RAFPlugin.js
@@ -3,19 +3,18 @@
* Jasmine RequestAnimationFrame: a set of helpers for testing functionality
* that uses requestAnimationFrame under the Jasmine BDD framework for JavaScript.
*/
-function RAFPlugin (jasmine) {
-
+function RAFPlugin(jasmine) {
var index = 0
var callbacks = []
- function MockRAF () {
+ function MockRAF() {
this.nextTime = 0
var _this = this
/**
- * Mock for window.requestAnimationFrame
- */
+ * Mock for window.requestAnimationFrame
+ */
this.mockRAF = function (fn) {
if (typeof fn !== 'function') {
throw new Error('You should pass a function to requestAnimationFrame')
@@ -28,8 +27,8 @@ function RAFPlugin (jasmine) {
}
/**
- * Mock for window.cancelAnimationFrame
- */
+ * Mock for window.cancelAnimationFrame
+ */
this.mockCAF = function (requestID) {
callbacks.splice(requestID, 1)
}
@@ -41,8 +40,8 @@ function RAFPlugin (jasmine) {
}
/**
- * Install request animation frame mocks.
- */
+ * Install request animation frame mocks.
+ */
this.install = function (global) {
_this.realRAF = global.requestAnimationFrame
_this.realCAF = global.cancelAnimationFrame
@@ -53,8 +52,8 @@ function RAFPlugin (jasmine) {
}
/**
- * Uninstall request animation frame mocks.
- */
+ * Uninstall request animation frame mocks.
+ */
this.uninstall = function (global) {
global.requestAnimationFrame = _this.realRAF
global.cancelAnimationFrame = _this.realCAF
@@ -64,12 +63,14 @@ function RAFPlugin (jasmine) {
}
/**
- * Simulate animation frame readiness.
- */
+ * Simulate animation frame readiness.
+ */
this.tick = function (dt) {
- _this.nextTime += (dt || 1)
+ _this.nextTime += dt || 1
- var fns = callbacks; var fn; var i
+ var fns = callbacks
+ var fn
+ var i
callbacks = []
index = 0
diff --git a/spec/SpecRunner.html b/spec/SpecRunner.html
index 56a8885..bd7b59a 100644
--- a/spec/SpecRunner.html
+++ b/spec/SpecRunner.html
@@ -1,27 +1,31 @@
<!DOCTYPE html>
<html>
-<head>
- <meta charset="utf-8">
- <title>SVG.js - Jasmine Spec Runner</title>
-
- <link rel="shortcut icon" type="image/png" href="../node_modules/jasmine-core/images/jasmine_favicon.png">
- <link rel="stylesheet" href="../node_modules/jasmine-core/lib/jasmine-core/jasmine.css">
-
- <script src="../node_modules/jasmine-core/lib/jasmine-core/jasmine.js"></script>
- <script src="../node_modules/jasmine-core/lib/jasmine-core/jasmine-html.js"></script>
- <script src="../node_modules/jasmine-core/lib/jasmine-core/boot.js"></script>
- <script src="RAFPlugin.js"></script>
-
- <link rel="stylesheet" href="fixtures/fixture.css">
-
-</head>
-
-<body>
-
-
- <!-- include spec files here... -->
-
- <script src="../dist/polyfillsIE.js"></script>
- <script src="es5TestBundle.js"></script>
-</body>
+ <head>
+ <meta charset="utf-8" />
+ <title>SVG.js - Jasmine Spec Runner</title>
+
+ <link
+ rel="shortcut icon"
+ type="image/png"
+ href="../node_modules/jasmine-core/images/jasmine_favicon.png"
+ />
+ <link
+ rel="stylesheet"
+ href="../node_modules/jasmine-core/lib/jasmine-core/jasmine.css"
+ />
+
+ <script src="../node_modules/jasmine-core/lib/jasmine-core/jasmine.js"></script>
+ <script src="../node_modules/jasmine-core/lib/jasmine-core/jasmine-html.js"></script>
+ <script src="../node_modules/jasmine-core/lib/jasmine-core/boot.js"></script>
+ <script src="RAFPlugin.js"></script>
+
+ <link rel="stylesheet" href="fixtures/fixture.css" />
+ </head>
+
+ <body>
+ <!-- include spec files here... -->
+
+ <script src="../dist/polyfillsIE.js"></script>
+ <script src="es5TestBundle.js"></script>
+ </body>
</html>
diff --git a/spec/SpecRunnerEs6.html b/spec/SpecRunnerEs6.html
index eb6b17b..05156bd 100644
--- a/spec/SpecRunnerEs6.html
+++ b/spec/SpecRunnerEs6.html
@@ -1,45 +1,50 @@
<!DOCTYPE html>
<html>
-<head>
- <meta charset="utf-8">
- <title>SVG.js - Jasmine Spec Runner</title>
+ <head>
+ <meta charset="utf-8" />
+ <title>SVG.js - Jasmine Spec Runner</title>
- <link rel="shortcut icon" type="image/png" href="../node_modules/jasmine-core/images/jasmine_favicon.png">
- <link rel="stylesheet" href="../node_modules/jasmine-core/lib/jasmine-core/jasmine.css">
+ <link
+ rel="shortcut icon"
+ type="image/png"
+ href="../node_modules/jasmine-core/images/jasmine_favicon.png"
+ />
+ <link
+ rel="stylesheet"
+ href="../node_modules/jasmine-core/lib/jasmine-core/jasmine.css"
+ />
- <script src="../node_modules/jasmine-core/lib/jasmine-core/jasmine.js"></script>
- <script src="../node_modules/jasmine-core/lib/jasmine-core/jasmine-html.js"></script>
- <script src="../node_modules/jasmine-core/lib/jasmine-core/boot.js"></script>
- <script src="RAFPlugin.js"></script>
+ <script src="../node_modules/jasmine-core/lib/jasmine-core/jasmine.js"></script>
+ <script src="../node_modules/jasmine-core/lib/jasmine-core/jasmine-html.js"></script>
+ <script src="../node_modules/jasmine-core/lib/jasmine-core/boot.js"></script>
+ <script src="RAFPlugin.js"></script>
- <link rel="stylesheet" href="fixtures/fixture.css">
+ <link rel="stylesheet" href="fixtures/fixture.css" />
+ </head>
-</head>
-
-<body>
-
- <!-- include spec files here... -->
- <script type="module" src="setupBrowser.js"></script>
- <script type="module" src="spec/elements/A.js"></script>
- <script type="module" src="spec/elements/Circle.js"></script>
- <script type="module" src="spec/elements/ClipPath.js"></script>
- <script type="module" src="spec/elements/Container.js"></script>
- <script type="module" src="spec/elements/Dom.js"></script>
- <script type="module" src="spec/elements/Element.js"></script>
- <script type="module" src="spec/elements/ForeignObject.js"></script>
- <script type="module" src="spec/elements/G.js"></script>
- <script type="module" src="spec/elements/Image.js"></script>
- <script type="module" src="spec/elements/Marker.js"></script>
- <script type="module" src="spec/elements/Svg.js"></script>
- <script type="module" src="spec/elements/Text.js"></script>
- <script type="module" src="spec/elements/TextPath.js"></script>
- <script type="module" src="spec/elements/Tspan.js"></script>
- <script type="module" src="spec/modules/core/event.js"></script>
- <script type="module" src="spec/modules/core/textable.js"></script>
- <script type="module" src="spec/types/ArrayPolyfill.js"></script>
- <script type="module" src="spec/types/Base.js"></script>
- <script type="module" src="spec/types/Box.js"></script>
- <script type="module" src="spec/utils/adopter.js"></script>
- <script type="module" src="spec/utils/utils.js"></script>
-</body>
+ <body>
+ <!-- include spec files here... -->
+ <script type="module" src="setupBrowser.js"></script>
+ <script type="module" src="spec/elements/A.js"></script>
+ <script type="module" src="spec/elements/Circle.js"></script>
+ <script type="module" src="spec/elements/ClipPath.js"></script>
+ <script type="module" src="spec/elements/Container.js"></script>
+ <script type="module" src="spec/elements/Dom.js"></script>
+ <script type="module" src="spec/elements/Element.js"></script>
+ <script type="module" src="spec/elements/ForeignObject.js"></script>
+ <script type="module" src="spec/elements/G.js"></script>
+ <script type="module" src="spec/elements/Image.js"></script>
+ <script type="module" src="spec/elements/Marker.js"></script>
+ <script type="module" src="spec/elements/Svg.js"></script>
+ <script type="module" src="spec/elements/Text.js"></script>
+ <script type="module" src="spec/elements/TextPath.js"></script>
+ <script type="module" src="spec/elements/Tspan.js"></script>
+ <script type="module" src="spec/modules/core/event.js"></script>
+ <script type="module" src="spec/modules/core/textable.js"></script>
+ <script type="module" src="spec/types/ArrayPolyfill.js"></script>
+ <script type="module" src="spec/types/Base.js"></script>
+ <script type="module" src="spec/types/Box.js"></script>
+ <script type="module" src="spec/utils/adopter.js"></script>
+ <script type="module" src="spec/utils/utils.js"></script>
+ </body>
</html>
diff --git a/spec/checkForAllTests.js b/spec/checkForAllTests.js
index 99c648e..d25a6a4 100644
--- a/spec/checkForAllTests.js
+++ b/spec/checkForAllTests.js
@@ -2,7 +2,6 @@ const glob = require('glob')
const path = require('path')
glob('./spec/*/**/*.js', (err, tests) => {
-
if (err) {
throw err
}
@@ -14,10 +13,13 @@ glob('./spec/*/**/*.js', (err, tests) => {
files = files.map((e) => path.basename(e))
tests = tests.map((e) => path.basename(e))
- const difference = files.filter(x => !tests.includes(x))
+ const difference = files.filter((x) => !tests.includes(x))
if (difference.length) {
- console.error('The following files dont have a test file:\n\t' + difference.join('\n\t'))
+ console.error(
+ 'The following files dont have a test file:\n\t' +
+ difference.join('\n\t')
+ )
} else {
console.info('All src files are covered by tests')
}
diff --git a/spec/fixtures/fixture.css b/spec/fixtures/fixture.css
index 4fad17b..85d4345 100644
--- a/spec/fixtures/fixture.css
+++ b/spec/fixtures/fixture.css
@@ -1,6 +1,6 @@
#drawing {
- width: 500px;
- height: 500px;
- position: fixed;
- z-index: -1;
+ width: 500px;
+ height: 500px;
+ position: fixed;
+ z-index: -1;
}
diff --git a/spec/helpers.js b/spec/helpers.js
index 7d63dfa..b5b29c3 100644
--- a/spec/helpers.js
+++ b/spec/helpers.js
@@ -1,7 +1,7 @@
import { getWindow } from '../src/utils/window.js'
import { svg } from '../src/modules/core/namespaces.js'
-function tag (name, attrs, children) {
+function tag(name, attrs, children) {
const doc = getWindow().document
const el = doc.createElementNS(svg, name)
let i
@@ -11,7 +11,9 @@ function tag (name, attrs, children) {
}
for (i in children) {
- if (typeof children[i] === 'string') { children[i] = doc.createTextNode(children[i]) }
+ if (typeof children[i] === 'string') {
+ children[i] = doc.createTextNode(children[i])
+ }
el.appendChild(children[i])
}
@@ -19,104 +21,128 @@ function tag (name, attrs, children) {
return el
}
-export function fixtures () {
- return tag('svg', {
- height: 0,
- width: 0,
- id: 'inlineSVG'
- }, [
- tag('defs', {}, [
- tag('linearGradient', {}, [
- tag('stop', { offset: '5%', 'stop-color': 'green' }),
- tag('stop', { offset: '95%', 'stop-color': 'gold' })
+export function fixtures() {
+ return tag(
+ 'svg',
+ {
+ height: 0,
+ width: 0,
+ id: 'inlineSVG'
+ },
+ [
+ tag('defs', {}, [
+ tag('linearGradient', {}, [
+ tag('stop', { offset: '5%', 'stop-color': 'green' }),
+ tag('stop', { offset: '95%', 'stop-color': 'gold' })
+ ]),
+ tag('radialGradient', {}, [
+ tag('stop', { offset: '5%', 'stop-color': 'green' }),
+ tag('stop', { offset: '95%', 'stop-color': 'gold' })
+ ])
]),
- tag('radialGradient', {}, [
- tag('stop', { offset: '5%', 'stop-color': 'green' }),
- tag('stop', { offset: '95%', 'stop-color': 'gold' })
- ])
- ]),
- tag('desc', {}, [ 'Some description' ]),
- tag('path', {
- id: 'lineAB',
- d: 'M 100 350 l 150 -300',
- stroke: 'red',
- 'stroke-width': '3',
- fill: 'none'
- }),
- tag('path', {
- id: 'lineBC',
- d: 'M 250 50 l 150 300',
- stroke: 'red',
- 'stroke-width': '3',
- fill: 'none'
- }),
- tag('path', {
- d: 'M 175 200 l 150 0',
- stroke: 'green',
- 'stroke-width': '3',
- fill: 'none'
- }),
- tag('path', {
- d: 'M 100 350 q 150 -300 300 0',
- stroke: 'blue',
- 'stroke-width': '5',
- fill: 'none'
- }),
- tag('g', {
- stroke: 'black',
- 'stroke-width': '2',
- fill: 'black',
- id: 'pointGroup'
- }, [
- tag('circle', {
- id: 'pointA',
- cx: '100',
- cy: '350',
- r: '3'
+ tag('desc', {}, ['Some description']),
+ tag('path', {
+ id: 'lineAB',
+ d: 'M 100 350 l 150 -300',
+ stroke: 'red',
+ 'stroke-width': '3',
+ fill: 'none'
}),
- tag('circle', {
- id: 'pointB',
- cx: '250',
- cy: '50',
- r: '50'
+ tag('path', {
+ id: 'lineBC',
+ d: 'M 250 50 l 150 300',
+ stroke: 'red',
+ 'stroke-width': '3',
+ fill: 'none'
}),
- tag('circle', {
- id: 'pointC',
- cx: '400',
- cy: '350',
- r: '50'
- })
- ]),
- tag('g', {
- 'font-size': '30',
- font: 'sans-serif',
- fill: 'black',
- stroke: 'none',
- 'text-anchor': 'middle',
- id: 'labelGroup'
- }, [
- tag('text', {
- x: '100',
- y: '350',
- dy: '-30'
- }, [ 'A' ]),
- tag('text', {
- x: '250',
- y: '50',
- dy: '-10'
- }, [ 'B' ]),
- tag('text', {
- x: '400',
- y: '350',
- dx: '30'
- }, [ 'C' ])
- ]),
- tag('polygon', { points: '200,10 250,190 160,210' }),
- tag('polyline', { points: '20,20 40,25 60,40 80,120 120,140 200,180' })
- ])
+ tag('path', {
+ d: 'M 175 200 l 150 0',
+ stroke: 'green',
+ 'stroke-width': '3',
+ fill: 'none'
+ }),
+ tag('path', {
+ d: 'M 100 350 q 150 -300 300 0',
+ stroke: 'blue',
+ 'stroke-width': '5',
+ fill: 'none'
+ }),
+ tag(
+ 'g',
+ {
+ stroke: 'black',
+ 'stroke-width': '2',
+ fill: 'black',
+ id: 'pointGroup'
+ },
+ [
+ tag('circle', {
+ id: 'pointA',
+ cx: '100',
+ cy: '350',
+ r: '3'
+ }),
+ tag('circle', {
+ id: 'pointB',
+ cx: '250',
+ cy: '50',
+ r: '50'
+ }),
+ tag('circle', {
+ id: 'pointC',
+ cx: '400',
+ cy: '350',
+ r: '50'
+ })
+ ]
+ ),
+ tag(
+ 'g',
+ {
+ 'font-size': '30',
+ font: 'sans-serif',
+ fill: 'black',
+ stroke: 'none',
+ 'text-anchor': 'middle',
+ id: 'labelGroup'
+ },
+ [
+ tag(
+ 'text',
+ {
+ x: '100',
+ y: '350',
+ dy: '-30'
+ },
+ ['A']
+ ),
+ tag(
+ 'text',
+ {
+ x: '250',
+ y: '50',
+ dy: '-10'
+ },
+ ['B']
+ ),
+ tag(
+ 'text',
+ {
+ x: '400',
+ y: '350',
+ dx: '30'
+ },
+ ['C']
+ )
+ ]
+ ),
+ tag('polygon', { points: '200,10 250,190 160,210' }),
+ tag('polyline', { points: '20,20 40,25 60,40 80,120 120,140 200,180' })
+ ]
+ )
}
-export function buildFixtures () {
+export function buildFixtures() {
const doc = getWindow().document
const body = doc.body || doc.documentElement
@@ -134,7 +160,7 @@ export function buildFixtures () {
body.appendChild(div)
}
-export function buildCanvas () {
+export function buildCanvas() {
const doc = getWindow().document
const body = doc.body || doc.documentElement
@@ -150,7 +176,7 @@ export function buildCanvas () {
body.appendChild(div)
}
-export function clear () {
+export function clear() {
const doc = getWindow().document
const canvas = doc.getElementById('canvas')
const fixtures = doc.getElementById('fixtures')
@@ -158,6 +184,7 @@ export function clear () {
// remove if present
fixtures && fixtures.parentNode.removeChild(fixtures)
canvas.parentNode.removeChild(canvas)
-
- ;[ ...doc.querySelectorAll('svg') ].forEach((el) => el.parentNode.removeChild(el))
+ ;[...doc.querySelectorAll('svg')].forEach((el) =>
+ el.parentNode.removeChild(el)
+ )
}
diff --git a/spec/runSVGDomTest.js b/spec/runSVGDomTest.js
index 3ce24cf..cada481 100644
--- a/spec/runSVGDomTest.js
+++ b/spec/runSVGDomTest.js
@@ -10,12 +10,8 @@ const jasmine = new Jasmine()
jasmine.loadConfig({
spec_dir: '/',
- spec_files: [
- 'spec/spec/*/**/*.js'
- ],
- helpers: [
- 'spec/setupSVGDom.js'
- ]
+ spec_files: ['spec/spec/*/**/*.js'],
+ helpers: ['spec/setupSVGDom.js']
})
jasmine.execute()
diff --git a/spec/setupSVGDom.js b/spec/setupSVGDom.js
index 22bf565..be5b803 100644
--- a/spec/setupSVGDom.js
+++ b/spec/setupSVGDom.js
@@ -7,7 +7,7 @@ import { registerWindow } from '../src/main.js'
jasmine.DEFAULT_TIMEOUT_INTERVAL = 200
-function setup () {
+function setup() {
const win = createHTMLWindow()
registerWindow(win, win.document)
buildCanvas()
@@ -15,7 +15,7 @@ function setup () {
global.container = win.document.getElementById('canvas')
}
-function teardown () {
+function teardown() {
clear()
global.container = null
registerWindow()
diff --git a/spec/spec/animation/Animator.js b/spec/spec/animation/Animator.js
index 043beaa..695dca7 100644
--- a/spec/spec/animation/Animator.js
+++ b/spec/spec/animation/Animator.js
@@ -4,7 +4,6 @@ import { Animator, Queue } from '../../../src/main.js'
import { getWindow } from '../../../src/utils/window.js'
describe('Animator.js', () => {
-
beforeEach(() => {
jasmine.RequestAnimationFrame.install(getWindow())
Animator.timeouts = new Queue()
@@ -19,7 +18,6 @@ describe('Animator.js', () => {
describe('timeout()', () => {
it('calls a function after a specific time', () => {
-
var spy = jasmine.createSpy('tester')
Animator.timeout(spy, 100)
diff --git a/spec/spec/animation/Controller.js b/spec/spec/animation/Controller.js
index 8ad074d..b81678b 100644
--- a/spec/spec/animation/Controller.js
+++ b/spec/spec/animation/Controller.js
@@ -1,12 +1,17 @@
/* globals describe, expect, it, jasmine */
import { easing, defaults } from '../../../src/main.js'
-import { Stepper, Ease, Controller, Spring, PID } from '../../../src/animation/Controller.js'
+import {
+ Stepper,
+ Ease,
+ Controller,
+ Spring,
+ PID
+} from '../../../src/animation/Controller.js'
const { any, createSpy } = jasmine
describe('Controller.js', () => {
-
describe('easing', () => {
var easedValues = {
'-': 0.5,
@@ -15,7 +20,7 @@ describe('Controller.js', () => {
'<': 0.2929
}
- ;[ '-', '<>', '<', '>' ].forEach((el) => {
+ ;['-', '<>', '<', '>'].forEach((el) => {
describe(el, () => {
it('is 0 at 0', () => {
expect(easing[el](0)).toBe(0)
diff --git a/spec/spec/animation/Morphable.js b/spec/spec/animation/Morphable.js
index 2fa58aa..d5d313a 100644
--- a/spec/spec/animation/Morphable.js
+++ b/spec/spec/animation/Morphable.js
@@ -1,6 +1,18 @@
/* globals describe, expect, it, jasmine */
-import { Morphable, NonMorphable, ObjectBag, Color, Box, Matrix, PointArray, PathArray, TransformBag, Number as SVGNumber, Array as SVGArray } from '../../../src/main.js'
+import {
+ Morphable,
+ NonMorphable,
+ ObjectBag,
+ Color,
+ Box,
+ Matrix,
+ PointArray,
+ PathArray,
+ TransformBag,
+ Number as SVGNumber,
+ Array as SVGArray
+} from '../../../src/main.js'
import { Stepper, easing, Ease } from '../../../src/animation/Controller.js'
const { objectContaining, arrayContaining, any } = jasmine
@@ -20,7 +32,6 @@ describe('Morphable.js', () => {
})
describe('constructors', () => {
-
it('Morphable with SVGNumber', () => {
const morpher = new Morphable().from(10).to(5)
@@ -46,16 +57,25 @@ describe('Morphable.js', () => {
expect(morpher).toEqual(any(Morphable))
expect(morpher.type()).toBe(ObjectBag)
expect(morpher.at(0.5)).toEqual(any(Object))
- expect(morpher.at(0.5).valueOf()).toEqual(objectContaining({ a: new SVGNumber(7.5), b: new SVGNumber(15) }))
+ expect(morpher.at(0.5).valueOf()).toEqual(
+ objectContaining({ a: new SVGNumber(7.5), b: new SVGNumber(15) })
+ )
})
it('Morphable from object containing css values', () => {
- const morpher = new Morphable().from({ opacity: '0', 'stroke-width': '10px' }).to({ opacity: 1, 'stroke-width': 20 })
+ const morpher = new Morphable()
+ .from({ opacity: '0', 'stroke-width': '10px' })
+ .to({ opacity: 1, 'stroke-width': 20 })
expect(morpher).toEqual(any(Morphable))
expect(morpher.type()).toBe(ObjectBag)
expect(morpher.at(0.5)).toEqual(any(Object))
- expect(morpher.at(0.5).valueOf()).toEqual(objectContaining({ opacity: new SVGNumber(0.5), 'stroke-width': new SVGNumber('15px') }))
+ expect(morpher.at(0.5).valueOf()).toEqual(
+ objectContaining({
+ opacity: new SVGNumber(0.5),
+ 'stroke-width': new SVGNumber('15px')
+ })
+ )
})
it('Creates a morphable out of an SVGNumber', () => {
@@ -77,48 +97,68 @@ describe('Morphable.js', () => {
})
it('Creates a morphable out of an Box', () => {
- const morpher = new Box(1, 2, 3, 4).to([ 5, 6, 7, 8 ])
+ const morpher = new Box(1, 2, 3, 4).to([5, 6, 7, 8])
expect(morpher).toEqual(any(Morphable))
expect(morpher.type()).toBe(Box)
expect(morpher.at(0.5)).toEqual(any(Box))
- expect(morpher.at(0.5)).toEqual(objectContaining({ x: 3, y: 4, width: 5, height: 6 }))
+ expect(morpher.at(0.5)).toEqual(
+ objectContaining({ x: 3, y: 4, width: 5, height: 6 })
+ )
})
it('Creates a morphable out of an Matrix', () => {
- const morpher = new Matrix(1, 2, 3, 4, 5, 6).to([ 3, 4, 5, 6, 7, 8 ])
+ const morpher = new Matrix(1, 2, 3, 4, 5, 6).to([3, 4, 5, 6, 7, 8])
expect(morpher).toEqual(any(Morphable))
expect(morpher.type()).toBe(Matrix)
expect(morpher.at(0.5)).toEqual(any(Matrix))
- expect(morpher.at(0.5)).toEqual(objectContaining(new Matrix(2, 3, 4, 5, 6, 7)))
+ expect(morpher.at(0.5)).toEqual(
+ objectContaining(new Matrix(2, 3, 4, 5, 6, 7))
+ )
})
it('Creates a morphable out of an SVGArray', () => {
- const morpher = new SVGArray([ 1, 2, 3, 4, 5, 6 ]).to([ 3, 4, 5, 6, 7, 8 ])
+ const morpher = new SVGArray([1, 2, 3, 4, 5, 6]).to([3, 4, 5, 6, 7, 8])
expect(morpher).toEqual(any(Morphable))
expect(morpher.type()).toBe(SVGArray)
expect(morpher.at(0.5)).toEqual(any(SVGArray))
- expect(morpher.at(0.5).toArray()).toEqual(arrayContaining([ 2, 3, 4, 5, 6, 7 ]))
+ expect(morpher.at(0.5).toArray()).toEqual(
+ arrayContaining([2, 3, 4, 5, 6, 7])
+ )
})
it('Creates a morphable out of an PointArray', () => {
- const morpher = new PointArray([ 1, 2, 3, 4, 5, 6 ]).to([ 3, 4, 5, 6, 7, 8 ])
+ const morpher = new PointArray([1, 2, 3, 4, 5, 6]).to([3, 4, 5, 6, 7, 8])
expect(morpher).toEqual(any(Morphable))
expect(morpher.type()).toBe(PointArray)
expect(morpher.at(0.5)).toEqual(any(PointArray))
- expect(morpher.at(0.5).toArray()).toEqual(arrayContaining([ 2, 3, 4, 5, 6, 7 ]))
+ expect(morpher.at(0.5).toArray()).toEqual(
+ arrayContaining([2, 3, 4, 5, 6, 7])
+ )
})
it('Creates a morphable out of an PathArray', () => {
- const morpher = new PathArray([ 'M', 1, 2, 'L', 3, 4, 'L', 5, 6 ]).to([ 'M', 3, 4, 'L', 5, 6, 'L', 7, 8 ])
+ const morpher = new PathArray(['M', 1, 2, 'L', 3, 4, 'L', 5, 6]).to([
+ 'M',
+ 3,
+ 4,
+ 'L',
+ 5,
+ 6,
+ 'L',
+ 7,
+ 8
+ ])
expect(morpher).toEqual(any(Morphable))
expect(morpher.type()).toBe(PathArray)
expect(morpher.at(0.5)).toEqual(any(PathArray))
- expect(morpher.at(0.5).toArray()).toEqual(arrayContaining([ 'M', 2, 3, 'L', 4, 5, 'L', 6, 7 ]))
+ expect(morpher.at(0.5).toArray()).toEqual(
+ arrayContaining(['M', 2, 3, 'L', 4, 5, 'L', 6, 7])
+ )
})
it('creates a morphable from unmorphable types', () => {
@@ -132,14 +172,18 @@ describe('Morphable.js', () => {
})
it('Creates a morphable out of an TransformBag', () => {
- const morpher = new TransformBag({ rotate: 0, translateX: 0 })
- .to({ rotate: 50, translateX: 20 })
+ const morpher = new TransformBag({ rotate: 0, translateX: 0 }).to({
+ rotate: 50,
+ translateX: 20
+ })
expect(morpher).toEqual(any(Morphable))
expect(morpher.type()).toBe(TransformBag)
expect(morpher.at(0.5)).toEqual(any(TransformBag))
- expect(morpher.at(0.5)).toEqual(objectContaining({ rotate: 25, translateX: 10 }))
+ expect(morpher.at(0.5)).toEqual(
+ objectContaining({ rotate: 25, translateX: 10 })
+ )
})
it('Creates a morphable out of an ObjectBag', () => {
@@ -148,7 +192,9 @@ describe('Morphable.js', () => {
expect(morpher).toEqual(any(Morphable))
expect(morpher.type()).toBe(ObjectBag)
expect(morpher.at(0.5)).toEqual(any(Object))
- expect(morpher.at(0.5).valueOf()).toEqual(objectContaining({ a: new SVGNumber(7.5), b: new SVGNumber(15) }))
+ expect(morpher.at(0.5).valueOf()).toEqual(
+ objectContaining({ a: new SVGNumber(7.5), b: new SVGNumber(15) })
+ )
})
it('creates a morphable from a color string', () => {
@@ -198,16 +244,16 @@ describe('Morphable.js', () => {
expect(morpher).toEqual(any(Morphable))
expect(morpher.type()).toBe(SVGArray)
expect(morpher.at(0.5)).toEqual(any(SVGArray))
- expect(morpher.at(0.5)).toEqual([ 2, 3, 4, 5 ])
+ expect(morpher.at(0.5)).toEqual([2, 3, 4, 5])
})
it('creates a morphable from an array', () => {
- const morpher = new Morphable().from([ 0, 1, 2, 3 ]).to([ 4, 5, 6, 7 ])
+ const morpher = new Morphable().from([0, 1, 2, 3]).to([4, 5, 6, 7])
expect(morpher).toEqual(any(Morphable))
expect(morpher.type()).toBe(SVGArray)
expect(morpher.at(0.5)).toEqual(any(SVGArray))
- expect(morpher.at(0.5)).toEqual([ 2, 3, 4, 5 ])
+ expect(morpher.at(0.5)).toEqual([2, 3, 4, 5])
})
it('converts the to-color to the from-type', () => {
@@ -231,7 +277,7 @@ describe('Morphable.js', () => {
it('sets the from attribute to an array representation of the morphable type', () => {
const morpher = new Morphable().from(5)
- expect(morpher.from()).toEqual(arrayContaining([ 5 ]))
+ expect(morpher.from()).toEqual(arrayContaining([5]))
})
})
@@ -255,7 +301,7 @@ describe('Morphable.js', () => {
it('sets the from attribute to an array representation of the morphable type', () => {
const morpher = new Morphable().to(5)
- expect(morpher.to()).toEqual(arrayContaining([ 5 ]))
+ expect(morpher.to()).toEqual(arrayContaining([5]))
})
})
@@ -270,7 +316,7 @@ describe('Morphable.js', () => {
describe('NonMorphable', () => {
describe('()', () => {
it('wraps any type into a NonMorphable from an array', () => {
- const non = new NonMorphable([ 5 ])
+ const non = new NonMorphable([5])
expect(non.valueOf()).toBe(5)
})
@@ -282,8 +328,8 @@ describe('Morphable.js', () => {
describe('toArray()', () => {
it('returns array representation of NonMorphable', () => {
- expect(new NonMorphable(5).toArray()).toEqual([ 5 ])
- expect(new NonMorphable('Hello').toArray()).toEqual([ 'Hello' ])
+ expect(new NonMorphable(5).toArray()).toEqual([5])
+ expect(new NonMorphable('Hello').toArray()).toEqual(['Hello'])
})
})
})
@@ -291,8 +337,8 @@ describe('Morphable.js', () => {
describe('TransformBag', () => {
describe('()', () => {
it('creates an object which holds transformations for morphing by passing array', () => {
- const bag = new TransformBag([ 0, 1, 2, 3, 4, 5, 6, 7 ])
- expect(bag.toArray()).toEqual([ 0, 1, 2, 3, 4, 5, 6, 7 ])
+ const bag = new TransformBag([0, 1, 2, 3, 4, 5, 6, 7])
+ expect(bag.toArray()).toEqual([0, 1, 2, 3, 4, 5, 6, 7])
})
it('creates an object which holds transformations for morphing by passing object', () => {
@@ -307,14 +353,14 @@ describe('Morphable.js', () => {
originY: 7
})
- expect(bag.toArray()).toEqual([ 0, 1, 2, 3, 4, 5, 6, 7 ])
+ expect(bag.toArray()).toEqual([0, 1, 2, 3, 4, 5, 6, 7])
})
})
describe('toArray()', () => {
it('creates an array out of the transform values', () => {
- const bag = new TransformBag([ 0, 1, 2, 3, 4, 5, 6, 7 ])
- expect(bag.toArray()).toEqual([ 0, 1, 2, 3, 4, 5, 6, 7 ])
+ const bag = new TransformBag([0, 1, 2, 3, 4, 5, 6, 7])
+ expect(bag.toArray()).toEqual([0, 1, 2, 3, 4, 5, 6, 7])
})
})
})
@@ -322,51 +368,174 @@ describe('Morphable.js', () => {
describe('ObjectBag', () => {
describe('()', () => {
it('wraps an object into a morphable object by passing an array', () => {
- const bag = new ObjectBag([ 'foo', SVGNumber, 2, 1, '', 'bar', SVGNumber, 2, 2, '', 'baz', SVGNumber, 2, 3, '' ])
- expect(bag.values).toEqual([ 'foo', SVGNumber, 2, 1, '', 'bar', SVGNumber, 2, 2, '', 'baz', SVGNumber, 2, 3, '' ])
+ const bag = new ObjectBag([
+ 'foo',
+ SVGNumber,
+ 2,
+ 1,
+ '',
+ 'bar',
+ SVGNumber,
+ 2,
+ 2,
+ '',
+ 'baz',
+ SVGNumber,
+ 2,
+ 3,
+ ''
+ ])
+ expect(bag.values).toEqual([
+ 'foo',
+ SVGNumber,
+ 2,
+ 1,
+ '',
+ 'bar',
+ SVGNumber,
+ 2,
+ 2,
+ '',
+ 'baz',
+ SVGNumber,
+ 2,
+ 3,
+ ''
+ ])
})
it('wraps an object into a morphable object by passing an object', () => {
const bag = new ObjectBag({ foo: 1, bar: 2, baz: 3 })
- expect(bag.values).toEqual([ 'bar', SVGNumber, 2, 2, '', 'baz', SVGNumber, 2, 3, '', 'foo', SVGNumber, 2, 1, '' ])
+ expect(bag.values).toEqual([
+ 'bar',
+ SVGNumber,
+ 2,
+ 2,
+ '',
+ 'baz',
+ SVGNumber,
+ 2,
+ 3,
+ '',
+ 'foo',
+ SVGNumber,
+ 2,
+ 1,
+ ''
+ ])
})
it('wraps an object with morphable values in an ObjectBag', () => {
const bag = new ObjectBag({ fill: new Color(), bar: 2 })
- expect(bag.values).toEqual([ 'bar', SVGNumber, 2, 2, '', 'fill', Color, 5, 0, 0, 0, 0, 'rgb' ])
+ expect(bag.values).toEqual([
+ 'bar',
+ SVGNumber,
+ 2,
+ 2,
+ '',
+ 'fill',
+ Color,
+ 5,
+ 0,
+ 0,
+ 0,
+ 0,
+ 'rgb'
+ ])
})
it('wraps an array with morphable representation in an ObjectBag', () => {
- const bag = new ObjectBag([ 'bar', SVGNumber, 2, 2, '', 'fill', Color, 5, 0, 0, 0, 0, 'rgb' ])
- expect(bag.toArray()).toEqual([ 'bar', SVGNumber, 2, 2, '', 'fill', Color, 5, 0, 0, 0, 0, 'rgb' ])
+ const bag = new ObjectBag([
+ 'bar',
+ SVGNumber,
+ 2,
+ 2,
+ '',
+ 'fill',
+ Color,
+ 5,
+ 0,
+ 0,
+ 0,
+ 0,
+ 'rgb'
+ ])
+ expect(bag.toArray()).toEqual([
+ 'bar',
+ SVGNumber,
+ 2,
+ 2,
+ '',
+ 'fill',
+ Color,
+ 5,
+ 0,
+ 0,
+ 0,
+ 0,
+ 'rgb'
+ ])
})
})
describe('toArray()', () => {
it('creates an array out of the object', () => {
const bag = new ObjectBag({ foo: 1, bar: 2, baz: 3 })
- expect(bag.toArray()).toEqual(
- [ 'bar', SVGNumber, 2, 2, '', 'baz', SVGNumber, 2, 3, '', 'foo', SVGNumber, 2, 1, '' ]
- )
+ expect(bag.toArray()).toEqual([
+ 'bar',
+ SVGNumber,
+ 2,
+ 2,
+ '',
+ 'baz',
+ SVGNumber,
+ 2,
+ 3,
+ '',
+ 'foo',
+ SVGNumber,
+ 2,
+ 1,
+ ''
+ ])
})
it('creates a flattened array out of the object with morphable values', () => {
const bag = new ObjectBag({ fill: new Color(), bar: 2 })
- expect(bag.toArray()).toEqual(
- [ 'bar', SVGNumber, 2, 2, '', 'fill', Color, 5, 0, 0, 0, 0, 'rgb' ]
- )
+ expect(bag.toArray()).toEqual([
+ 'bar',
+ SVGNumber,
+ 2,
+ 2,
+ '',
+ 'fill',
+ Color,
+ 5,
+ 0,
+ 0,
+ 0,
+ 0,
+ 'rgb'
+ ])
})
})
describe('valueOf()', () => {
it('creates morphable objects from the stored values', () => {
const bag = new ObjectBag({ foo: 1, bar: 2, baz: 3 })
- expect(bag.valueOf()).toEqual({ foo: new SVGNumber(1), bar: new SVGNumber(2), baz: new SVGNumber(3) })
+ expect(bag.valueOf()).toEqual({
+ foo: new SVGNumber(1),
+ bar: new SVGNumber(2),
+ baz: new SVGNumber(3)
+ })
})
it('creates also morphable objects from the stored values', () => {
const bag = new ObjectBag({ fill: new Color(), bar: 2 })
- expect(bag.valueOf()).toEqual({ fill: objectContaining(new Color()), bar: new SVGNumber(2) })
+ expect(bag.valueOf()).toEqual({
+ fill: objectContaining(new Color()),
+ bar: new SVGNumber(2)
+ })
})
})
@@ -375,7 +544,21 @@ describe('Morphable.js', () => {
const bag1 = new ObjectBag({ x: 1, y: '#fff' })
const bag2 = new ObjectBag({ x: 2, y: new Color().hsl() })
bag1.align(bag2.toArray())
- expect(bag1.toArray()).toEqual([ 'x', SVGNumber, 2, 1, '', 'y', Color, 5, 0, 0, 100, 0, 'hsl' ])
+ expect(bag1.toArray()).toEqual([
+ 'x',
+ SVGNumber,
+ 2,
+ 1,
+ '',
+ 'y',
+ Color,
+ 5,
+ 0,
+ 0,
+ 100,
+ 0,
+ 'hsl'
+ ])
})
})
})
diff --git a/spec/spec/animation/Queue.js b/spec/spec/animation/Queue.js
index 8386405..b405b62 100644
--- a/spec/spec/animation/Queue.js
+++ b/spec/spec/animation/Queue.js
@@ -3,9 +3,7 @@
import { Queue } from '../../../src/main.js'
describe('Queue.js', function () {
-
describe('first ()', function () {
-
it('returns null if no item in the queue', function () {
var queue = new Queue()
expect(queue.first()).toEqual(null)
@@ -21,7 +19,6 @@ describe('Queue.js', function () {
})
describe('last ()', function () {
-
it('returns null if no item in the queue', function () {
var queue = new Queue()
expect(queue.last()).toEqual(null)
@@ -37,7 +34,6 @@ describe('Queue.js', function () {
})
describe('push ()', function () {
-
it('adds an element to the end of the queue', function () {
var queue = new Queue()
queue.push(1)
diff --git a/spec/spec/animation/Runner.js b/spec/spec/animation/Runner.js
index 2512dac..2325fd5 100644
--- a/spec/spec/animation/Runner.js
+++ b/spec/spec/animation/Runner.js
@@ -1,6 +1,22 @@
/* globals describe, expect, it, beforeEach, afterEach, spyOn, jasmine */
-import { Runner, defaults, Ease, Controller, SVG, Timeline, Rect, Morphable, Animator, Queue, Matrix, Color, Box, Polygon, PointArray } from '../../../src/main.js'
+import {
+ Runner,
+ defaults,
+ Ease,
+ Controller,
+ SVG,
+ Timeline,
+ Rect,
+ Morphable,
+ Animator,
+ Queue,
+ Matrix,
+ Color,
+ Box,
+ Polygon,
+ PointArray
+} from '../../../src/main.js'
import { FakeRunner, RunnerArray } from '../../../src/animation/Runner.js'
import { getWindow } from '../../../src/utils/window.js'
import SVGNumber from '../../../src/types/SVGNumber.js'
@@ -8,7 +24,6 @@ import SVGNumber from '../../../src/types/SVGNumber.js'
const { any, createSpy, objectContaining, arrayContaining } = jasmine
describe('Runner.js', () => {
-
describe('Runner', () => {
var initFn = createSpy('initFn')
var runFn = createSpy('runFn')
@@ -31,59 +46,73 @@ describe('Runner.js', () => {
it('can handle all form of input', () => {
var fn = Runner.sanitise
- expect(fn(200, 200, 'now')).toEqual(objectContaining({
- duration: 200,
- delay: 200,
- when: 'now',
- times: 1,
- wait: 0,
- swing: false
- }))
-
- expect(fn(200, 200)).toEqual(objectContaining({
- duration: 200,
- delay: 200,
- when: 'last',
- times: 1,
- wait: 0,
- swing: false
- }))
-
- expect(fn(200)).toEqual(objectContaining({
- duration: 200,
- delay: defaults.timeline.delay,
- when: 'last',
- times: 1,
- wait: 0,
- swing: false
- }))
-
- expect(fn(runFn)).toEqual(objectContaining({
- duration: runFn,
- delay: defaults.timeline.delay,
- when: 'last',
- times: 1,
- wait: 0,
- swing: false
- }))
-
- expect(fn({ delay: 200 })).toEqual(objectContaining({
- duration: defaults.timeline.duration,
- delay: 200,
- when: 'last',
- times: 1,
- wait: 0,
- swing: false
- }))
-
- expect(fn({ times: 3, delay: 200, when: 'now', swing: true, wait: 200 })).toEqual(objectContaining({
- duration: defaults.timeline.duration,
- delay: 200,
- when: 'now',
- times: 3,
- wait: 200,
- swing: true
- }))
+ expect(fn(200, 200, 'now')).toEqual(
+ objectContaining({
+ duration: 200,
+ delay: 200,
+ when: 'now',
+ times: 1,
+ wait: 0,
+ swing: false
+ })
+ )
+
+ expect(fn(200, 200)).toEqual(
+ objectContaining({
+ duration: 200,
+ delay: 200,
+ when: 'last',
+ times: 1,
+ wait: 0,
+ swing: false
+ })
+ )
+
+ expect(fn(200)).toEqual(
+ objectContaining({
+ duration: 200,
+ delay: defaults.timeline.delay,
+ when: 'last',
+ times: 1,
+ wait: 0,
+ swing: false
+ })
+ )
+
+ expect(fn(runFn)).toEqual(
+ objectContaining({
+ duration: runFn,
+ delay: defaults.timeline.delay,
+ when: 'last',
+ times: 1,
+ wait: 0,
+ swing: false
+ })
+ )
+
+ expect(fn({ delay: 200 })).toEqual(
+ objectContaining({
+ duration: defaults.timeline.duration,
+ delay: 200,
+ when: 'last',
+ times: 1,
+ wait: 0,
+ swing: false
+ })
+ )
+
+ expect(
+ fn({ times: 3, delay: 200, when: 'now', swing: true, wait: 200 })
+ ).toEqual(
+ objectContaining({
+ duration: defaults.timeline.duration,
+ delay: 200,
+ when: 'now',
+ times: 3,
+ wait: 200,
+ swing: true
+ })
+ )
})
})
@@ -115,17 +144,18 @@ describe('Runner.js', () => {
var runner = new Runner()
runner.queue(initFn, runFn, true)
- expect(runner._queue[0]).toEqual(objectContaining({
- initialiser: initFn,
- initialised: false,
- runner: runFn,
- finished: false
- }))
+ expect(runner._queue[0]).toEqual(
+ objectContaining({
+ initialiser: initFn,
+ initialised: false,
+ runner: runFn,
+ finished: false
+ })
+ )
})
})
describe('step()', () => {
-
it('returns itself', () => {
var runner = new Runner()
expect(runner.step()).toBe(runner)
@@ -163,7 +193,7 @@ describe('Runner.js', () => {
expect(runFn.calls.count()).toBe(2)
})
- function getLoop (r) {
+ function getLoop(r) {
var loopDuration = r._duration + r._wait
var loopsDone = Math.floor(r._time / loopDuration)
return loopsDone
@@ -447,7 +477,6 @@ describe('Runner.js', () => {
})
})
})
-
})
describe('active()', () => {
@@ -613,7 +642,6 @@ describe('Runner.js', () => {
})
describe('position()', () => {
-
it('gets the position of a runner', () => {
var spy = createSpy('stepper')
var runner = new Runner(1000).queue(null, spy)
@@ -718,9 +746,10 @@ describe('Runner.js', () => {
it('throws if no timeline is given', () => {
var runner = new Runner()
- expect(() => runner.schedule(200, 'now')).toThrowError('Runner cannot be scheduled without timeline')
+ expect(() => runner.schedule(200, 'now')).toThrowError(
+ 'Runner cannot be scheduled without timeline'
+ )
})
-
})
describe('unschedule()', () => {
@@ -750,10 +779,22 @@ describe('Runner.js', () => {
expect(runner2.timeline()).toBe(timeline)
expect(runner2.time()).toBe(0)
- expect(timeline.schedule()).toEqual(arrayContaining([
- objectContaining({ start: t, duration: 1000, end: t + 1000, runner: runner }),
- objectContaining({ start: t + 2000, duration: 500, end: t + 2500, runner: runner2 })
- ]))
+ expect(timeline.schedule()).toEqual(
+ arrayContaining([
+ objectContaining({
+ start: t,
+ duration: 1000,
+ end: t + 1000,
+ runner: runner
+ }),
+ objectContaining({
+ start: t + 2000,
+ duration: 500,
+ end: t + 2500,
+ runner: runner2
+ })
+ ])
+ )
})
it('reuses timeline and element of current runner', () => {
@@ -909,7 +950,7 @@ describe('Runner.js', () => {
const runner = rect.animate().move(10, 10)
jasmine.RequestAnimationFrame.tick(16)
expect(runner._tryRetarget('x', 20)).toBe(true)
- expect(runner._history.x.morpher.to()).toEqual([ 20, '' ])
+ expect(runner._history.x.morpher.to()).toEqual([20, ''])
})
it('throws away the morpher if it was not initialized yet and returns false', () => {
@@ -929,10 +970,14 @@ describe('Runner.js', () => {
it('does only work with controller for transformations and uses retarget function when retargeting transformations', () => {
const rect = new Rect()
- const runner = rect.animate(new Controller(() => 0)).transform({ translate: [ 10, 10 ] })
+ const runner = rect
+ .animate(new Controller(() => 0))
+ .transform({ translate: [10, 10] })
jasmine.RequestAnimationFrame.tick(16)
// In that case tryRetarget is not successful
- expect(runner._tryRetarget('transform', { translate: [ 20, 20 ] })).toBe(true)
+ expect(
+ runner._tryRetarget('transform', { translate: [20, 20] })
+ ).toBe(true)
})
it('starts the timeline if retarget was successful', () => {
@@ -942,7 +987,7 @@ describe('Runner.js', () => {
jasmine.RequestAnimationFrame.tick(16)
const spy = spyOn(timeline, 'play')
expect(runner._tryRetarget('x', 20)).toBe(true)
- expect(runner._history.x.morpher.to()).toEqual([ 20, '' ])
+ expect(runner._history.x.morpher.to()).toEqual([20, ''])
expect(spy).toHaveBeenCalledTimes(1)
})
})
@@ -1002,7 +1047,7 @@ describe('Runner.js', () => {
describe('addTransform()', () => {
it('adds a transformation by multiplying', () => {
const runner = new Runner()
- runner.addTransform({ translate: [ 10, 10 ] })
+ runner.addTransform({ translate: [10, 10] })
expect(runner.transforms).toEqual(new Matrix(1, 0, 0, 1, 10, 10))
})
})
@@ -1010,7 +1055,7 @@ describe('Runner.js', () => {
describe('clearTransform()', () => {
it('resets the transformations to identity', () => {
const runner = new Runner()
- runner.addTransform({ translate: [ 10, 10 ] })
+ runner.addTransform({ translate: [10, 10] })
runner.clearTransform()
expect(runner.transforms).toEqual(new Matrix())
})
@@ -1019,7 +1064,7 @@ describe('Runner.js', () => {
describe('clearTransformsFromQueue', () => {
it('deletes all functions from the queue which are transformations', () => {
const runner = new Runner().queue(initFn, runFn)
- runner.transform({ translate: [ 10, 20 ] })
+ runner.transform({ translate: [10, 20] })
runner.clearTransformsFromQueue()
expect(runner._queue.length).toBe(1)
})
@@ -1062,17 +1107,15 @@ describe('Runner.js', () => {
it('calculates the current transformation of this element', () => {
const rect = new Rect()
rect._prepareRunner()
- const runner1 = new Runner().addTransform({ translate: [ 10, 20 ] })
+ const runner1 = new Runner().addTransform({ translate: [10, 20] })
const runner2 = new Runner().addTransform({ rotate: 45 })
- const runner3 = new Runner().addTransform({ translate: [ 10, 20 ] })
+ const runner3 = new Runner().addTransform({ translate: [10, 20] })
rect._addRunner(runner1)
rect._addRunner(runner2)
rect._addRunner(runner3)
expect(rect._currentTransform(runner3)).toEqual(
- new Matrix({ translate: [ 10, 20 ] })
- .rotate(45)
- .translate(10, 20)
+ new Matrix({ translate: [10, 20] }).rotate(45).translate(10, 20)
)
})
})
@@ -1132,14 +1175,26 @@ describe('Runner.js', () => {
const runner = new Runner()
runner.styleAttr('attr', 'x', 5)
expect(runner._history.attr.morpher).toEqual(any(Morphable))
- expect(runner._history.attr.morpher.to()).toEqual([ 'x', SVGNumber, 2, 5, '' ])
+ expect(runner._history.attr.morpher.to()).toEqual([
+ 'x',
+ SVGNumber,
+ 2,
+ 5,
+ ''
+ ])
})
it('adds a morpher for css', () => {
const runner = new Runner()
runner.styleAttr('css', 'x', 5)
expect(runner._history.css.morpher).toEqual(any(Morphable))
- expect(runner._history.css.morpher.to()).toEqual([ 'x', SVGNumber, 2, 5, '' ])
+ expect(runner._history.css.morpher.to()).toEqual([
+ 'x',
+ SVGNumber,
+ 2,
+ 5,
+ ''
+ ])
})
it('adds init and run fn for execution when runner runs', () => {
@@ -1147,8 +1202,20 @@ describe('Runner.js', () => {
const runner = new Runner(100).ease('-').element(element)
runner.styleAttr('attr', 'x', 5)
runner.step(50)
- expect(runner._history.attr.morpher.from()).toEqual([ 'x', SVGNumber, 2, 0, '' ])
- expect(runner._history.attr.morpher.to()).toEqual([ 'x', SVGNumber, 2, 5, '' ])
+ expect(runner._history.attr.morpher.from()).toEqual([
+ 'x',
+ SVGNumber,
+ 2,
+ 0,
+ ''
+ ])
+ expect(runner._history.attr.morpher.to()).toEqual([
+ 'x',
+ SVGNumber,
+ 2,
+ 5,
+ ''
+ ])
expect(element.x()).toBe(2.5)
})
@@ -1157,18 +1224,54 @@ describe('Runner.js', () => {
const runner = new Runner(100).ease('-').element(element)
runner.styleAttr('attr', { fill: '#000', stroke: new Color('#fff') })
runner.step(50)
- expect(runner._history.attr.morpher.from()).toEqual(
- [ 'fill', Color, 5, 255, 255, 255, 0, 'rgb', 'stroke', Color, 5, 0, 0, 0, 0, 'rgb' ]
- )
-
- expect(runner._history.attr.morpher.to()).toEqual(
- [ 'fill', Color, 5, 0, 0, 0, 0, 'rgb', 'stroke', Color, 5, 255, 255, 255, 0, 'rgb' ]
- )
+ expect(runner._history.attr.morpher.from()).toEqual([
+ 'fill',
+ Color,
+ 5,
+ 255,
+ 255,
+ 255,
+ 0,
+ 'rgb',
+ 'stroke',
+ Color,
+ 5,
+ 0,
+ 0,
+ 0,
+ 0,
+ 'rgb'
+ ])
+
+ expect(runner._history.attr.morpher.to()).toEqual([
+ 'fill',
+ Color,
+ 5,
+ 0,
+ 0,
+ 0,
+ 0,
+ 'rgb',
+ 'stroke',
+ Color,
+ 5,
+ 255,
+ 255,
+ 255,
+ 0,
+ 'rgb'
+ ])
const result = runner._history.attr.morpher.at(0.5).valueOf()
expect(result.fill).toEqual(any(Color))
expect(result.stroke).toEqual(any(Color))
- expect(result.fill.toArray()).toEqual([ 127.5, 127.5, 127.5, 0, 'rgb' ])
- expect(result.stroke.toArray()).toEqual([ 127.5, 127.5, 127.5, 0, 'rgb' ])
+ expect(result.fill.toArray()).toEqual([127.5, 127.5, 127.5, 0, 'rgb'])
+ expect(result.stroke.toArray()).toEqual([
+ 127.5,
+ 127.5,
+ 127.5,
+ 0,
+ 'rgb'
+ ])
})
it('it changes color space', () => {
@@ -1176,16 +1279,30 @@ describe('Runner.js', () => {
const runner = new Runner(100).ease('-').element(element)
runner.styleAttr('attr', { fill: new Color(100, 12, 12, 'hsl') })
runner.step(50)
- expect(runner._history.attr.morpher.from()).toEqual(
- [ 'fill', Color, 5, 0, 0, 100, 0, 'hsl' ]
- )
-
- expect(runner._history.attr.morpher.to()).toEqual(
- [ 'fill', Color, 5, 100, 12, 12, 0, 'hsl' ]
- )
+ expect(runner._history.attr.morpher.from()).toEqual([
+ 'fill',
+ Color,
+ 5,
+ 0,
+ 0,
+ 100,
+ 0,
+ 'hsl'
+ ])
+
+ expect(runner._history.attr.morpher.to()).toEqual([
+ 'fill',
+ Color,
+ 5,
+ 100,
+ 12,
+ 12,
+ 0,
+ 'hsl'
+ ])
const result = runner._history.attr.morpher.at(0.5).valueOf()
expect(result.fill).toEqual(any(Color))
- expect(result.fill.toArray()).toEqual([ 50, 6, 56, 0, 'hsl' ])
+ expect(result.fill.toArray()).toEqual([50, 6, 56, 0, 'hsl'])
expect(element.fill()).toBe('#969388')
})
@@ -1195,7 +1312,10 @@ describe('Runner.js', () => {
runner.styleAttr('attr', { fill: new Color(100, 12, 12, 'hsl') })
runner.step(50)
expect(element.fill()).toBe('#969388')
- runner.styleAttr('attr', { fill: new Color(100, 50, 50, 'hsl'), x: 50 })
+ runner.styleAttr('attr', {
+ fill: new Color(100, 50, 50, 'hsl'),
+ x: 50
+ })
runner.step(25)
expect(element.fill()).toBe('#b1c37c')
expect(element.x()).toBe(37.5)
@@ -1213,14 +1333,17 @@ describe('Runner.js', () => {
})
})
- function closeTo (number, precision = 2) {
+ function closeTo(number, precision = 2) {
return {
/*
* The asymmetricMatch function is required, and must return a boolean.
*/
asymmetricMatch: function (compareTo) {
const factor = 10 ** precision
- return Math.round((~~(compareTo * factor)) / factor) === Math.round((~~(number * factor)) / factor)
+ return (
+ Math.round(~~(compareTo * factor) / factor) ===
+ Math.round(~~(number * factor) / factor)
+ )
},
/*
@@ -1228,12 +1351,14 @@ describe('Runner.js', () => {
* be seen by the user in the message when a test fails.
*/
jasmineToString: function () {
- return '<close to: ' + number + ' with precision: ' + precision + '>'
+ return (
+ '<close to: ' + number + ' with precision: ' + precision + '>'
+ )
}
}
}
- function equal (obj) {
+ function equal(obj) {
return {
/*
* The asymmetricMatch function is required, and must return a boolean.
@@ -1242,7 +1367,9 @@ describe('Runner.js', () => {
if (!(compareTo instanceof obj.constructor)) return false
const keys = Object.keys(obj)
- const difference = Object.keys(compareTo).filter((el) => !keys.includes(el))
+ const difference = Object.keys(compareTo).filter(
+ (el) => !keys.includes(el)
+ )
if (difference.length) return false
@@ -1269,15 +1396,16 @@ describe('Runner.js', () => {
const runner = new Runner(100).ease('-').element(element)
runner.zoom(2, { x: 0, y: 0 })
runner.step(50)
- expect(runner._history.zoom.morpher.from()).toEqual(
- [ 1, '' ]
- )
- expect(runner._history.zoom.morpher.to()).toEqual(
- [ 2, '' ]
- )
+ expect(runner._history.zoom.morpher.from()).toEqual([1, ''])
+ expect(runner._history.zoom.morpher.to()).toEqual([2, ''])
expect(element.zoom()).toBeCloseTo(1.5, 10)
- expect(element.viewbox().toArray()).toEqual([ 0, 0, closeTo(66.666, 3), closeTo(66.666, 3) ])
+ expect(element.viewbox().toArray()).toEqual([
+ 0,
+ 0,
+ closeTo(66.666, 3),
+ closeTo(66.666, 3)
+ ])
})
it('retargets if called twice', () => {
@@ -1286,16 +1414,17 @@ describe('Runner.js', () => {
runner.zoom(2, { x: 0, y: 0 })
runner.step(50)
runner.zoom(4, { x: 0, y: 0 })
- expect(runner._history.zoom.morpher.from()).toEqual(
- [ 1, '' ]
- )
- expect(runner._history.zoom.morpher.to()).toEqual(
- [ 4, '' ]
- )
+ expect(runner._history.zoom.morpher.from()).toEqual([1, ''])
+ expect(runner._history.zoom.morpher.to()).toEqual([4, ''])
runner.step(25)
expect(element.zoom()).toBeCloseTo(3.25, 10)
- expect(element.viewbox().toArray()).toEqual([ 0, 0, closeTo(30.769, 3), closeTo(30.769, 3) ])
+ expect(element.viewbox().toArray()).toEqual([
+ 0,
+ 0,
+ closeTo(30.769, 3),
+ closeTo(30.769, 3)
+ ])
})
})
@@ -1303,52 +1432,59 @@ describe('Runner.js', () => {
it('does not retarget for non-declarative transformations', () => {
const runner = new Runner()
const spy = spyOn(runner, '_tryRetarget')
- runner.transform({ translate: [ 10, 20 ] })
+ runner.transform({ translate: [10, 20] })
expect(spy).not.toHaveBeenCalled()
})
it('does not retarget for relative transformations', () => {
const runner = new Runner(new Controller(() => 0))
const spy = spyOn(runner, '_tryRetarget')
- runner.transform({ translate: [ 10, 20 ] }, true)
+ runner.transform({ translate: [10, 20] }, true)
expect(spy).not.toHaveBeenCalled()
})
it('does retarget for absolute declarative transformations', () => {
const runner = new Runner(new Controller(() => 0))
const spy = spyOn(runner, '_tryRetarget')
- runner.transform({ translate: [ 10, 20 ] })
+ runner.transform({ translate: [10, 20] })
expect(spy).toHaveBeenCalled()
})
it('calls queue with isTransform=true', () => {
const runner = new Runner()
const spy = spyOn(runner, 'queue')
- runner.transform({ translate: [ 10, 20 ] })
- expect(spy).toHaveBeenCalledWith(any(Function), any(Function), any(Function), true)
+ runner.transform({ translate: [10, 20] })
+ expect(spy).toHaveBeenCalledWith(
+ any(Function),
+ any(Function),
+ any(Function),
+ true
+ )
})
it('steps an affine transformation correctly', () => {
const element = new Rect()
const runner = new Runner(100).ease('-').element(element)
- runner.transform({ translate: [ 10, 20 ], scale: 2, rotate: 90 })
+ runner.transform({ translate: [10, 20], scale: 2, rotate: 90 })
runner.step(50)
// transform sets an immediate callback to apply all merged transforms
// when every runner had the chance to add its bit of transforms
jasmine.RequestAnimationFrame.tick(1)
- expect(element.matrix().decompose()).toEqual(objectContaining({
- translateX: 5,
- translateY: 10,
- scaleX: closeTo(1.5, 10),
- scaleY: closeTo(1.5),
- rotate: closeTo(45, 10)
- }))
+ expect(element.matrix().decompose()).toEqual(
+ objectContaining({
+ translateX: 5,
+ translateY: 10,
+ scaleX: closeTo(1.5, 10),
+ scaleY: closeTo(1.5),
+ rotate: closeTo(45, 10)
+ })
+ )
})
it('retargets an affine transformation correctly', () => {
const element = new Rect()
const runner = new Runner(() => 1).element(element)
- runner.transform({ translate: [ 10, 20 ], scale: 2, rotate: 90 })
+ runner.transform({ translate: [10, 20], scale: 2, rotate: 90 })
runner.step(50)
runner.transform({ scale: 2 })
@@ -1357,26 +1493,26 @@ describe('Runner.js', () => {
// on every frame. That is why we step here to see the effect of our retargeting
runner.step(25)
- expect(runner._history.transform.morpher.to()).toEqual(
- [ 2, 2, 0, 0, 0, 0, 0, 0 ]
- )
+ expect(runner._history.transform.morpher.to()).toEqual([
+ 2, 2, 0, 0, 0, 0, 0, 0
+ ])
})
it('retargets an affine transformation correctly and sets new origin', () => {
const element = new Rect()
const runner = new Runner(() => 1).element(element)
- runner.transform({ translate: [ 10, 20 ], scale: 2, rotate: 90 })
+ runner.transform({ translate: [10, 20], scale: 2, rotate: 90 })
runner.step(50)
- runner.transform({ scale: 2, origin: [ 10, 10 ] })
+ runner.transform({ scale: 2, origin: [10, 10] })
// transform sets its to-target to the morpher in the initialisation step
// because it depends on the from-target. Declaritive animation run the init-step
// on every frame. That is why we step here to see the effect of our retargeting
runner.step(25)
- expect(runner._history.transform.morpher.to()).toEqual(
- [ 2, 2, 0, 0, 0, 0, 10, 10 ]
- )
+ expect(runner._history.transform.morpher.to()).toEqual([
+ 2, 2, 0, 0, 0, 0, 10, 10
+ ])
})
it('steps multiple relative animations correctly', () => {
@@ -1433,9 +1569,7 @@ describe('Runner.js', () => {
expect(runner1._queue.length).toBe(0)
// The origin is transformed with every
- expect(element.matrix()).toEqual(
- new Matrix().scale(1.5).rotate(22.5)
- )
+ expect(element.matrix()).toEqual(new Matrix().scale(1.5).rotate(22.5))
})
it('correctly animates matrices directly', () => {
@@ -1456,16 +1590,16 @@ describe('Runner.js', () => {
it('correctly animates matrices affine', () => {
const element = new Rect()
const runner = new Runner(100).ease('-').element(element)
- runner.transform(Object.assign({ affine: true }, new Matrix({ rotate: 90 })))
+ runner.transform(
+ Object.assign({ affine: true }, new Matrix({ rotate: 90 }))
+ )
runner.step(50)
// transform sets an immediate callback to apply all merged transforms
// when every runner had the chance to add its bit of transforms
jasmine.RequestAnimationFrame.tick(1)
// The origin is transformed with every
- expect(element.matrix()).toEqual(
- new Matrix({ rotate: 45 })
- )
+ expect(element.matrix()).toEqual(new Matrix({ rotate: 45 }))
})
it('correctly animates matrices affine by passing third parameter', () => {
@@ -1478,9 +1612,7 @@ describe('Runner.js', () => {
jasmine.RequestAnimationFrame.tick(1)
// The origin is transformed with every
- expect(element.matrix()).toEqual(
- new Matrix({ rotate: 45 })
- )
+ expect(element.matrix()).toEqual(new Matrix({ rotate: 45 }))
})
it('correctly animates a declarative relative rotation', () => {
@@ -1563,8 +1695,8 @@ describe('Runner.js', () => {
runner._queueNumberDelta('x', 10)
runner.step(50)
expect(runner._history.x.morpher.type()).toEqual(SVGNumber)
- expect(runner._history.x.morpher.from()).toEqual([ 10, '' ])
- expect(runner._history.x.morpher.to()).toEqual([ 20, '' ])
+ expect(runner._history.x.morpher.from()).toEqual([10, ''])
+ expect(runner._history.x.morpher.to()).toEqual([20, ''])
expect(element.x()).toBe(15)
})
@@ -1576,7 +1708,7 @@ describe('Runner.js', () => {
runner.step(25)
runner._queueNumberDelta('x', 20)
- expect(runner._history.x.morpher.to()).toEqual([ 30, '' ])
+ expect(runner._history.x.morpher.to()).toEqual([30, ''])
runner.step(25)
expect(element.x()).toBe(20)
@@ -1590,8 +1722,8 @@ describe('Runner.js', () => {
runner._queueObject('x', new SVGNumber(20))
runner.step(50)
expect(runner._history.x.morpher.type()).toEqual(SVGNumber)
- expect(runner._history.x.morpher.from()).toEqual([ 10, '' ])
- expect(runner._history.x.morpher.to()).toEqual([ 20, '' ])
+ expect(runner._history.x.morpher.from()).toEqual([10, ''])
+ expect(runner._history.x.morpher.to()).toEqual([20, ''])
expect(element.x()).toBe(15)
})
@@ -1719,25 +1851,25 @@ describe('Runner.js', () => {
describe('plot()', () => {
it('queues a morphable array', () => {
- const element = new Polygon().plot([ 10, 10, 20, 20 ])
+ const element = new Polygon().plot([10, 10, 20, 20])
const runner = new Runner(100).ease('-').element(element)
runner.plot(20, 20, 30, 30)
runner.step(50)
- expect(runner._history.plot.morpher.from()).toEqual([ 10, 10, 20, 20 ])
- expect(runner._history.plot.morpher.to()).toEqual([ 20, 20, 30, 30 ])
- expect(element.array()).toEqual(new PointArray([ 15, 15, 25, 25 ]))
+ expect(runner._history.plot.morpher.from()).toEqual([10, 10, 20, 20])
+ expect(runner._history.plot.morpher.to()).toEqual([20, 20, 30, 30])
+ expect(element.array()).toEqual(new PointArray([15, 15, 25, 25]))
})
it('retargets correctly', () => {
- const element = new Polygon().plot([ 10, 10, 20, 20 ])
+ const element = new Polygon().plot([10, 10, 20, 20])
const runner = new Runner(100).ease('-').element(element)
runner.plot(20, 20, 30, 30)
runner.step(25)
runner.plot(30, 30, 40, 40)
runner.step(25)
- expect(runner._history.plot.morpher.from()).toEqual([ 10, 10, 20, 20 ])
- expect(runner._history.plot.morpher.to()).toEqual([ 30, 30, 40, 40 ])
- expect(element.array()).toEqual(new PointArray([ 20, 20, 30, 30 ]))
+ expect(runner._history.plot.morpher.from()).toEqual([10, 10, 20, 20])
+ expect(runner._history.plot.morpher.to()).toEqual([30, 30, 40, 40])
+ expect(element.array()).toEqual(new PointArray([20, 20, 30, 30]))
})
})
@@ -1755,7 +1887,10 @@ describe('Runner.js', () => {
const runner = new Runner()
const spy = spyOn(runner, '_queueObject')
runner.viewbox(10, 10, 100, 100)
- expect(spy).toHaveBeenCalledWith('viewbox', equal(new Box(10, 10, 100, 100)))
+ expect(spy).toHaveBeenCalledWith(
+ 'viewbox',
+ equal(new Box(10, 10, 100, 100))
+ )
})
})
@@ -1785,10 +1920,12 @@ describe('Runner.js', () => {
describe('mergeWith()', () => {
it('merges the transformations of a runner with another and returns a FakeRunner', () => {
const fake = new FakeRunner()
- const runner = new Runner().addTransform({ translate: [ 10, 20 ] })
+ const runner = new Runner().addTransform({ translate: [10, 20] })
const newRunner = fake.mergeWith(runner)
expect(newRunner).toEqual(any(FakeRunner))
- expect(newRunner.transforms).toEqual(new Matrix({ translate: [ 10, 20 ] }))
+ expect(newRunner.transforms).toEqual(
+ new Matrix({ translate: [10, 20] })
+ )
})
})
})
@@ -1832,9 +1969,9 @@ describe('Runner.js', () => {
describe('merge()', () => {
it('merges all runners which are done', () => {
- const runner1 = new Runner().addTransform({ translate: [ 10, 20 ] })
+ const runner1 = new Runner().addTransform({ translate: [10, 20] })
const runner2 = new Runner().addTransform({ rotate: 45 })
- const runner3 = new Runner().addTransform({ translate: [ 10, 20 ] })
+ const runner3 = new Runner().addTransform({ translate: [10, 20] })
const arr = new RunnerArray()
arr.add(runner1).add(runner2).add(runner3)
runner1.done = true
@@ -1843,17 +1980,15 @@ describe('Runner.js', () => {
arr.merge()
expect(arr.runners[0]).toEqual(any(FakeRunner))
expect(arr.runners[0].transforms).toEqual(
- new Matrix({ translate: [ 10, 20 ] })
- .rotate(45)
- .translate(10, 20)
+ new Matrix({ translate: [10, 20] }).rotate(45).translate(10, 20)
)
})
it('skips runners which are not done', () => {
- const runner1 = new Runner().addTransform({ translate: [ 10, 20 ] })
+ const runner1 = new Runner().addTransform({ translate: [10, 20] })
const runner2 = new Runner().addTransform({ rotate: 45 })
const runner3 = new Runner().addTransform({ rotate: 45 })
- const runner4 = new Runner().addTransform({ translate: [ 10, 20 ] })
+ const runner4 = new Runner().addTransform({ translate: [10, 20] })
const runner5 = new Runner().addTransform({ rotate: 45 })
const arr = new RunnerArray()
arr.add(runner1).add(runner2).add(runner3).add(runner4).add(runner5)
@@ -1865,24 +2000,22 @@ describe('Runner.js', () => {
arr.merge()
expect(arr.runners[0]).toEqual(any(FakeRunner))
expect(arr.runners[0].transforms).toEqual(
- new Matrix({ translate: [ 10, 20 ] })
- .rotate(45)
+ new Matrix({ translate: [10, 20] }).rotate(45)
)
expect(arr.runners[2]).toEqual(any(FakeRunner))
expect(arr.runners[2].transforms).toEqual(
- new Matrix({ translate: [ 10, 20 ] })
- .rotate(45)
+ new Matrix({ translate: [10, 20] }).rotate(45)
)
expect(arr.runners[1]).toBe(runner3)
})
it('skips runners which have a timeline and are scheduled on that timeline', () => {
- const runner1 = new Runner().addTransform({ translate: [ 10, 20 ] })
+ const runner1 = new Runner().addTransform({ translate: [10, 20] })
const runner2 = new Runner().addTransform({ rotate: 45 })
const runner3 = new Runner().addTransform({ rotate: 45 })
- const runner4 = new Runner().addTransform({ translate: [ 10, 20 ] })
+ const runner4 = new Runner().addTransform({ translate: [10, 20] })
const runner5 = new Runner().addTransform({ rotate: 45 })
const arr = new RunnerArray()
arr.add(runner1).add(runner2).add(runner3).add(runner4).add(runner5)
@@ -1896,14 +2029,12 @@ describe('Runner.js', () => {
arr.merge()
expect(arr.runners[0]).toEqual(any(FakeRunner))
expect(arr.runners[0].transforms).toEqual(
- new Matrix({ translate: [ 10, 20 ] })
- .rotate(45)
+ new Matrix({ translate: [10, 20] }).rotate(45)
)
expect(arr.runners[2]).toEqual(any(FakeRunner))
expect(arr.runners[2].transforms).toEqual(
- new Matrix({ translate: [ 10, 20 ] })
- .rotate(45)
+ new Matrix({ translate: [10, 20] }).rotate(45)
)
expect(arr.runners[1]).toBe(runner3)
@@ -1940,7 +2071,12 @@ describe('Runner.js', () => {
arr.add(runner1).add(runner2).add(runner3).add(runner4).add(runner5)
arr.clearBefore(runner3.id)
expect(arr.length()).toBe(4)
- expect(arr.runners).toEqual([ any(FakeRunner), runner3, runner4, runner5 ])
+ expect(arr.runners).toEqual([
+ any(FakeRunner),
+ runner3,
+ runner4,
+ runner5
+ ])
})
})
})
diff --git a/spec/spec/animation/Timeline.js b/spec/spec/animation/Timeline.js
index 5f511ff..cbb40f8 100644
--- a/spec/spec/animation/Timeline.js
+++ b/spec/spec/animation/Timeline.js
@@ -1,6 +1,13 @@
/* globals describe, expect, it, beforeEach, afterEach, spyOn, container, jasmine */
-import { Timeline, SVG, Runner, Animator, Queue, Rect } from '../../../src/main.js'
+import {
+ Timeline,
+ SVG,
+ Runner,
+ Animator,
+ Queue,
+ Rect
+} from '../../../src/main.js'
import { getWindow } from '../../../src/utils/window.js'
const { createSpy, any } = jasmine
@@ -127,7 +134,9 @@ describe('Timeline.js', () => {
it('throws if when is not supported', () => {
const timeline = new Timeline().schedule(new Runner(1000), 1000)
const runner = new Runner(1000)
- expect(() => timeline.schedule(runner, 0, 'not supported')).toThrowError('Invalid value for the "when" parameter')
+ expect(() => timeline.schedule(runner, 0, 'not supported')).toThrowError(
+ 'Invalid value for the "when" parameter'
+ )
})
it('uses persist value of the runner of present', () => {
@@ -152,7 +161,9 @@ describe('Timeline.js', () => {
it('gets a runner by its id from the timeline', () => {
const timeline = new Timeline()
const runner = new Runner(1000)
- expect(timeline.schedule(runner).getRunnerInfoById(runner.id).runner).toBe(runner)
+ expect(
+ timeline.schedule(runner).getRunnerInfoById(runner.id).runner
+ ).toBe(runner)
})
it('returns null of runner not found', () => {
@@ -460,7 +471,10 @@ describe('Timeline.js', () => {
it('continues if there are still runners left from us when going back in time', () => {
const spy = createSpy()
- const timeline = new Timeline().on('finished', spy).time(1200).reverse(true)
+ const timeline = new Timeline()
+ .on('finished', spy)
+ .time(1200)
+ .reverse(true)
const runner = new Runner(1000)
spy.calls.reset()
timeline.schedule(runner, 0).play() // we have to play because its synchronous here
diff --git a/spec/spec/elements/A.js b/spec/spec/elements/A.js
index 854204e..5fcbe87 100644
--- a/spec/spec/elements/A.js
+++ b/spec/spec/elements/A.js
@@ -6,7 +6,6 @@ const { any } = jasmine
const url = 'https://svgjs.dev'
describe('A.js', () => {
-
describe('()', () => {
it('creates a new object of type A', () => {
expect(new A()).toEqual(any(A))
@@ -81,7 +80,7 @@ describe('A.js', () => {
expect(link.parent()).toBe(null)
})
- it('removes also the link when link wasn\'t in document', () => {
+ it("removes also the link when link wasn't in document", () => {
const link = new A().to(url)
const rect = link.rect(100, 100)
@@ -116,5 +115,4 @@ describe('A.js', () => {
})
})
})
-
})
diff --git a/spec/spec/elements/ClipPath.js b/spec/spec/elements/ClipPath.js
index 1effe6d..5061a10 100644
--- a/spec/spec/elements/ClipPath.js
+++ b/spec/spec/elements/ClipPath.js
@@ -37,7 +37,7 @@ describe('ClipPath.js', () => {
const canvas = SVG().addTo(container)
const clip = canvas.clip()
const rect = canvas.rect(100, 100).clipWith(clip)
- expect(clip.targets()).toEqual([ rect ])
+ expect(clip.targets()).toEqual([rect])
})
})
@@ -47,7 +47,7 @@ describe('ClipPath.js', () => {
const canvas = SVG()
const clip = canvas.clip()
expect(clip).toEqual(any(ClipPath))
- expect(canvas.defs().children()).toEqual([ clip ])
+ expect(canvas.defs().children()).toEqual([clip])
})
})
})
diff --git a/spec/spec/elements/Container.js b/spec/spec/elements/Container.js
index 5d53eb1..f9741ed 100644
--- a/spec/spec/elements/Container.js
+++ b/spec/spec/elements/Container.js
@@ -61,7 +61,16 @@ describe('Container.js', () => {
it('flattens the whole document when called on the root', () => {
canvas.flatten()
- expect(canvas.children()).toEqual([ rect1, rect2, circle1, circle2, line1, line2, circle3, rect3 ])
+ expect(canvas.children()).toEqual([
+ rect1,
+ rect2,
+ circle1,
+ circle2,
+ line1,
+ line2,
+ circle3,
+ rect3
+ ])
})
it('flattens a group and places all children into its parent when called on a group - 1', () => {
@@ -81,8 +90,15 @@ describe('Container.js', () => {
rect3
*/
- expect(canvas.children()).toEqual([ rect1, group1, group4 ])
- expect(group1.children()).toEqual([ rect2, circle1, circle2, line1, line2, circle3 ])
+ expect(canvas.children()).toEqual([rect1, group1, group4])
+ expect(group1.children()).toEqual([
+ rect2,
+ circle1,
+ circle2,
+ line1,
+ line2,
+ circle3
+ ])
})
it('flattens a group and places all children into its parent when called on a group - 2', () => {
@@ -103,7 +119,7 @@ describe('Container.js', () => {
rect3
*/
- expect(group2.children()).toEqual([ circle2, line1, line2, circle3 ])
+ expect(group2.children()).toEqual([circle2, line1, line2, circle3])
})
})
@@ -111,21 +127,27 @@ describe('Container.js', () => {
it('ungroups a group and inserts all children in the correct order in the parent parent of the group', () => {
group1.ungroup()
- expect(canvas.children()).toEqual([ rect1, rect2, circle1, group2, group4 ])
+ expect(canvas.children()).toEqual([rect1, rect2, circle1, group2, group4])
group4.ungroup()
- expect(canvas.children()).toEqual([ rect1, rect2, circle1, group2, rect3 ])
+ expect(canvas.children()).toEqual([rect1, rect2, circle1, group2, rect3])
})
it('ungroups a group into another group and appends the elements to the other group', () => {
group1.ungroup(group4)
- expect(group4.children()).toEqual([ rect3, rect2, circle1, group2 ])
+ expect(group4.children()).toEqual([rect3, rect2, circle1, group2])
})
it('ungroups a group into another group at the specified position', () => {
group2.ungroup(group1, 1)
- expect(group1.children()).toEqual([ rect2, circle2, group3, circle3, circle1 ])
+ expect(group1.children()).toEqual([
+ rect2,
+ circle2,
+ group3,
+ circle3,
+ circle1
+ ])
})
})
})
diff --git a/spec/spec/elements/Dom.js b/spec/spec/elements/Dom.js
index e33883d..3325d93 100644
--- a/spec/spec/elements/Dom.js
+++ b/spec/spec/elements/Dom.js
@@ -1,12 +1,22 @@
/* globals describe, expect, it, beforeEach, spyOn, jasmine, container */
-import { SVG, G, Rect, Svg, Dom, List, Fragment, Circle, Tspan, create } from '../../../src/main.js'
+import {
+ SVG,
+ G,
+ Rect,
+ Svg,
+ Dom,
+ List,
+ Fragment,
+ Circle,
+ Tspan,
+ create
+} from '../../../src/main.js'
import { getWindow } from '../../../src/utils/window.js'
import { svg, html } from '../../../src/modules/core/namespaces.js'
const { any, createSpy, objectContaining } = jasmine
describe('Dom.js', function () {
-
describe('()', () => {
it('creates a new object of type Dom', () => {
const rect = new Rect()
@@ -119,7 +129,7 @@ describe('Dom.js', function () {
const rect = g.rect(100, 100)
const circle = g.circle(100, 100)
const children = g.children()
- expect(children).toEqual([ rect, circle ])
+ expect(children).toEqual([rect, circle])
expect(children).toEqual(any(List))
})
})
@@ -197,8 +207,8 @@ describe('Dom.js', function () {
group.each(spy)
expect(spy.calls.all()).toEqual([
- objectContaining({ object: group2, args: [ 0, [ group2, circle ] ] }),
- objectContaining({ object: circle, args: [ 1, [ group2, circle ] ] })
+ objectContaining({ object: group2, args: [0, [group2, circle]] }),
+ objectContaining({ object: circle, args: [1, [group2, circle]] })
])
})
@@ -211,9 +221,9 @@ describe('Dom.js', function () {
group.each(spy, true)
expect(spy.calls.all()).toEqual([
- objectContaining({ object: group2, args: [ 0, [ group2, circle ] ] }),
- objectContaining({ object: rect, args: [ 0, [ rect ] ] }),
- objectContaining({ object: circle, args: [ 1, [ group2, circle ] ] })
+ objectContaining({ object: group2, args: [0, [group2, circle]] }),
+ objectContaining({ object: rect, args: [0, [rect]] }),
+ objectContaining({ object: circle, args: [1, [group2, circle]] })
])
})
})
@@ -277,7 +287,7 @@ describe('Dom.js', function () {
expect(g.has(rect)).toBe(true)
})
- it('returns false if the element hasn\'t the passed element as child', () => {
+ it("returns false if the element hasn't the passed element as child", () => {
const g = new G()
const rect = new Rect()
expect(g.has(rect)).toBe(false)
@@ -437,7 +447,7 @@ describe('Dom.js', function () {
const rect = new Rect()
const ret = rect.putIn(g)
expect(ret).toEqual(any(G))
- expect(ret.children()).toEqual([ rect ])
+ expect(ret.children()).toEqual([rect])
})
it('works with a query selector', () => {
@@ -446,7 +456,7 @@ describe('Dom.js', function () {
const rect = canvas.rect(100, 100)
const ret = rect.putIn('.test')
expect(ret).toBe(g)
- expect(g.children()).toEqual([ rect ])
+ expect(g.children()).toEqual([rect])
})
})
@@ -460,7 +470,7 @@ describe('Dom.js', function () {
it('removes the element from the parent', () => {
const canvas = SVG().addTo(container)
const rect = canvas.rect(100, 100)
- expect(canvas.children()).toEqual([ rect ])
+ expect(canvas.children()).toEqual([rect])
rect.remove()
expect(canvas.children()).toEqual([])
})
@@ -473,7 +483,7 @@ describe('Dom.js', function () {
it('also works when direct child of document-fragment', () => {
const fragment = new Fragment()
const rect = fragment.rect(100, 100)
- expect(fragment.children()).toEqual([ rect ])
+ expect(fragment.children()).toEqual([rect])
expect(rect.remove()).toBe(rect)
expect(fragment.children()).toEqual([])
})
@@ -518,7 +528,7 @@ describe('Dom.js', function () {
const rect3 = g.rect(100, 100)
const circle = new Circle()
rect2.replace(circle)
- expect(g.children()).toEqual([ rect1, circle, rect3 ])
+ expect(g.children()).toEqual([rect1, circle, rect3])
})
it('also works without a parent', () => {
@@ -531,17 +541,32 @@ describe('Dom.js', function () {
describe('round()', () => {
it('rounds all attributes whose values are numbers to two decimals by default', () => {
const rect = new Rect({ id: 'foo', x: 10.678, y: 3, width: 123.456 })
- expect(rect.round().attr()).toEqual({ id: 'foo', x: 10.68, y: 3, width: 123.46 })
+ expect(rect.round().attr()).toEqual({
+ id: 'foo',
+ x: 10.68,
+ y: 3,
+ width: 123.46
+ })
})
it('rounds all attributes whose values are numbers to the passed precision', () => {
const rect = new Rect({ id: 'foo', x: 10.678, y: 3, width: 123.456 })
- expect(rect.round(1).attr()).toEqual({ id: 'foo', x: 10.7, y: 3, width: 123.5 })
+ expect(rect.round(1).attr()).toEqual({
+ id: 'foo',
+ x: 10.7,
+ y: 3,
+ width: 123.5
+ })
})
it('rounds the given attributes whose values are numbers to the passed precision', () => {
const rect = new Rect({ id: 'foo', x: 10.678, y: 3, width: 123.456 })
- expect(rect.round(1, [ 'id', 'x' ]).attr()).toEqual({ id: 'foo', x: 10.7, y: 3, width: 123.456 })
+ expect(rect.round(1, ['id', 'x']).attr()).toEqual({
+ id: 'foo',
+ x: 10.7,
+ y: 3,
+ width: 123.456
+ })
})
})
@@ -632,9 +657,9 @@ describe('Dom.js', function () {
})
})
- describe('writeDataToDom()', () => {
- // not really testable
- })
+ // describe('writeDataToDom()', () => {
+ // // not really testable
+ // })
describe('xml()', () => {
describe('as setter', () => {
@@ -645,27 +670,27 @@ describe('Dom.js', function () {
it('imports a single element', () => {
const g = new G().xml('<rect />', undefined, svg)
- expect(g.children()).toEqual([ any(Rect) ])
+ expect(g.children()).toEqual([any(Rect)])
expect(g.children()[0].node.namespaceURI).toBe(svg)
})
it('imports multiple elements', () => {
const g = new G().xml('<rect /><circle />', undefined, svg)
- expect(g.children()).toEqual([ any(Rect), any(Circle) ])
+ expect(g.children()).toEqual([any(Rect), any(Circle)])
})
it('replaces the current element with the imported elements with outerHtml = true', () => {
const canvas = new Svg()
const g = canvas.group()
g.xml('<rect /><circle />', true, svg)
- expect(canvas.children()).toEqual([ any(Rect), any(Circle) ])
+ expect(canvas.children()).toEqual([any(Rect), any(Circle)])
})
it('returns the parent when outerHtml = true', () => {
const canvas = new Svg()
const g = canvas.group()
expect(g.xml('<rect /><circle />', true, svg)).toBe(canvas)
- expect(canvas.children()).toEqual([ any(Rect), any(Circle) ])
+ expect(canvas.children()).toEqual([any(Rect), any(Circle)])
})
it('works without a parent', () => {
@@ -684,46 +709,58 @@ describe('Dom.js', function () {
})
it('returns the svg string of the element by default', () => {
- expect(rect.xml(), svg).toBe('<rect width="123.456" height="234.567"></rect>')
- expect(canvas.xml(), svg).toBe('<svg><g><rect width="123.456" height="234.567"></rect></g></svg>')
+ expect(rect.xml(), svg).toBe(
+ '<rect width="123.456" height="234.567"></rect>'
+ )
+ expect(canvas.xml(), svg).toBe(
+ '<svg><g><rect width="123.456" height="234.567"></rect></g></svg>'
+ )
})
it('returns the innerHtml when outerHtml = false', () => {
expect(rect.xml(false, svg)).toBe('')
- expect(canvas.xml(false, svg)).toBe('<g><rect width="123.456" height="234.567"></rect></g>')
+ expect(canvas.xml(false, svg)).toBe(
+ '<g><rect width="123.456" height="234.567"></rect></g>'
+ )
})
it('runs a function on every exported node', () => {
- expect(rect.xml((el) => el.round(1))).toBe('<rect width="123.5" height="234.6"></rect>')
+ expect(rect.xml((el) => el.round(1))).toBe(
+ '<rect width="123.5" height="234.6"></rect>'
+ )
})
it('runs a function on every exported node and replaces node with returned node if return value is not falsy', () => {
- expect(rect.xml((el) => new Circle(), svg)).toBe('<circle></circle>')
- expect(canvas.xml((el) => new G(), svg)).toBe('<g></g>') // outer <svg> was replaced by an empty g
- expect(canvas.xml((el) => {
- if (el instanceof Rect) return new Circle()
- if (el instanceof Svg) el.removeNamespace()
- }, svg)).toBe('<svg><g><circle></circle></g></svg>')
+ expect(rect.xml(() => new Circle(), svg)).toBe('<circle></circle>')
+ expect(canvas.xml(() => new G(), svg)).toBe('<g></g>') // outer <svg> was replaced by an empty g
+ expect(
+ canvas.xml((el) => {
+ if (el instanceof Rect) return new Circle()
+ if (el instanceof Svg) el.removeNamespace()
+ }, svg)
+ ).toBe('<svg><g><circle></circle></g></svg>')
})
it('runs a function on every exported node and removes node if return value is false', () => {
expect(group.xml(() => false, svg)).toBe('')
expect(canvas.xml(() => false, svg)).toBe('')
- expect(canvas.xml((el) => {
- if (el instanceof Svg) {
- el.removeNamespace()
- } else {
- return false
- }
- }, svg)).toBe('<svg></svg>')
+ expect(
+ canvas.xml((el) => {
+ if (el instanceof Svg) {
+ el.removeNamespace()
+ } else {
+ return false
+ }
+ }, svg)
+ ).toBe('<svg></svg>')
})
it('runs a function on every inner node and exports it when outerHtml = false', () => {
expect(canvas.xml(() => false, false, svg)).toBe('')
- expect(canvas.xml(() => undefined, false, svg)).toBe('<g><rect width="123.456" height="234.567"></rect></g>')
+ expect(canvas.xml(() => undefined, false, svg)).toBe(
+ '<g><rect width="123.456" height="234.567"></rect></g>'
+ )
})
-
})
-
})
})
diff --git a/spec/spec/elements/Element.js b/spec/spec/elements/Element.js
index 70c3a52..53c5028 100644
--- a/spec/spec/elements/Element.js
+++ b/spec/spec/elements/Element.js
@@ -171,10 +171,10 @@ describe('Element.js', function () {
const group3 = group2.group()
const rect = group3.rect(100, 100)
- expect(rect.parents('.test')).toEqual([ group3, group2, group1 ])
- expect(rect.parents(group2)).toEqual([ group3, group2 ])
+ expect(rect.parents('.test')).toEqual([group3, group2, group1])
+ expect(rect.parents(group2)).toEqual([group3, group2])
expect(rect.parents(group1).length).toBe(3)
- expect(rect.parents()).toEqual([ group3, group2, group1, canvas ])
+ expect(rect.parents()).toEqual([group3, group2, group1, canvas])
})
it('returns array of parents until the closest matching parent', () => {
@@ -185,9 +185,9 @@ describe('Element.js', function () {
const group3 = group2.group().addClass('foo')
const rect = group3.rect(100, 100)
- expect(rect.parents('.test')).toEqual([ group3, group2 ])
- expect(rect.parents('.foo')).toEqual([ group3 ])
- expect(rect.parents('.test:not(.foo)')).toEqual([ group3, group2, group1 ])
+ expect(rect.parents('.test')).toEqual([group3, group2])
+ expect(rect.parents('.foo')).toEqual([group3])
+ expect(rect.parents('.test:not(.foo)')).toEqual([group3, group2, group1])
})
it('returns null if the passed element is not an ancestor', () => {
@@ -198,7 +198,6 @@ describe('Element.js', function () {
const group3 = group2.group()
const rect = group3.rect(100, 100)
-
expect(rect.parents('.does-not-exist')).toEqual(null)
expect(rect.parents('.test')).toEqual(null)
expect(rect.parents(groupA)).toEqual(null)
@@ -274,7 +273,9 @@ describe('Element.js', function () {
it('writes data from the dom property into the dom', () => {
element.dom = { foo: 'bar' }
element.writeDataToDom()
- expect(element.node.getAttribute('svgjs:data')).toBe(JSON.stringify({ foo: 'bar' }))
+ expect(element.node.getAttribute('svgjs:data')).toBe(
+ JSON.stringify({ foo: 'bar' })
+ )
})
it('recursively calls writeDataToDom on all children', () => {
diff --git a/spec/spec/elements/ForeignObject.js b/spec/spec/elements/ForeignObject.js
index 14e9e00..0040d04 100644
--- a/spec/spec/elements/ForeignObject.js
+++ b/spec/spec/elements/ForeignObject.js
@@ -5,7 +5,6 @@ import { makeInstance, ForeignObject } from '../../../src/main.js'
const { any } = jasmine
describe('ForeignObject.js', () => {
-
describe('()', () => {
it('creates a new object of type ForeignObject', () => {
expect(new ForeignObject()).toEqual(any(ForeignObject))
diff --git a/spec/spec/elements/Fragment.js b/spec/spec/elements/Fragment.js
index 8e6503d..dfac3d0 100644
--- a/spec/spec/elements/Fragment.js
+++ b/spec/spec/elements/Fragment.js
@@ -7,7 +7,6 @@ import { svg } from '../../../src/modules/core/namespaces.js'
const { any } = jasmine
describe('Fragment.js', () => {
-
describe('()', () => {
it('creates a new object of type Fragment', () => {
expect(new Fragment()).toEqual(any(Fragment))
@@ -22,7 +21,7 @@ describe('Fragment.js', () => {
const frag = new Fragment()
const rect = frag.rect(100, 100)
- expect(frag.children()).toEqual([ rect ])
+ expect(frag.children()).toEqual([rect])
})
})
@@ -43,7 +42,9 @@ describe('Fragment.js', () => {
group.rect(123.456, 234.567)
const spy = spyOn(Dom.prototype, 'xml').and.callThrough()
- expect(frag.xml(false, svg)).toBe('<g><rect width="123.456" height="234.567"></rect></g>')
+ expect(frag.xml(false, svg)).toBe(
+ '<g><rect width="123.456" height="234.567"></rect></g>'
+ )
expect(spy).toHaveBeenCalledWith(false, svg)
})
@@ -53,10 +54,11 @@ describe('Fragment.js', () => {
group.rect(123.456, 234.567)
const spy = spyOn(Dom.prototype, 'xml').and.callThrough()
- expect(frag.xml(true, svg)).toBe('<g><rect width="123.456" height="234.567"></rect></g>')
+ expect(frag.xml(true, svg)).toBe(
+ '<g><rect width="123.456" height="234.567"></rect></g>'
+ )
expect(spy).toHaveBeenCalledWith(false, svg)
})
})
-
})
})
diff --git a/spec/spec/elements/G.js b/spec/spec/elements/G.js
index 58dc07d..b46e232 100644
--- a/spec/spec/elements/G.js
+++ b/spec/spec/elements/G.js
@@ -5,7 +5,6 @@ import { G, SVG } from '../../../src/main.js'
const { any } = jasmine
describe('G.js', () => {
-
describe('()', () => {
it('creates a new object of type G', () => {
expect(new G()).toEqual(any(G))
diff --git a/spec/spec/elements/Gradient.js b/spec/spec/elements/Gradient.js
index 76c36ce..41b896e 100644
--- a/spec/spec/elements/Gradient.js
+++ b/spec/spec/elements/Gradient.js
@@ -46,7 +46,7 @@ describe('Gradient.js', () => {
const canvas = SVG().addTo(container)
const gradient = canvas.gradient('linear')
const rect = canvas.rect(100, 100).fill(gradient)
- expect(gradient.targets()).toEqual([ rect ])
+ expect(gradient.targets()).toEqual([rect])
})
})
@@ -69,7 +69,7 @@ describe('Gradient.js', () => {
const spy = createSpy('gradient')
gradient.update(spy)
expect(spy.calls.all()).toEqual([
- objectContaining({ object: gradient, args: [ gradient ] })
+ objectContaining({ object: gradient, args: [gradient] })
])
})
})
@@ -102,7 +102,7 @@ describe('Gradient.js', () => {
const gradient = defs.gradient('linear', spy)
expect(gradient).toEqual(any(Gradient))
expect(gradient.type).toBe('linearGradient')
- expect(defs.children()).toEqual([ gradient ])
+ expect(defs.children()).toEqual([gradient])
expect(spy).toHaveBeenCalled()
})
})
diff --git a/spec/spec/elements/Image.js b/spec/spec/elements/Image.js
index c7b91d2..2e92e13 100644
--- a/spec/spec/elements/Image.js
+++ b/spec/spec/elements/Image.js
@@ -7,7 +7,6 @@ const { any, objectContaining, createSpy } = jasmine
const url = 'spec/fixtures/pixel.png'
describe('Image.js', () => {
-
describe('()', () => {
it('creates a new object of type Image', () => {
expect(new Image()).toEqual(any(Image))
@@ -28,7 +27,7 @@ describe('Image.js', () => {
const spy = createSpy('image', (e) => {
expect(e.target.complete).toBe(true)
expect(spy.calls.all()).toEqual([
- objectContaining({ object: image, args: [ any(getWindow().Event) ] })
+ objectContaining({ object: image, args: [any(getWindow().Event)] })
])
done()
}).and.callThrough()
@@ -53,29 +52,37 @@ describe('Image.js', () => {
})
it('should not change with and height when size already set', (done) => {
- const image = new Image().load(url, () => {
- expect(image.attr('height')).toBe(100)
- expect(image.attr('width')).toBe(100)
- done()
- }).size(100, 100)
+ const image = new Image()
+ .load(url, () => {
+ expect(image.attr('height')).toBe(100)
+ expect(image.attr('width')).toBe(100)
+ done()
+ })
+ .size(100, 100)
})
it('changes size of pattern to image size if parent is pattern and size is 0', (done) => {
const pattern = new Pattern().size(0, 0)
- new Image().load(url, () => {
- expect(pattern.attr('height')).toBe(100)
- expect(pattern.attr('width')).toBe(100)
- done()
- }).size(100, 100).addTo(pattern)
+ new Image()
+ .load(url, () => {
+ expect(pattern.attr('height')).toBe(100)
+ expect(pattern.attr('width')).toBe(100)
+ done()
+ })
+ .size(100, 100)
+ .addTo(pattern)
})
it('does not change size of pattern if pattern has a size set', (done) => {
const pattern = new Pattern().size(50, 50)
- new Image().load(url, () => {
- expect(pattern.attr('height')).toBe(50)
- expect(pattern.attr('width')).toBe(50)
- done()
- }).size(100, 100).addTo(pattern)
+ new Image()
+ .load(url, () => {
+ expect(pattern.attr('height')).toBe(50)
+ expect(pattern.attr('width')).toBe(50)
+ done()
+ })
+ .size(100, 100)
+ .addTo(pattern)
})
})
@@ -85,7 +92,7 @@ describe('Image.js', () => {
const canvas = SVG()
const image = canvas.image(url)
expect(image).toBe(image)
- expect(canvas.children()).toEqual([ image ])
+ expect(canvas.children()).toEqual([image])
})
})
})
@@ -95,21 +102,21 @@ describe('Image.js', () => {
const canvas = SVG()
const image = new Image()
canvas.rect(100, 100).attr('something', image)
- expect(canvas.defs().children()).toEqual([ any(Pattern) ])
+ expect(canvas.defs().children()).toEqual([any(Pattern)])
expect(canvas.defs().findOne('image')).toBe(image)
})
it('creates an image from image path in defs with pattern when attr is fill', () => {
const canvas = SVG()
canvas.rect(100, 100).attr('fill', url)
- expect(canvas.defs().children()).toEqual([ any(Pattern) ])
+ expect(canvas.defs().children()).toEqual([any(Pattern)])
expect(canvas.defs().findOne('image').attr('href')).toBe(url)
})
it('creates an image from image path in defs with pattern when attr is stroke', () => {
const canvas = SVG()
canvas.rect(100, 100).attr('stroke', url)
- expect(canvas.defs().children()).toEqual([ any(Pattern) ])
+ expect(canvas.defs().children()).toEqual([any(Pattern)])
expect(canvas.defs().findOne('image').attr('href')).toBe(url)
})
})
diff --git a/spec/spec/elements/Line.js b/spec/spec/elements/Line.js
index 9f25937..48a02bf 100644
--- a/spec/spec/elements/Line.js
+++ b/spec/spec/elements/Line.js
@@ -25,7 +25,10 @@ describe('Line.js', () => {
it('returns a PointArray containing the points of the line', () => {
const array = line.plot(1, 2, 3, 4).array()
expect(array).toEqual(any(PointArray))
- expect(array).toEqual([ [ 1, 2 ], [ 3, 4 ] ])
+ expect(array).toEqual([
+ [1, 2],
+ [3, 4]
+ ])
})
})
@@ -38,9 +41,14 @@ describe('Line.js', () => {
const canvas = SVG().addTo(container)
const line = canvas.line(1, 2, 3, 4)
line.move(50, 50)
- expect(line.bbox()).toEqual(objectContaining({
- x: 50, y: 50, width: 2, height: 2
- }))
+ expect(line.bbox()).toEqual(
+ objectContaining({
+ x: 50,
+ y: 50,
+ width: 2,
+ height: 2
+ })
+ )
})
})
@@ -65,19 +73,27 @@ describe('Line.js', () => {
it('calls attr with line attributes when array given', () => {
const spy = spyOn(line, 'attr')
- line.plot([ 1, 2, 3, 4 ])
+ line.plot([1, 2, 3, 4])
expect(spy).toHaveBeenCalledWith({ x1: 1, y1: 2, x2: 3, y2: 4 })
})
it('calls attr with line attributes when multi array given', () => {
const spy = spyOn(line, 'attr')
- line.plot([ [ 1, 2 ], [ 3, 4 ] ])
+ line.plot([
+ [1, 2],
+ [3, 4]
+ ])
expect(spy).toHaveBeenCalledWith({ x1: 1, y1: 2, x2: 3, y2: 4 })
})
it('calls attr with line attributes when PointArray given', () => {
const spy = spyOn(line, 'attr')
- line.plot(new PointArray([ [ 1, 2 ], [ 3, 4 ] ]))
+ line.plot(
+ new PointArray([
+ [1, 2],
+ [3, 4]
+ ])
+ )
expect(spy).toHaveBeenCalledWith({ x1: 1, y1: 2, x2: 3, y2: 4 })
})
})
@@ -91,27 +107,42 @@ describe('Line.js', () => {
const canvas = SVG().addTo(container)
const line = canvas.line(1, 2, 3, 4)
line.size(50, 50)
- expect(line.bbox()).toEqual(objectContaining({
- width: 50, height: 50, x: 1, y: 2
- }))
+ expect(line.bbox()).toEqual(
+ objectContaining({
+ width: 50,
+ height: 50,
+ x: 1,
+ y: 2
+ })
+ )
})
it('changes height proportionally', () => {
const canvas = SVG().addTo(container)
const line = canvas.line(1, 2, 3, 4)
line.size(50, null)
- expect(line.bbox()).toEqual(objectContaining({
- width: 50, height: 50, x: 1, y: 2
- }))
+ expect(line.bbox()).toEqual(
+ objectContaining({
+ width: 50,
+ height: 50,
+ x: 1,
+ y: 2
+ })
+ )
})
it('changes width proportionally', () => {
const canvas = SVG().addTo(container)
const line = canvas.line(1, 2, 3, 4)
line.size(null, 50)
- expect(line.bbox()).toEqual(objectContaining({
- width: 50, height: 50, x: 1, y: 2
- }))
+ expect(line.bbox()).toEqual(
+ objectContaining({
+ width: 50,
+ height: 50,
+ x: 1,
+ y: 2
+ })
+ )
})
})
@@ -120,14 +151,20 @@ describe('Line.js', () => {
it('creates a line with given points', () => {
const group = new G()
const line = group.line(1, 2, 3, 4)
- expect(line.array()).toEqual([ [ 1, 2 ], [ 3, 4 ] ])
+ expect(line.array()).toEqual([
+ [1, 2],
+ [3, 4]
+ ])
expect(line).toEqual(any(Line))
})
it('defaults to zero line', () => {
const group = new G()
const line = group.line()
- expect(line.array()).toEqual([ [ 0, 0 ], [ 0, 0 ] ])
+ expect(line.array()).toEqual([
+ [0, 0],
+ [0, 0]
+ ])
expect(line).toEqual(any(Line))
})
})
diff --git a/spec/spec/elements/Marker.js b/spec/spec/elements/Marker.js
index 63e06fe..cddfc50 100644
--- a/spec/spec/elements/Marker.js
+++ b/spec/spec/elements/Marker.js
@@ -5,7 +5,6 @@ import { Marker, SVG, Defs } from '../../../src/main.js'
const { any } = jasmine
describe('Marker.js', function () {
-
describe('()', () => {
it('creates a new object of type Marker', () => {
expect(new Marker()).toEqual(any(Marker))
@@ -106,7 +105,7 @@ describe('Marker.js', function () {
expect(marker.attr('viewBox')).toBe('0 0 10 12')
expect(marker.attr('orient')).toBe('auto')
expect(marker).toEqual(any(Marker))
- expect(defs.children()).toEqual([ marker ])
+ expect(defs.children()).toEqual([marker])
})
})
})
@@ -117,7 +116,9 @@ describe('Marker.js', function () {
beforeEach(() => {
// because we use `reference` here we need to put it into the live dom
canvas = new SVG().addTo(container)
- path = canvas.path('M 100 200 C 200 100 300 0 400 100 C 500 200 600 300 700 200 C 800 100 900 100 900 100')
+ path = canvas.path(
+ 'M 100 200 C 200 100 300 0 400 100 C 500 200 600 300 700 200 C 800 100 900 100 900 100'
+ )
})
it('creates an instance of Marker', () => {
@@ -172,7 +173,5 @@ describe('Marker.js', function () {
expect(path.node.getAttribute('marker-mid')).toBe(marker.toString())
})
})
-
})
-
})
diff --git a/spec/spec/elements/Mask.js b/spec/spec/elements/Mask.js
index 32e5d15..08a1aaa 100644
--- a/spec/spec/elements/Mask.js
+++ b/spec/spec/elements/Mask.js
@@ -5,7 +5,6 @@ import { Mask, SVG, Container, Rect } from '../../../src/main.js'
const { any } = jasmine
describe('Mask.js', () => {
-
describe('()', () => {
it('creates a new object of type Mask', () => {
expect(new Mask()).toEqual(any(Mask))
@@ -38,7 +37,7 @@ describe('Mask.js', () => {
const canvas = SVG().addTo(container)
const mask = canvas.mask()
const rect = canvas.rect(100, 100).maskWith(mask)
- expect(mask.targets()).toEqual([ rect ])
+ expect(mask.targets()).toEqual([rect])
})
})
@@ -48,7 +47,7 @@ describe('Mask.js', () => {
const canvas = SVG()
const mask = canvas.mask()
expect(mask).toEqual(any(Mask))
- expect(canvas.defs().children()).toEqual([ mask ])
+ expect(canvas.defs().children()).toEqual([mask])
})
})
})
diff --git a/spec/spec/elements/Path.js b/spec/spec/elements/Path.js
index d43857e..08105bc 100644
--- a/spec/spec/elements/Path.js
+++ b/spec/spec/elements/Path.js
@@ -25,7 +25,10 @@ describe('Path.js', () => {
it('returns the underlying PathArray', () => {
const array = path.plot('M1 2 3 4').array()
expect(array).toEqual(any(PathArray))
- expect(array).toEqual([ [ 'M', 1, 2 ], [ 'L', 3, 4 ] ])
+ expect(array).toEqual([
+ ['M', 1, 2],
+ ['L', 3, 4]
+ ])
})
})
@@ -61,9 +64,14 @@ describe('Path.js', () => {
const canvas = SVG().addTo(container)
const path = canvas.path('M0 0 50, 50')
path.move(50, 50)
- expect(path.bbox()).toEqual(objectContaining({
- x: 50, y: 50, width: 50, height: 50
- }))
+ expect(path.bbox()).toEqual(
+ objectContaining({
+ x: 50,
+ y: 50,
+ width: 50,
+ height: 50
+ })
+ )
})
})
@@ -82,20 +90,37 @@ describe('Path.js', () => {
it('works with flat array', () => {
const spy = spyOn(path, 'attr')
- path.plot([ 'M', 0, 0, 'L', 50, 50 ])
- expect(spy).toHaveBeenCalledWith('d', [ [ 'M', 0, 0 ], [ 'L', 50, 50 ] ])
+ path.plot(['M', 0, 0, 'L', 50, 50])
+ expect(spy).toHaveBeenCalledWith('d', [
+ ['M', 0, 0],
+ ['L', 50, 50]
+ ])
})
it('works with multi array', () => {
const spy = spyOn(path, 'attr')
- path.plot([ [ 'M', 0, 0 ], [ 'L', 50, 50 ] ])
- expect(spy).toHaveBeenCalledWith('d', [ [ 'M', 0, 0 ], [ 'L', 50, 50 ] ])
+ path.plot([
+ ['M', 0, 0],
+ ['L', 50, 50]
+ ])
+ expect(spy).toHaveBeenCalledWith('d', [
+ ['M', 0, 0],
+ ['L', 50, 50]
+ ])
})
it('works with PathArray', () => {
const spy = spyOn(path, 'attr')
- path.plot(new PathArray([ [ 'M', 0, 0 ], [ 'L', 50, 50 ] ]))
- expect(spy).toHaveBeenCalledWith('d', [ [ 'M', 0, 0 ], [ 'L', 50, 50 ] ])
+ path.plot(
+ new PathArray([
+ ['M', 0, 0],
+ ['L', 50, 50]
+ ])
+ )
+ expect(spy).toHaveBeenCalledWith('d', [
+ ['M', 0, 0],
+ ['L', 50, 50]
+ ])
})
})
@@ -108,27 +133,42 @@ describe('Path.js', () => {
const canvas = SVG().addTo(container)
const path = canvas.path('M0 0 50, 50')
path.size(100, 100)
- expect(path.bbox()).toEqual(objectContaining({
- width: 100, height: 100, x: 0, y: 0
- }))
+ expect(path.bbox()).toEqual(
+ objectContaining({
+ width: 100,
+ height: 100,
+ x: 0,
+ y: 0
+ })
+ )
})
it('changes height proportionally', () => {
const canvas = SVG().addTo(container)
const path = canvas.path('M0 0 50, 50')
path.size(100, null)
- expect(path.bbox()).toEqual(objectContaining({
- width: 100, height: 100, x: 0, y: 0
- }))
+ expect(path.bbox()).toEqual(
+ objectContaining({
+ width: 100,
+ height: 100,
+ x: 0,
+ y: 0
+ })
+ )
})
it('changes width proportionally', () => {
const canvas = SVG().addTo(container)
const path = canvas.path('M0 0 50, 50')
path.size(null, 100)
- expect(path.bbox()).toEqual(objectContaining({
- width: 100, height: 100, x: 0, y: 0
- }))
+ expect(path.bbox()).toEqual(
+ objectContaining({
+ width: 100,
+ height: 100,
+ x: 0,
+ y: 0
+ })
+ )
})
})
diff --git a/spec/spec/elements/Pattern.js b/spec/spec/elements/Pattern.js
index 670a1af..edc9841 100644
--- a/spec/spec/elements/Pattern.js
+++ b/spec/spec/elements/Pattern.js
@@ -39,7 +39,7 @@ describe('Pattern.js', () => {
const canvas = SVG().addTo(container)
const pattern = canvas.pattern()
const rect = canvas.rect(100, 100).fill(pattern)
- expect(pattern.targets()).toEqual([ rect ])
+ expect(pattern.targets()).toEqual([rect])
})
})
@@ -62,7 +62,7 @@ describe('Pattern.js', () => {
const spy = createSpy('pattern')
pattern.update(spy)
expect(spy.calls.all()).toEqual([
- objectContaining({ object: pattern, args: [ pattern ] })
+ objectContaining({ object: pattern, args: [pattern] })
])
})
})
@@ -94,9 +94,14 @@ describe('Pattern.js', () => {
const spy = createSpy('pattern')
const pattern = defs.pattern(100, 100, spy)
expect(pattern).toEqual(any(Pattern))
- expect(defs.children()).toEqual([ pattern ])
+ expect(defs.children()).toEqual([pattern])
expect(spy).toHaveBeenCalled()
- expect(pattern.attr([ 'x', 'y', 'width', 'height' ])).toEqual({ x: 0, y: 0, width: 100, height: 100 })
+ expect(pattern.attr(['x', 'y', 'width', 'height'])).toEqual({
+ x: 0,
+ y: 0,
+ width: 100,
+ height: 100
+ })
})
})
})
diff --git a/spec/spec/elements/Polygon.js b/spec/spec/elements/Polygon.js
index 8a3f226..872aa32 100644
--- a/spec/spec/elements/Polygon.js
+++ b/spec/spec/elements/Polygon.js
@@ -19,8 +19,11 @@ describe('Polygon.js', () => {
describe('polygon()', () => {
it('creates a polygon with given points', () => {
const group = new G()
- const polygon = group.polygon([ 1, 2, 3, 4 ])
- expect(polygon.array()).toEqual([ [ 1, 2 ], [ 3, 4 ] ])
+ const polygon = group.polygon([1, 2, 3, 4])
+ expect(polygon.array()).toEqual([
+ [1, 2],
+ [3, 4]
+ ])
expect(polygon).toEqual(any(Polygon))
})
})
@@ -28,7 +31,7 @@ describe('Polygon.js', () => {
it('creates a polygon with one point by default', () => {
const group = new G()
const polygon = group.polygon()
- expect(polygon.array()).toEqual([ [ 0, 0 ] ])
+ expect(polygon.array()).toEqual([[0, 0]])
expect(polygon).toEqual(any(Polygon))
})
})
diff --git a/spec/spec/elements/Polyline.js b/spec/spec/elements/Polyline.js
index 76dca30..e4a571f 100644
--- a/spec/spec/elements/Polyline.js
+++ b/spec/spec/elements/Polyline.js
@@ -19,15 +19,18 @@ describe('Polyline.js', () => {
describe('polyline()', () => {
it('creates a polyline with given points', () => {
const group = new G()
- const polyline = group.polyline([ 1, 2, 3, 4 ])
- expect(polyline.array()).toEqual([ [ 1, 2 ], [ 3, 4 ] ])
+ const polyline = group.polyline([1, 2, 3, 4])
+ expect(polyline.array()).toEqual([
+ [1, 2],
+ [3, 4]
+ ])
expect(polyline).toEqual(any(Polyline))
})
it('creates a polyline with one point by default', () => {
const group = new G()
const polyline = group.polyline()
- expect(polyline.array()).toEqual([ [ 0, 0 ] ])
+ expect(polyline.array()).toEqual([[0, 0]])
expect(polyline).toEqual(any(Polyline))
})
})
diff --git a/spec/spec/elements/Rect.js b/spec/spec/elements/Rect.js
index 230078f..20b5117 100644
--- a/spec/spec/elements/Rect.js
+++ b/spec/spec/elements/Rect.js
@@ -20,7 +20,10 @@ describe('Rect.js', () => {
it('creates a rect with given size', () => {
const group = new G()
const rect = group.rect(100, 100)
- expect(rect.attr([ 'width', 'height' ])).toEqual({ width: 100, height: 100 })
+ expect(rect.attr(['width', 'height'])).toEqual({
+ width: 100,
+ height: 100
+ })
expect(rect).toEqual(any(Rect))
})
})
diff --git a/spec/spec/elements/Stop.js b/spec/spec/elements/Stop.js
index e2ce2a8..e58cb24 100644
--- a/spec/spec/elements/Stop.js
+++ b/spec/spec/elements/Stop.js
@@ -66,7 +66,11 @@ describe('Stop.js', () => {
it('creates stop in the gradient with object given', () => {
const gradient = new Gradient('linear')
- const stop = gradient.stop({ offset: 0.1, color: '#ffffff', opacity: 0.5 })
+ const stop = gradient.stop({
+ offset: 0.1,
+ color: '#ffffff',
+ opacity: 0.5
+ })
expect(stop.attr('offset')).toBe(0.1)
expect(stop.attr('stop-color')).toBe('#ffffff')
expect(stop.attr('stop-opacity')).toBe(0.5)
diff --git a/spec/spec/elements/Style.js b/spec/spec/elements/Style.js
index 7b69dd3..fd587a1 100644
--- a/spec/spec/elements/Style.js
+++ b/spec/spec/elements/Style.js
@@ -33,13 +33,17 @@ describe('Style.js', () => {
it('adds a font-face rule to load a custom font and returns itself', () => {
const style = new Style()
expect(style.font('fontName', 'url')).toBe(style)
- expect(style.node.textContent).toBe('@font-face{font-family:fontName;src:url;}')
+ expect(style.node.textContent).toBe(
+ '@font-face{font-family:fontName;src:url;}'
+ )
})
it('adds extra parameters if wanted', () => {
const style = new Style()
style.font('fontName', 'url', { foo: 'bar' })
- expect(style.node.textContent).toBe('@font-face{font-family:fontName;src:url;foo:bar;}')
+ expect(style.node.textContent).toBe(
+ '@font-face{font-family:fontName;src:url;foo:bar;}'
+ )
})
})
@@ -78,7 +82,9 @@ describe('Style.js', () => {
const g = new G()
const style = g.fontface('fontName', 'url', { foo: 'bar' })
expect(style).toEqual(any(Style))
- expect(style.node.textContent).toBe('@font-face{font-family:fontName;src:url;foo:bar;}')
+ expect(style.node.textContent).toBe(
+ '@font-face{font-family:fontName;src:url;foo:bar;}'
+ )
})
})
})
diff --git a/spec/spec/elements/Svg.js b/spec/spec/elements/Svg.js
index 990992a..6da7729 100644
--- a/spec/spec/elements/Svg.js
+++ b/spec/spec/elements/Svg.js
@@ -1,13 +1,16 @@
/* globals describe, expect, it, jasmine, container */
import { Svg, SVG, Defs } from '../../../src/main.js'
-import { svg as ns, xlink, svgjs } from '../../../src/modules/core/namespaces.js'
+import {
+ svg as ns,
+ xlink,
+ svgjs
+} from '../../../src/modules/core/namespaces.js'
import { getWindow } from '../../../src/utils/window.js'
const { any } = jasmine
describe('Svg.js', () => {
-
describe('()', () => {
it('creates a new object of type Svg', () => {
expect(new Svg()).toEqual(any(Svg))
diff --git a/spec/spec/elements/Symbol.js b/spec/spec/elements/Symbol.js
index 12be314..6d9c17e 100644
--- a/spec/spec/elements/Symbol.js
+++ b/spec/spec/elements/Symbol.js
@@ -21,7 +21,7 @@ describe('Symbol.js', () => {
const g = new G()
const symbol = g.symbol()
expect(symbol).toEqual(any(Symbol))
- expect(g.children()).toEqual([ symbol ])
+ expect(g.children()).toEqual([symbol])
})
})
})
diff --git a/spec/spec/elements/Text.js b/spec/spec/elements/Text.js
index e1a74d2..b0c5a9a 100644
--- a/spec/spec/elements/Text.js
+++ b/spec/spec/elements/Text.js
@@ -1,6 +1,13 @@
/* globals describe, expect, it, spyOn jasmine, container */
-import { Text, Number as SVGNumber, SVG, G, Path, TextPath } from '../../../src/main.js'
+import {
+ Text,
+ Number as SVGNumber,
+ SVG,
+ G,
+ Path,
+ TextPath
+} from '../../../src/main.js'
const { any } = jasmine
diff --git a/spec/spec/elements/TextPath.js b/spec/spec/elements/TextPath.js
index 91c78c8..5e85bdb 100644
--- a/spec/spec/elements/TextPath.js
+++ b/spec/spec/elements/TextPath.js
@@ -7,7 +7,8 @@ const { any } = jasmine
describe('TextPath.js', () => {
var canvas, text, path
var txt = 'We go up, then we go down, then up again'
- var data = 'M 100 200 C 200 100 300 0 400 100 C 500 200 600 300 700 200 C 800 100 900 100 900 100'
+ var data =
+ 'M 100 200 C 200 100 300 0 400 100 C 500 200 600 300 700 200 C 800 100 900 100 900 100'
beforeEach(() => {
canvas = new SVG().addTo(container)
@@ -144,9 +145,8 @@ describe('TextPath.js', () => {
describe('targets', () => {
it('returns all elements referencing this path with href', () => {
const textPath = text.path(path)
- expect(path.targets()).toEqual([ textPath ])
+ expect(path.targets()).toEqual([textPath])
})
})
})
-
})
diff --git a/spec/spec/elements/Tspan.js b/spec/spec/elements/Tspan.js
index d6f42b2..879267c 100644
--- a/spec/spec/elements/Tspan.js
+++ b/spec/spec/elements/Tspan.js
@@ -98,11 +98,12 @@ describe('Tspan.js', () => {
text.tspan('Second Line').newLine()
const third = text.tspan('Third Line').newLine()
- const fontSize = getWindow().getComputedStyle(third.node).getPropertyValue('font-size')
+ const fontSize = getWindow()
+ .getComputedStyle(third.node)
+ .getPropertyValue('font-size')
const dy = 2 * new SVGNumber(fontSize)
expect(third.dy()).toBe(dy)
})
-
})
describe('Tspan', () => {
diff --git a/spec/spec/modules/core/attr.js b/spec/spec/modules/core/attr.js
index e73fb53..b47794a 100644
--- a/spec/spec/modules/core/attr.js
+++ b/spec/spec/modules/core/attr.js
@@ -6,7 +6,6 @@ import { registerAttrHook } from '../../../../src/modules/core/attr.js'
const { objectContaining } = jasmine
describe('attr.js', () => {
-
describe('attr()', () => {
let element
@@ -83,13 +82,13 @@ describe('attr.js', () => {
'fill-opacity': 0.5
})
- const ret = element.attr([ 'x', 'fill-opacity' ])
+ const ret = element.attr(['x', 'fill-opacity'])
expect(ret).toEqual({ x: 1, 'fill-opacity': 0.5 })
})
it('correctly creates SVG.Array if array given', () => {
- element.attr('something', [ 2, 3, 4 ])
+ element.attr('something', [2, 3, 4])
expect(element.attr('something')).toBe('2 3 4')
})
@@ -120,8 +119,9 @@ describe('attr.js', () => {
element.attr('name', 'Bob')
}
- expect(throwingFn).toThrowError('This hook should only be executed in one test')
+ expect(throwingFn).toThrowError(
+ 'This hook should only be executed in one test'
+ )
})
})
-
})
diff --git a/spec/spec/modules/core/circled.js b/spec/spec/modules/core/circled.js
index a6324d8..95217c0 100644
--- a/spec/spec/modules/core/circled.js
+++ b/spec/spec/modules/core/circled.js
@@ -94,5 +94,4 @@ describe('circled.js', () => {
expect(element.height()).toBe(100)
})
})
-
})
diff --git a/spec/spec/modules/core/containerGeometry.js b/spec/spec/modules/core/containerGeometry.js
index 740f99f..011d9a8 100644
--- a/spec/spec/modules/core/containerGeometry.js
+++ b/spec/spec/modules/core/containerGeometry.js
@@ -5,7 +5,6 @@ import { Box, create, Element, G, Rect, SVG } from '../../../../src/main.js'
const { any, objectContaining } = jasmine
describe('containerGeometry.js', () => {
-
describe('dmove()', () => {
it('moves the bbox of the group by a certain amount (1)', () => {
const canvas = SVG().addTo(container)
@@ -17,9 +16,14 @@ describe('containerGeometry.js', () => {
g.dmove(10, 10)
const box = g.bbox()
- expect(box).toEqual(objectContaining({
- x: 20, y: 30, width: box.width, height: box.height
- }))
+ expect(box).toEqual(
+ objectContaining({
+ x: 20,
+ y: 30,
+ width: box.width,
+ height: box.height
+ })
+ )
})
it('moves the bbox of the group by a certain amount (2)', () => {
@@ -55,9 +59,14 @@ describe('containerGeometry.js', () => {
expect(fn).not.toThrowError()
const box = g.bbox()
- expect(box).toEqual(objectContaining({
- x: 20, y: 30, width: box.width, height: box.height
- }))
+ expect(box).toEqual(
+ objectContaining({
+ x: 20,
+ y: 30,
+ width: box.width,
+ height: box.height
+ })
+ )
})
})
@@ -211,7 +220,6 @@ describe('containerGeometry.js', () => {
expect(newBox.w).toBeCloseTo(100, 4)
expect(newBox.h).toBeCloseTo(100, 4)
})
-
})
describe('width()', () => {
diff --git a/spec/spec/modules/core/event.js b/spec/spec/modules/core/event.js
index a395a4b..e259593 100644
--- a/spec/spec/modules/core/event.js
+++ b/spec/spec/modules/core/event.js
@@ -1,5 +1,13 @@
/* globals describe, expect, it, spyOn, jasmine */
-import { windowEvents, getEvents, getEventTarget, clearEvents, dispatch, on, off } from '../../../../src/modules/core/event.js'
+import {
+ windowEvents,
+ getEvents,
+ getEventTarget,
+ clearEvents,
+ dispatch,
+ on,
+ off
+} from '../../../../src/modules/core/event.js'
import { getWindow } from '../../../../src/utils/window.js'
import { EventTarget, SVG } from '../../../../src/main.js'
@@ -68,7 +76,7 @@ describe('event.js', () => {
it('binds to multiple events passed as array', () => {
const eventTarget = new EventTarget()
const spy = createSpy('spy')
- on(eventTarget, [ 'event1', 'event2', 'event3' ], spy)
+ on(eventTarget, ['event1', 'event2', 'event3'], spy)
dispatch(eventTarget, 'event1')
dispatch(eventTarget, 'event2')
dispatch(eventTarget, 'event3')
@@ -112,11 +120,11 @@ describe('event.js', () => {
it('unbinds multiple events with space or comma separated string', () => {
const eventTarget = new EventTarget()
const spy = createSpy('spy')
- on(eventTarget, [ 'event1', 'event2', 'event3' ], spy)
+ on(eventTarget, ['event1', 'event2', 'event3'], spy)
dispatch(eventTarget, 'event1')
dispatch(eventTarget, 'event2')
dispatch(eventTarget, 'event3')
- off(eventTarget, [ 'event1', 'event2', 'event3' ], spy)
+ off(eventTarget, ['event1', 'event2', 'event3'], spy)
dispatch(eventTarget, 'event1')
dispatch(eventTarget, 'event2')
dispatch(eventTarget, 'event3')
@@ -136,11 +144,11 @@ describe('event.js', () => {
it('unbinds all events including namespaced ones when only event is passed', () => {
const eventTarget = new EventTarget()
const spy = createSpy('spy')
- on(eventTarget, [ 'event1.ns1', 'event2.ns2', 'event3' ], spy)
+ on(eventTarget, ['event1.ns1', 'event2.ns2', 'event3'], spy)
dispatch(eventTarget, 'event1')
dispatch(eventTarget, 'event2')
dispatch(eventTarget, 'event3')
- off(eventTarget, [ 'event1', 'event2', 'event3' ])
+ off(eventTarget, ['event1', 'event2', 'event3'])
dispatch(eventTarget, 'event1')
dispatch(eventTarget, 'event2')
dispatch(eventTarget, 'event3')
@@ -192,7 +200,12 @@ describe('event.js', () => {
it('dispatches a custom event on the EventTarget by calling dispatchEvent()', () => {
const eventTarget = new EventTarget()
const spy = spyOn(eventTarget, 'dispatchEvent')
- const event = dispatch(eventTarget, 'event', { some: 'data' }, { cancelable: false })
+ const event = dispatch(
+ eventTarget,
+ 'event',
+ { some: 'data' },
+ { cancelable: false }
+ )
expect(event).toEqual(any(getWindow().CustomEvent))
expect(spy).toHaveBeenCalledWith(event)
expect(event.detail).toEqual({ some: 'data' })
diff --git a/spec/spec/modules/core/gradiented.js b/spec/spec/modules/core/gradiented.js
index ba159f5..7b2c227 100644
--- a/spec/spec/modules/core/gradiented.js
+++ b/spec/spec/modules/core/gradiented.js
@@ -3,7 +3,6 @@
import { Gradient } from '../../../../src/main.js'
describe('gradiented.js', () => {
-
describe('from()', () => {
it('sets fx and fy for radial gradients and returns itself', () => {
const gradient = new Gradient('radial')
@@ -35,5 +34,4 @@ describe('gradiented.js', () => {
expect(gradient.attr('y2')).toBe(20)
})
})
-
})
diff --git a/spec/spec/modules/core/pointed.js b/spec/spec/modules/core/pointed.js
index bbe2475..77bf2d3 100644
--- a/spec/spec/modules/core/pointed.js
+++ b/spec/spec/modules/core/pointed.js
@@ -8,12 +8,11 @@ describe('pointed.js', () => {
beforeEach(() => {
canvas = SVG().addTo(container)
const line = canvas.line(1, 2, 3, 4)
- const polygon = canvas.polygon([ 1, 2, 3, 4 ])
- const polyline = canvas.polyline([ 1, 2, 3, 4 ])
+ const polygon = canvas.polygon([1, 2, 3, 4])
+ const polyline = canvas.polyline([1, 2, 3, 4])
lines = { line, polygon, polyline }
})
-
- ;[ 'line', 'polygon', 'polyline' ].forEach((l) => {
+ ;['line', 'polygon', 'polyline'].forEach((l) => {
describe('for ' + l, () => {
describe('x()', () => {
it('sets the x value of the ' + l + 'and returns itself', () => {
diff --git a/spec/spec/modules/core/poly.js b/spec/spec/modules/core/poly.js
index c44bebc..e4c3bed 100644
--- a/spec/spec/modules/core/poly.js
+++ b/spec/spec/modules/core/poly.js
@@ -15,7 +15,10 @@ describe('Polygon.js', () => {
it('returns the underlying PointArray', () => {
const array = poly.plot('1 2 3 4').array()
expect(array).toEqual(any(PointArray))
- expect(array).toEqual([ [ 1, 2 ], [ 3, 4 ] ])
+ expect(array).toEqual([
+ [1, 2],
+ [3, 4]
+ ])
})
})
@@ -36,9 +39,14 @@ describe('Polygon.js', () => {
const canvas = SVG().addTo(container)
const poly = canvas.polygon('0 0 50 50')
poly.move(50, 50)
- expect(poly.bbox()).toEqual(objectContaining({
- x: 50, y: 50, width: 50, height: 50
- }))
+ expect(poly.bbox()).toEqual(
+ objectContaining({
+ x: 50,
+ y: 50,
+ width: 50,
+ height: 50
+ })
+ )
})
})
@@ -57,20 +65,37 @@ describe('Polygon.js', () => {
it('works with flat array', () => {
const spy = spyOn(poly, 'attr')
- poly.plot([ 1, 2, 3, 4 ])
- expect(spy).toHaveBeenCalledWith('points', [ [ 1, 2 ], [ 3, 4 ] ])
+ poly.plot([1, 2, 3, 4])
+ expect(spy).toHaveBeenCalledWith('points', [
+ [1, 2],
+ [3, 4]
+ ])
})
it('works with multi array', () => {
const spy = spyOn(poly, 'attr')
- poly.plot([ [ 1, 2 ], [ 3, 4 ] ])
- expect(spy).toHaveBeenCalledWith('points', [ [ 1, 2 ], [ 3, 4 ] ])
+ poly.plot([
+ [1, 2],
+ [3, 4]
+ ])
+ expect(spy).toHaveBeenCalledWith('points', [
+ [1, 2],
+ [3, 4]
+ ])
})
it('works with PointArray', () => {
const spy = spyOn(poly, 'attr')
- poly.plot(new PointArray([ [ 1, 2 ], [ 3, 4 ] ]))
- expect(spy).toHaveBeenCalledWith('points', [ [ 1, 2 ], [ 3, 4 ] ])
+ poly.plot(
+ new PointArray([
+ [1, 2],
+ [3, 4]
+ ])
+ )
+ expect(spy).toHaveBeenCalledWith('points', [
+ [1, 2],
+ [3, 4]
+ ])
})
})
@@ -83,27 +108,42 @@ describe('Polygon.js', () => {
const canvas = SVG().addTo(container)
const poly = canvas.polygon('0 0 50 50')
poly.size(100, 100)
- expect(poly.bbox()).toEqual(objectContaining({
- width: 100, height: 100, x: 0, y: 0
- }))
+ expect(poly.bbox()).toEqual(
+ objectContaining({
+ width: 100,
+ height: 100,
+ x: 0,
+ y: 0
+ })
+ )
})
it('changes height proportionally', () => {
const canvas = SVG().addTo(container)
const poly = canvas.polygon('0 0 50 50')
poly.size(100, null)
- expect(poly.bbox()).toEqual(objectContaining({
- width: 100, height: 100, x: 0, y: 0
- }))
+ expect(poly.bbox()).toEqual(
+ objectContaining({
+ width: 100,
+ height: 100,
+ x: 0,
+ y: 0
+ })
+ )
})
it('changes width proportionally', () => {
const canvas = SVG().addTo(container)
const poly = canvas.polygon('0 0 50 50')
poly.size(null, 100)
- expect(poly.bbox()).toEqual(objectContaining({
- width: 100, height: 100, x: 0, y: 0
- }))
+ expect(poly.bbox()).toEqual(
+ objectContaining({
+ width: 100,
+ height: 100,
+ x: 0,
+ y: 0
+ })
+ )
})
})
})
diff --git a/spec/spec/modules/core/regex.js b/spec/spec/modules/core/regex.js
index 5040fbd..37f774c 100644
--- a/spec/spec/modules/core/regex.js
+++ b/spec/spec/modules/core/regex.js
@@ -96,14 +96,26 @@ describe('regex.js', () => {
describe('transforms', () => {
it('splits a transform chain', () => {
- const split = 'rotate(34) translate(1,2), translate(1 , 3),rotate(12) , something(1,2,3)'.split(regex.transforms)
- expect(split).toEqual([ 'rotate(34', 'translate(1,2', 'translate(1 , 3', 'rotate(12', 'something(1,2,3', '' ])
+ const split =
+ 'rotate(34) translate(1,2), translate(1 , 3),rotate(12) , something(1,2,3)'.split(
+ regex.transforms
+ )
+ expect(split).toEqual([
+ 'rotate(34',
+ 'translate(1,2',
+ 'translate(1 , 3',
+ 'rotate(12',
+ 'something(1,2,3',
+ ''
+ ])
})
})
describe('whitespace', () => {
it('replaces all whitespaces', () => {
- expect(' \n \r \t '.replace(regex.whitespace, ' ')).toBe(' ')
+ expect(' \n \r \t '.replace(regex.whitespace, ' ')).toBe(
+ ' '
+ )
})
})
@@ -196,7 +208,7 @@ describe('regex.js', () => {
describe('delimiter', () => {
it('splits at whitespace and comma', () => {
const split = '1,2 3 , 4 5,, 6'.split(regex.delimiter)
- expect(split).toEqual([ '1', '2', '3', '4', '5', '6' ])
+ expect(split).toEqual(['1', '2', '3', '4', '5', '6'])
})
})
diff --git a/spec/spec/modules/core/selector.js b/spec/spec/modules/core/selector.js
index 1336059..8729b61 100644
--- a/spec/spec/modules/core/selector.js
+++ b/spec/spec/modules/core/selector.js
@@ -10,17 +10,17 @@ describe('selector.js', () => {
const span = SVG('<span />', true).addClass('bar').addTo(div)
const span2 = SVG('<span />', true).addTo(div)
- expect(find('#canvas').map(el => el.node)).toEqual([ container ])
- expect(find('span')).toEqual([ span, span2 ])
- expect(find('#foo')).toEqual([ div ])
- expect(find('.bar')).toEqual([ span ])
+ expect(find('#canvas').map((el) => el.node)).toEqual([container])
+ expect(find('span')).toEqual([span, span2])
+ expect(find('#foo')).toEqual([div])
+ expect(find('.bar')).toEqual([span])
})
it('finds all elements of a selector scoped to an element', () => {
const div = SVG('<div />', true).id('foo').addTo(container)
expect(find('#canvas', getWindow().document)[0].node).toBe(container)
- expect(find('#foo', container)).toEqual([ div ])
+ expect(find('#foo', container)).toEqual([div])
expect(find('#canvas', div.node)).toEqual([])
})
})
@@ -34,11 +34,11 @@ describe('selector.js', () => {
const g4 = new G().addTo(g2)
const g5 = new G().addTo(g3)
- expect(g1.find('g')).toEqual([ g2, g4, g3, g5 ])
- expect(g2.find('g')).toEqual([ g4 ])
- expect(g1.find('#foo')).toEqual([ g2 ])
+ expect(g1.find('g')).toEqual([g2, g4, g3, g5])
+ expect(g2.find('g')).toEqual([g4])
+ expect(g1.find('#foo')).toEqual([g2])
expect(g2.find('#foo')).toEqual([])
- expect(g1.find('.bar')).toEqual([ g3 ])
+ expect(g1.find('.bar')).toEqual([g3])
})
})
diff --git a/spec/spec/modules/core/textable.js b/spec/spec/modules/core/textable.js
index c0a2100..8135c6a 100644
--- a/spec/spec/modules/core/textable.js
+++ b/spec/spec/modules/core/textable.js
@@ -257,7 +257,10 @@ describe('textable.js', () => {
add.tspan('The second.')
add.tspan('The third.')
})
- expect(text.length()).toBeCloseTo(text.get(0).length() + text.get(1).length() + text.get(2).length(), 3)
+ expect(text.length()).toBeCloseTo(
+ text.get(0).length() + text.get(1).length() + text.get(2).length(),
+ 3
+ )
})
it('gets total length of tspan', () => {
@@ -266,7 +269,10 @@ describe('textable.js', () => {
add.tspan('The second.')
add.tspan('The third.')
})
- expect(tspan.length()).toBeCloseTo(tspan.get(0).length() + tspan.get(1).length() + tspan.get(2).length(), 3)
+ expect(tspan.length()).toBeCloseTo(
+ tspan.get(0).length() + tspan.get(1).length() + tspan.get(2).length(),
+ 3
+ )
})
})
@@ -284,7 +290,9 @@ describe('textable.js', () => {
text.tspan('A great piece!')
text.tspan('Another great piece!')
expect(text.node.childNodes[0].childNodes[0].data).toBe('A great piece!')
- expect(text.node.childNodes[1].childNodes[0].data).toBe('Another great piece!')
+ expect(text.node.childNodes[1].childNodes[0].data).toBe(
+ 'Another great piece!'
+ )
})
it('disables adding multiple plain text nodes when given false for Text', () => {
@@ -299,7 +307,9 @@ describe('textable.js', () => {
text.clear().build(true)
text.tspan('A great piece!')
text.build(false).tspan('Another great piece!')
- expect(text.node.childNodes[0].childNodes[0].data).toBe('Another great piece!')
+ expect(text.node.childNodes[0].childNodes[0].data).toBe(
+ 'Another great piece!'
+ )
expect(text.node.childNodes[1]).toBe(undefined)
})
@@ -316,7 +326,9 @@ describe('textable.js', () => {
tspan.tspan('A great piece!')
tspan.tspan('Another great piece!')
expect(tspan.node.childNodes[0].childNodes[0].data).toBe('A great piece!')
- expect(tspan.node.childNodes[1].childNodes[0].data).toBe('Another great piece!')
+ expect(tspan.node.childNodes[1].childNodes[0].data).toBe(
+ 'Another great piece!'
+ )
})
it('disables adding multiple plain text nodes when given false for Tspan', () => {
@@ -331,9 +343,10 @@ describe('textable.js', () => {
tspan.clear().build(true)
tspan.tspan('A great piece!')
tspan.build(false).tspan('Another great piece!')
- expect(tspan.node.childNodes[0].childNodes[0].data).toBe('Another great piece!')
+ expect(tspan.node.childNodes[0].childNodes[0].data).toBe(
+ 'Another great piece!'
+ )
expect(tspan.node.childNodes[1]).toBe(undefined)
})
})
-
})
diff --git a/spec/spec/modules/optional/arrange.js b/spec/spec/modules/optional/arrange.js
index de1a4a0..c665aa5 100644
--- a/spec/spec/modules/optional/arrange.js
+++ b/spec/spec/modules/optional/arrange.js
@@ -11,7 +11,7 @@ describe('arrange.js', () => {
const circle = g.circle(100)
const line = g.line(1, 2, 3, 4)
- expect(circle.siblings()).toEqual([ rect, circle, line ])
+ expect(circle.siblings()).toEqual([rect, circle, line])
})
})
@@ -77,7 +77,7 @@ describe('arrange.js', () => {
rect.forward()
- expect(g.children()).toEqual([ circle, rect, line ])
+ expect(g.children()).toEqual([circle, rect, line])
})
it('does nothing when the element is already the last one', () => {
@@ -88,7 +88,7 @@ describe('arrange.js', () => {
line.forward()
- expect(g.children()).toEqual([ rect, circle, line ])
+ expect(g.children()).toEqual([rect, circle, line])
})
})
@@ -107,7 +107,7 @@ describe('arrange.js', () => {
line.backward()
- expect(g.children()).toEqual([ rect, line, circle ])
+ expect(g.children()).toEqual([rect, line, circle])
})
it('does nothing when the element is already the first one', () => {
@@ -118,7 +118,7 @@ describe('arrange.js', () => {
rect.backward()
- expect(g.children()).toEqual([ rect, circle, line ])
+ expect(g.children()).toEqual([rect, circle, line])
})
})
@@ -137,7 +137,7 @@ describe('arrange.js', () => {
rect.front()
- expect(g.children()).toEqual([ circle, line, rect ])
+ expect(g.children()).toEqual([circle, line, rect])
})
it('does nothing when the element is already the last one', () => {
@@ -148,7 +148,7 @@ describe('arrange.js', () => {
line.front()
- expect(g.children()).toEqual([ rect, circle, line ])
+ expect(g.children()).toEqual([rect, circle, line])
})
})
@@ -167,7 +167,7 @@ describe('arrange.js', () => {
line.back()
- expect(g.children()).toEqual([ line, rect, circle ])
+ expect(g.children()).toEqual([line, rect, circle])
})
it('does nothing when the element is already the first one', () => {
@@ -178,7 +178,7 @@ describe('arrange.js', () => {
rect.back()
- expect(g.children()).toEqual([ rect, circle, line ])
+ expect(g.children()).toEqual([rect, circle, line])
})
})
@@ -191,7 +191,7 @@ describe('arrange.js', () => {
const line = new Line()
circle.before(line)
- expect(g.children()).toEqual([ rect, line, circle ])
+ expect(g.children()).toEqual([rect, line, circle])
})
})
@@ -204,7 +204,7 @@ describe('arrange.js', () => {
const line = new Line()
rect.after(line)
- expect(g.children()).toEqual([ rect, line, circle ])
+ expect(g.children()).toEqual([rect, line, circle])
})
})
@@ -216,7 +216,7 @@ describe('arrange.js', () => {
const line = new Line().insertBefore(circle)
- expect(g.children()).toEqual([ rect, line, circle ])
+ expect(g.children()).toEqual([rect, line, circle])
})
})
@@ -228,7 +228,7 @@ describe('arrange.js', () => {
const line = new Line().insertAfter(rect)
- expect(g.children()).toEqual([ rect, line, circle ])
+ expect(g.children()).toEqual([rect, line, circle])
})
})
})
diff --git a/spec/spec/modules/optional/class.js b/spec/spec/modules/optional/class.js
index b6bb42b..461c14f 100644
--- a/spec/spec/modules/optional/class.js
+++ b/spec/spec/modules/optional/class.js
@@ -7,7 +7,7 @@ describe('class.js', () => {
describe('classes()', () => {
it('returns all classes on an element', () => {
const rect = new Rect({ class: 'myClass myClass2' })
- expect(rect.classes()).toEqual([ 'myClass', 'myClass2' ])
+ expect(rect.classes()).toEqual(['myClass', 'myClass2'])
})
it('returns an empty array if no class on the element', () => {
@@ -35,13 +35,15 @@ describe('class.js', () => {
})
it('adds a class to the element', () => {
- const rect = new Rect({ class: 'myClass myClass2' }).addClass('myClass3')
- expect(rect.classes()).toEqual([ 'myClass', 'myClass2', 'myClass3' ])
+ const rect = new Rect({ class: 'myClass myClass2' }).addClass(
+ 'myClass3'
+ )
+ expect(rect.classes()).toEqual(['myClass', 'myClass2', 'myClass3'])
})
it('does nothing if class already present on the element', () => {
const rect = new Rect({ class: 'myClass myClass2' }).addClass('myClass')
- expect(rect.classes()).toEqual([ 'myClass', 'myClass2' ])
+ expect(rect.classes()).toEqual(['myClass', 'myClass2'])
})
})
@@ -52,13 +54,17 @@ describe('class.js', () => {
})
it('removes a class from the element', () => {
- const rect = new Rect({ class: 'myClass myClass2' }).removeClass('myClass2')
- expect(rect.classes()).toEqual([ 'myClass' ])
+ const rect = new Rect({ class: 'myClass myClass2' }).removeClass(
+ 'myClass2'
+ )
+ expect(rect.classes()).toEqual(['myClass'])
})
it('does nothing if class is not present on the element', () => {
- const rect = new Rect({ class: 'myClass myClass2' }).removeClass('myClass3')
- expect(rect.classes()).toEqual([ 'myClass', 'myClass2' ])
+ const rect = new Rect({ class: 'myClass myClass2' }).removeClass(
+ 'myClass3'
+ )
+ expect(rect.classes()).toEqual(['myClass', 'myClass2'])
})
})
@@ -69,13 +75,17 @@ describe('class.js', () => {
})
it('removes a class from the element when its present', () => {
- const rect = new Rect({ class: 'myClass myClass2' }).toggleClass('myClass2')
- expect(rect.classes()).toEqual([ 'myClass' ])
+ const rect = new Rect({ class: 'myClass myClass2' }).toggleClass(
+ 'myClass2'
+ )
+ expect(rect.classes()).toEqual(['myClass'])
})
it('adds a class to the element if its not present', () => {
- const rect = new Rect({ class: 'myClass myClass2' }).toggleClass('myClass3')
- expect(rect.classes()).toEqual([ 'myClass', 'myClass2', 'myClass3' ])
+ const rect = new Rect({ class: 'myClass myClass2' }).toggleClass(
+ 'myClass3'
+ )
+ expect(rect.classes()).toEqual(['myClass', 'myClass2', 'myClass3'])
})
})
})
diff --git a/spec/spec/modules/optional/css.js b/spec/spec/modules/optional/css.js
index b6c04bc..8a42acf 100644
--- a/spec/spec/modules/optional/css.js
+++ b/spec/spec/modules/optional/css.js
@@ -7,7 +7,9 @@ describe('css.js', () => {
describe('css()', () => {
describe('as getter', () => {
it('returns all css as object', () => {
- const rect = new Rect({ style: 'fill: none; outline-width: 1px; stroke: none' })
+ const rect = new Rect({
+ style: 'fill: none; outline-width: 1px; stroke: none'
+ })
expect(rect.css()).toEqual({
fill: 'none',
'outline-width': '1px',
@@ -16,57 +18,80 @@ describe('css.js', () => {
})
it('returns an object with selected css properties', () => {
- const rect = new Rect({ style: 'fill: none; outline-width: 1px; stroke: none' })
- expect(rect.css([ 'fill', 'stroke' ])).toEqual({
+ const rect = new Rect({
+ style: 'fill: none; outline-width: 1px; stroke: none'
+ })
+ expect(rect.css(['fill', 'stroke'])).toEqual({
fill: 'none',
stroke: 'none'
})
})
it('returns a single property with property name given', () => {
- const rect = new Rect({ style: 'fill: none; outline-width: 1px; stroke: none' })
+ const rect = new Rect({
+ style: 'fill: none; outline-width: 1px; stroke: none'
+ })
expect(rect.css('fill')).toBe('none')
})
it('returns undefined if css property is not set', () => {
- const rect = new Rect({ style: 'fill: none; outline-width: 1px; stroke: none' })
+ const rect = new Rect({
+ style: 'fill: none; outline-width: 1px; stroke: none'
+ })
expect(rect.css('outline-color')).toBe('')
})
})
describe('as setter', () => {
it('returns itself', () => {
- const rect = new Rect({ style: 'fill: none; outline-width: 1px; stroke: none' })
+ const rect = new Rect({
+ style: 'fill: none; outline-width: 1px; stroke: none'
+ })
expect(rect.css('fill', 'black')).toBe(rect)
})
it('adds a css property', () => {
- const rect = new Rect({ style: 'fill: none; outline-width: 1px; stroke: none' })
- expect(rect.css('stroke-width', '2px').css('stroke-width')).toBe('2px')
+ const rect = new Rect({
+ style: 'fill: none; outline-width: 1px; stroke: none'
+ })
+ expect(rect.css('stroke-width', '2px').css('stroke-width')).toBe(
+ '2px'
+ )
})
it('changes a css property', () => {
- const rect = new Rect({ style: 'fill: none; outline-width: 1px; stroke: none' })
+ const rect = new Rect({
+ style: 'fill: none; outline-width: 1px; stroke: none'
+ })
expect(rect.css('fill', 'black').css('fill')).toBe('black')
})
it('sets an object of properties', () => {
const rect = new Rect()
- expect(rect.css({ fill: 'none', stroke: 'none' }).css()).toEqual({ fill: 'none', stroke: 'none' })
+ expect(rect.css({ fill: 'none', stroke: 'none' }).css()).toEqual({
+ fill: 'none',
+ stroke: 'none'
+ })
})
it('removes property if empty string is passed as value', () => {
- const rect = new Rect({ style: 'fill: none; outline-width: 1px; stroke: none' })
+ const rect = new Rect({
+ style: 'fill: none; outline-width: 1px; stroke: none'
+ })
expect(rect.css('fill', '').css('fill')).toBe('')
})
it('removes property if null is passed as value', () => {
- const rect = new Rect({ style: 'fill: none; outline-width: 1px; stroke: none' })
+ const rect = new Rect({
+ style: 'fill: none; outline-width: 1px; stroke: none'
+ })
expect(rect.css('fill', null).css('fill')).toBe('')
})
it('removes property if null is passed as part of object', () => {
- const rect = new Rect({ style: 'fill: none; outline-width: 1px; stroke: none' })
+ const rect = new Rect({
+ style: 'fill: none; outline-width: 1px; stroke: none'
+ })
expect(rect.css({ fill: null, stroke: 'black' }).css('fill')).toBe('')
})
})
diff --git a/spec/spec/modules/optional/data.js b/spec/spec/modules/optional/data.js
index 211fef3..5265dd1 100644
--- a/spec/spec/modules/optional/data.js
+++ b/spec/spec/modules/optional/data.js
@@ -7,7 +7,11 @@ describe('data.js', () => {
describe('data()', () => {
describe('as getter', () => {
it('returns all data as object', () => {
- const rect = new Rect({ 'data-fill': 'none', 'data-outline-width': '1px', 'data-stroke': 'none' })
+ const rect = new Rect({
+ 'data-fill': 'none',
+ 'data-outline-width': '1px',
+ 'data-stroke': 'none'
+ })
expect(rect.data()).toEqual({
fill: 'none',
'outline-width': '1px',
@@ -16,65 +20,108 @@ describe('data.js', () => {
})
it('returns an object with selected data properties', () => {
- const rect = new Rect({ 'data-fill': 'none', 'data-outline-width': '1px', 'data-stroke': 'none' })
- expect(rect.data([ 'fill', 'stroke' ])).toEqual({
+ const rect = new Rect({
+ 'data-fill': 'none',
+ 'data-outline-width': '1px',
+ 'data-stroke': 'none'
+ })
+ expect(rect.data(['fill', 'stroke'])).toEqual({
fill: 'none',
stroke: 'none'
})
})
it('returns a single property with property name given', () => {
- const rect = new Rect({ 'data-fill': 'none', 'data-outline-width': '1px', 'data-stroke': 'none' })
+ const rect = new Rect({
+ 'data-fill': 'none',
+ 'data-outline-width': '1px',
+ 'data-stroke': 'none'
+ })
expect(rect.data('fill')).toBe('none')
})
it('returns undefined if data property is not set', () => {
- const rect = new Rect({ 'data-fill': 'none', 'data-outline-width': '1px', 'data-stroke': 'none' })
+ const rect = new Rect({
+ 'data-fill': 'none',
+ 'data-outline-width': '1px',
+ 'data-stroke': 'none'
+ })
expect(rect.data('outline-color')).toBe(undefined)
})
})
describe('as setter', () => {
it('returns itself', () => {
- const rect = new Rect({ 'data-fill': 'none', 'data-outline-width': '1px', 'data-stroke': 'none' })
+ const rect = new Rect({
+ 'data-fill': 'none',
+ 'data-outline-width': '1px',
+ 'data-stroke': 'none'
+ })
expect(rect.data('fill', 'black')).toBe(rect)
})
it('adds a data property', () => {
- const rect = new Rect({ 'data-fill': 'none', 'data-outline-width': '1px', 'data-stroke': 'none' })
- expect(rect.data('stroke-width', '2px').data('stroke-width')).toBe('2px')
+ const rect = new Rect({
+ 'data-fill': 'none',
+ 'data-outline-width': '1px',
+ 'data-stroke': 'none'
+ })
+ expect(rect.data('stroke-width', '2px').data('stroke-width')).toBe(
+ '2px'
+ )
})
it('changes a data property', () => {
- const rect = new Rect({ 'data-fill': 'none', 'data-outline-width': '1px', 'data-stroke': 'none' })
+ const rect = new Rect({
+ 'data-fill': 'none',
+ 'data-outline-width': '1px',
+ 'data-stroke': 'none'
+ })
expect(rect.data('fill', 'black').data('fill')).toBe('black')
})
it('sets an object of properties', () => {
const rect = new Rect()
- expect(rect.data({ fill: 'none', stroke: 'none' }).data()).toEqual({ fill: 'none', stroke: 'none' })
+ expect(rect.data({ fill: 'none', stroke: 'none' }).data()).toEqual({
+ fill: 'none',
+ stroke: 'none'
+ })
})
it('removes property if null is passed as value', () => {
- const rect = new Rect({ 'data-fill': 'none', 'data-outline-width': '1px', 'data-stroke': 'none' })
+ const rect = new Rect({
+ 'data-fill': 'none',
+ 'data-outline-width': '1px',
+ 'data-stroke': 'none'
+ })
expect(rect.data('fill', null).data('fill')).toBe(undefined)
})
it('removes property if null is passed as part of object', () => {
- const rect = new Rect({ 'data-fill': 'none', 'data-outline-width': '1px', 'data-stroke': 'none' })
- expect(rect.data({ fill: null, stroke: 'black' }).data('fill')).toBe(undefined)
+ const rect = new Rect({
+ 'data-fill': 'none',
+ 'data-outline-width': '1px',
+ 'data-stroke': 'none'
+ })
+ expect(rect.data({ fill: null, stroke: 'black' }).data('fill')).toBe(
+ undefined
+ )
})
it('converts everything except number and strings to JSON', () => {
const rect = new Rect()
- expect(rect.data('fill', { some: 'object' }).attr('data-fill')).toBe(JSON.stringify({ some: 'object' }))
+ expect(rect.data('fill', { some: 'object' }).attr('data-fill')).toBe(
+ JSON.stringify({ some: 'object' })
+ )
expect(rect.data('fill', 5).attr('data-fill')).toBe(5)
expect(rect.data('fill', 'string').attr('data-fill')).toBe('string')
})
it('does not convert to json with third parameter true', () => {
const rect = new Rect()
- expect(rect.data('fill', { some: 'object' }, true).attr('data-fill')).toBe({}.toString())
+ expect(
+ rect.data('fill', { some: 'object' }, true).attr('data-fill')
+ ).toBe({}.toString())
})
})
})
diff --git a/spec/spec/modules/optional/memory.js b/spec/spec/modules/optional/memory.js
index 3199456..7472078 100644
--- a/spec/spec/modules/optional/memory.js
+++ b/spec/spec/modules/optional/memory.js
@@ -6,7 +6,11 @@ describe('memory.js', () => {
describe('Dom', () => {
describe('memory()', () => {
it('returns all memory as object', () => {
- const rect = new Rect().remember({ fill: 'none', 'outline-width': '1px', stroke: 'none' })
+ const rect = new Rect().remember({
+ fill: 'none',
+ 'outline-width': '1px',
+ stroke: 'none'
+ })
expect(rect.memory()).toEqual({
fill: 'none',
'outline-width': '1px',
@@ -18,52 +22,90 @@ describe('memory.js', () => {
describe('remember()', () => {
describe('as getter', () => {
it('returns a single property with property name given', () => {
- const rect = new Rect().remember({ fill: 'none', 'outline-width': '1px', stroke: 'none' })
+ const rect = new Rect().remember({
+ fill: 'none',
+ 'outline-width': '1px',
+ stroke: 'none'
+ })
expect(rect.remember('fill')).toBe('none')
})
it('returns undefined if memory property is not set', () => {
- const rect = new Rect().remember({ fill: 'none', 'outline-width': '1px', stroke: 'none' })
+ const rect = new Rect().remember({
+ fill: 'none',
+ 'outline-width': '1px',
+ stroke: 'none'
+ })
expect(rect.remember('outline-color')).toBe(undefined)
})
})
describe('as setter', () => {
it('returns itself', () => {
- const rect = new Rect().remember({ fill: 'none', 'outline-width': '1px', stroke: 'none' })
+ const rect = new Rect().remember({
+ fill: 'none',
+ 'outline-width': '1px',
+ stroke: 'none'
+ })
expect(rect.remember('fill', 'black')).toBe(rect)
})
it('adds a memory property', () => {
- const rect = new Rect().remember({ fill: 'none', 'outline-width': '1px', stroke: 'none' })
- expect(rect.remember('stroke-width', '2px').remember('stroke-width')).toBe('2px')
+ const rect = new Rect().remember({
+ fill: 'none',
+ 'outline-width': '1px',
+ stroke: 'none'
+ })
+ expect(
+ rect.remember('stroke-width', '2px').remember('stroke-width')
+ ).toBe('2px')
})
it('changes a memory property', () => {
- const rect = new Rect().remember({ fill: 'none', 'outline-width': '1px', stroke: 'none' })
+ const rect = new Rect().remember({
+ fill: 'none',
+ 'outline-width': '1px',
+ stroke: 'none'
+ })
expect(rect.remember('fill', 'black').remember('fill')).toBe('black')
})
it('sets an object of properties', () => {
const rect = new Rect()
- expect(rect.remember({ fill: 'none', stroke: 'none' }).memory()).toEqual({ fill: 'none', stroke: 'none' })
+ expect(
+ rect.remember({ fill: 'none', stroke: 'none' }).memory()
+ ).toEqual({ fill: 'none', stroke: 'none' })
})
})
})
describe('forget()', () => {
it('removes property', () => {
- const rect = new Rect().remember({ fill: 'none', 'outline-width': '1px', stroke: 'none' })
+ const rect = new Rect().remember({
+ fill: 'none',
+ 'outline-width': '1px',
+ stroke: 'none'
+ })
expect(rect.forget('fill').remember('fill')).toBe(undefined)
})
it('removes multiple properties', () => {
- const rect = new Rect().remember({ fill: 'none', 'outline-width': '1px', stroke: 'none' })
- expect(rect.forget('fill', 'stroke').memory()).toEqual({ 'outline-width': '1px' })
+ const rect = new Rect().remember({
+ fill: 'none',
+ 'outline-width': '1px',
+ stroke: 'none'
+ })
+ expect(rect.forget('fill', 'stroke').memory()).toEqual({
+ 'outline-width': '1px'
+ })
})
it('erases the whole object with nothing passed', () => {
- const rect = new Rect().remember({ fill: 'none', 'outline-width': '1px', stroke: 'none' })
+ const rect = new Rect().remember({
+ fill: 'none',
+ 'outline-width': '1px',
+ stroke: 'none'
+ })
expect(rect.forget().memory()).toEqual({})
})
})
diff --git a/spec/spec/modules/optional/sugar.js b/spec/spec/modules/optional/sugar.js
index 84c95b0..74cef62 100644
--- a/spec/spec/modules/optional/sugar.js
+++ b/spec/spec/modules/optional/sugar.js
@@ -32,15 +32,18 @@ describe('sugar.js', () => {
it('sets an object of fill properties', () => {
const rect = new Rect()
- expect(rect.fill({
- color: 'black',
- opacity: 0.5,
- rule: 'even-odd'
- }).attr()).toEqual({
+ expect(
+ rect
+ .fill({
+ color: 'black',
+ opacity: 0.5,
+ rule: 'even-odd'
+ })
+ .attr()
+ ).toEqual({
fill: 'black',
'fill-opacity': 0.5,
- 'fill-rule':
- 'even-odd'
+ 'fill-rule': 'even-odd'
})
})
})
@@ -86,16 +89,20 @@ describe('sugar.js', () => {
it('sets an object of stroke properties', () => {
const rect = new Rect()
- expect(rect.stroke({
- color: 'black',
- width: 2,
- opacity: 0.5,
- linecap: 'butt',
- linejoin: 'miter',
- miterlimit: 10,
- dasharray: '2 2',
- dashoffset: 15
- }).attr()).toEqual({
+ expect(
+ rect
+ .stroke({
+ color: 'black',
+ width: 2,
+ opacity: 0.5,
+ linecap: 'butt',
+ linejoin: 'miter',
+ miterlimit: 10,
+ dasharray: '2 2',
+ dashoffset: 15
+ })
+ .attr()
+ ).toEqual({
stroke: 'black',
'stroke-width': 2,
'stroke-opacity': 0.5,
@@ -108,7 +115,7 @@ describe('sugar.js', () => {
})
it('sets stroke dasharray with array passed', () => {
- const rect = new Rect().stroke({ dasharray: [ 2, 2 ] })
+ const rect = new Rect().stroke({ dasharray: [2, 2] })
expect(rect.attr()).toEqual({ 'stroke-dasharray': '2 2' })
})
})
@@ -157,21 +164,30 @@ describe('sugar.js', () => {
const rect = new Rect()
const spy = spyOn(rect, 'transform')
rect.skew()
- expect(spy).toHaveBeenCalledWith({ skew: [ undefined, undefined ], ox: undefined, oy: undefined }, true)
+ expect(spy).toHaveBeenCalledWith(
+ { skew: [undefined, undefined], ox: undefined, oy: undefined },
+ true
+ )
})
it('redirects to transform() with one argument', function () {
const rect = new Rect()
const spy = spyOn(rect, 'transform')
rect.skew(5)
- expect(spy).toHaveBeenCalledWith({ skew: 5, ox: undefined, oy: undefined }, true)
+ expect(spy).toHaveBeenCalledWith(
+ { skew: 5, ox: undefined, oy: undefined },
+ true
+ )
})
it('redirects to transform() with two argument', function () {
const rect = new Rect()
const spy = spyOn(rect, 'transform')
rect.skew(5, 6)
- expect(spy).toHaveBeenCalledWith({ skew: [ 5, 6 ], ox: undefined, oy: undefined }, true)
+ expect(spy).toHaveBeenCalledWith(
+ { skew: [5, 6], ox: undefined, oy: undefined },
+ true
+ )
})
it('redirects to transform() with three arguments', function () {
@@ -185,7 +201,7 @@ describe('sugar.js', () => {
const rect = new Rect()
const spy = spyOn(rect, 'transform')
rect.skew(5, 6, 7, 8)
- expect(spy).toHaveBeenCalledWith({ skew: [ 5, 6 ], ox: 7, oy: 8 }, true)
+ expect(spy).toHaveBeenCalledWith({ skew: [5, 6], ox: 7, oy: 8 }, true)
})
})
@@ -203,21 +219,30 @@ describe('sugar.js', () => {
const rect = new Rect()
const spy = spyOn(rect, 'transform')
rect.scale()
- expect(spy).toHaveBeenCalledWith({ scale: [ undefined, undefined ], ox: undefined, oy: undefined }, true)
+ expect(spy).toHaveBeenCalledWith(
+ { scale: [undefined, undefined], ox: undefined, oy: undefined },
+ true
+ )
})
it('redirects to transform() with one argument', function () {
const rect = new Rect()
const spy = spyOn(rect, 'transform')
rect.scale(5)
- expect(spy).toHaveBeenCalledWith({ scale: 5, ox: undefined, oy: undefined }, true)
+ expect(spy).toHaveBeenCalledWith(
+ { scale: 5, ox: undefined, oy: undefined },
+ true
+ )
})
it('redirects to transform() with two argument', function () {
const rect = new Rect()
const spy = spyOn(rect, 'transform')
rect.scale(5, 6)
- expect(spy).toHaveBeenCalledWith({ scale: [ 5, 6 ], ox: undefined, oy: undefined }, true)
+ expect(spy).toHaveBeenCalledWith(
+ { scale: [5, 6], ox: undefined, oy: undefined },
+ true
+ )
})
it('redirects to transform() with three arguments', function () {
@@ -231,7 +256,7 @@ describe('sugar.js', () => {
const rect = new Rect()
const spy = spyOn(rect, 'transform')
rect.scale(5, 6, 7, 8)
- expect(spy).toHaveBeenCalledWith({ scale: [ 5, 6 ], ox: 7, oy: 8 }, true)
+ expect(spy).toHaveBeenCalledWith({ scale: [5, 6], ox: 7, oy: 8 }, true)
})
})
@@ -240,7 +265,7 @@ describe('sugar.js', () => {
const rect = new Rect()
const spy = spyOn(rect, 'transform')
rect.translate(1, 2)
- expect(spy).toHaveBeenCalledWith({ translate: [ 1, 2 ] }, true)
+ expect(spy).toHaveBeenCalledWith({ translate: [1, 2] }, true)
})
})
@@ -249,7 +274,7 @@ describe('sugar.js', () => {
const rect = new Rect()
const spy = spyOn(rect, 'transform')
rect.relative(1, 2)
- expect(spy).toHaveBeenCalledWith({ relative: [ 1, 2 ] }, true)
+ expect(spy).toHaveBeenCalledWith({ relative: [1, 2] }, true)
})
})
@@ -265,7 +290,10 @@ describe('sugar.js', () => {
const rect = new Rect()
const spy = spyOn(rect, 'transform')
rect.flip()
- expect(spy).toHaveBeenCalledWith({ flip: 'both', origin: 'center' }, true)
+ expect(spy).toHaveBeenCalledWith(
+ { flip: 'both', origin: 'center' },
+ true
+ )
})
// this works because only x and y are valid flip values. Everything else flips on both axis
@@ -347,7 +375,6 @@ describe('sugar.js', () => {
expect(spy).toHaveBeenCalledWith('font-size', undefined)
})
})
-
})
describe('radius()', () => {
@@ -395,7 +422,8 @@ describe('sugar.js', () => {
})
describe('events', () => {
- [ 'click',
+ ;[
+ 'click',
'dblclick',
'mousedown',
'mouseup',
@@ -408,7 +436,8 @@ describe('sugar.js', () => {
'touchmove',
'touchleave',
'touchend',
- 'touchcancel' ].forEach(ev => {
+ 'touchcancel'
+ ].forEach((ev) => {
describe(ev, () => {
it('calls on() with the eventname set to ' + ev, () => {
const rect = new Rect()
@@ -418,12 +447,17 @@ describe('sugar.js', () => {
expect(spy).toHaveBeenCalledWith(ev, fn)
})
- it('calls off() with the eventname set to ' + ev + ' when null is passed as second argument', () => {
- const rect = new Rect()
- const spy = spyOn(rect, 'off')
- rect[ev](null)
- expect(spy).toHaveBeenCalledWith(ev)
- })
+ it(
+ 'calls off() with the eventname set to ' +
+ ev +
+ ' when null is passed as second argument',
+ () => {
+ const rect = new Rect()
+ const spy = spyOn(rect, 'off')
+ rect[ev](null)
+ expect(spy).toHaveBeenCalledWith(ev)
+ }
+ )
})
})
})
diff --git a/spec/spec/modules/optional/transform.js b/spec/spec/modules/optional/transform.js
index db59784..41d403c 100644
--- a/spec/spec/modules/optional/transform.js
+++ b/spec/spec/modules/optional/transform.js
@@ -23,12 +23,19 @@ describe('transform.js', () => {
it('reduces all transformations of the transform list into one matrix - 2', () => {
const rect = new Rect().attr('transform', 'translate(10, 20) rotate(45)')
- expect(rect.matrixify()).toEqual(new Matrix().rotate(45).translate(10, 20))
+ expect(rect.matrixify()).toEqual(
+ new Matrix().rotate(45).translate(10, 20)
+ )
})
it('reduces all transformations of the transform list into one matrix - 3', () => {
- const rect = new Rect().attr('transform', 'translate(10, 20) rotate(45) skew(1,2) skewX(10) skewY(20)')
- expect(rect.matrixify()).toEqual(new Matrix().skewY(20).skewX(10).skew(1, 2).rotate(45).translate(10, 20))
+ const rect = new Rect().attr(
+ 'transform',
+ 'translate(10, 20) rotate(45) skew(1,2) skewX(10) skewY(20)'
+ )
+ expect(rect.matrixify()).toEqual(
+ new Matrix().skewY(20).skewX(10).skew(1, 2).rotate(45).translate(10, 20)
+ )
})
})
@@ -69,7 +76,9 @@ describe('transform.js', () => {
const expected = new Matrix().translate(10, 20).rotate(-10)
// funny enough the dom seems to shorten the floats and precision gets lost
- ;[ ...'abcdef' ].forEach(prop => expect(actual[prop]).toBeCloseTo(expected[prop], 5))
+ ;[...'abcdef'].forEach((prop) =>
+ expect(actual[prop]).toBeCloseTo(expected[prop], 5)
+ )
})
it('inserts the element at the specified position', () => {
@@ -110,21 +119,25 @@ describe('transform.js', () => {
})
it('sets the transformation with an object', () => {
- const rect = new Rect().transform({ rotate: 45, translate: [ 10, 20 ] })
+ const rect = new Rect().transform({ rotate: 45, translate: [10, 20] })
expect(rect.transform('rotate')).toBe(45)
expect(rect.transform('translateX')).toBe(10)
expect(rect.transform('translateY')).toBe(20)
})
it('performs a relative transformation with flag=true', () => {
- const rect = new Rect().transform({ rotate: 45, translate: [ 10, 20 ] }).transform({ rotate: 10 }, true)
+ const rect = new Rect()
+ .transform({ rotate: 45, translate: [10, 20] })
+ .transform({ rotate: 10 }, true)
expect(rect.transform('rotate')).toBeCloseTo(55, 5) // rounding errors
expect(rect.transform('translateX')).toBe(10)
expect(rect.transform('translateY')).toBe(20)
})
it('performs a relative transformation with flag=other matrix', () => {
- const rect = new Rect().transform({ rotate: 45, translate: [ 10, 20 ] }).transform({ rotate: 10 }, new Matrix().rotate(30))
+ const rect = new Rect()
+ .transform({ rotate: 45, translate: [10, 20] })
+ .transform({ rotate: 10 }, new Matrix().rotate(30))
expect(rect.transform('rotate')).toBeCloseTo(40, 5) // rounding errors
expect(rect.transform('translateX')).toBe(0)
expect(rect.transform('translateY')).toBe(0)
@@ -132,7 +145,9 @@ describe('transform.js', () => {
it('performs a relative transformation with flag=other element', () => {
const referenceElement = new Rect().transform({ rotate: 30 })
- const rect = new Rect().transform({ rotate: 45, translate: [ 10, 20 ] }).transform({ rotate: 10 }, referenceElement)
+ const rect = new Rect()
+ .transform({ rotate: 45, translate: [10, 20] })
+ .transform({ rotate: 10 }, referenceElement)
expect(rect.transform('rotate')).toBeCloseTo(40, 5) // rounding errors
expect(rect.transform('translateX')).toBe(0)
expect(rect.transform('translateY')).toBe(0)
diff --git a/spec/spec/types/Box.js b/spec/spec/types/Box.js
index e220cea..e0f13e1 100644
--- a/spec/spec/types/Box.js
+++ b/spec/spec/types/Box.js
@@ -1,12 +1,6 @@
/* globals describe, expect, it, beforeEach, afterEach, spyOn, jasmine, container */
-import {
- Box,
- Matrix,
- Rect,
- G,
- makeInstance as SVG
-} from '../../../src/main.js'
+import { Box, Matrix, Rect, G, makeInstance as SVG } from '../../../src/main.js'
import { withWindow, getWindow } from '../../../src/utils/window.js'
import { isNulledBox, domContains } from '../../../src/types/Box.js'
@@ -70,48 +64,69 @@ describe('Box.js', () => {
it('creates a new Box with default attributes', () => {
const box = new Box()
expect(box).toEqual(any(Box))
- expect(box).toEqual(objectContaining({
- width: 0, height: 0, x: 0, y: 0, w: 0, h: 0, cx: 0, cy: 0, x2: 0, y2: 0
- }))
+ expect(box).toEqual(
+ objectContaining({
+ width: 0,
+ height: 0,
+ x: 0,
+ y: 0,
+ w: 0,
+ h: 0,
+ cx: 0,
+ cy: 0,
+ x2: 0,
+ y2: 0
+ })
+ )
})
})
describe('init()', () => {
it('inits or reinits the box according to input', () => {
- expect(new Box().init(1, 2, 3, 4).toArray()).toEqual([ 1, 2, 3, 4 ])
+ expect(new Box().init(1, 2, 3, 4).toArray()).toEqual([1, 2, 3, 4])
})
it('works with array input', () => {
- expect(new Box().init([ 1, 2, 3, 4 ]).toArray()).toEqual([ 1, 2, 3, 4 ])
+ expect(new Box().init([1, 2, 3, 4]).toArray()).toEqual([1, 2, 3, 4])
})
it('works with 3 arguments as input', () => {
- expect(new Box().init(1, 2, 3, 4).toArray()).toEqual([ 1, 2, 3, 4 ])
+ expect(new Box().init(1, 2, 3, 4).toArray()).toEqual([1, 2, 3, 4])
})
it('works with string input', () => {
- expect(new Box().init('1,2,3,4').toArray()).toEqual([ 1, 2, 3, 4 ])
+ expect(new Box().init('1,2,3,4').toArray()).toEqual([1, 2, 3, 4])
})
it('creates a new box from parsed string with exponential values', function () {
- expect(new Box().init('-1.12e1 1e-2 +2e2 +.3e+4').toArray())
- .toEqual([ -11.2, 0.01, 200, 3000 ])
+ expect(new Box().init('-1.12e1 1e-2 +2e2 +.3e+4').toArray()).toEqual([
+ -11.2, 0.01, 200, 3000
+ ])
})
it('works with object input', () => {
- expect(new Box().init({ x: 1, y: 2, width: 3, height: 4 }).toArray())
- .toEqual([ 1, 2, 3, 4 ])
+ expect(
+ new Box().init({ x: 1, y: 2, width: 3, height: 4 }).toArray()
+ ).toEqual([1, 2, 3, 4])
})
it('calculates all derived values correctly', () => {
- expect(new Box().init(2, 4, 6, 8)).toEqual(objectContaining({
- cx: 5, cy: 8, x2: 8, y2: 12, w: 6, h: 8
- }))
+ expect(new Box().init(2, 4, 6, 8)).toEqual(
+ objectContaining({
+ cx: 5,
+ cy: 8,
+ x2: 8,
+ y2: 12,
+ w: 6,
+ h: 8
+ })
+ )
})
it('can handle input with left instead of x and top instead of y', () => {
- expect(new Box().init({ left: 1, top: 2, width: 3, height: 4 }).toArray())
- .toEqual([ 1, 2, 3, 4 ])
+ expect(
+ new Box().init({ left: 1, top: 2, width: 3, height: 4 }).toArray()
+ ).toEqual([1, 2, 3, 4])
})
})
@@ -122,7 +137,7 @@ describe('Box.js', () => {
var box3 = new Box(500, 100, 100, 100)
var merged = box1.merge(box2).merge(box3)
- expect(merged.toArray()).toEqual([ 50, 50, 550, 450 ])
+ expect(merged.toArray()).toEqual([50, 50, 550, 450])
})
it('returns a new instance', () => {
@@ -136,23 +151,35 @@ describe('Box.js', () => {
describe('transform()', () => {
it('transforms the box with given matrix', () => {
- var box1 = new Box(50, 50, 100, 100).transform(new Matrix(1, 0, 0, 1, 20, 20))
- var box2 = new Box(50, 50, 100, 100).transform(new Matrix(2, 0, 0, 2, 0, 0))
- var box3 = new Box(-200, -200, 100, 100).transform(new Matrix(1, 0, 0, 1, -20, -20))
+ var box1 = new Box(50, 50, 100, 100).transform(
+ new Matrix(1, 0, 0, 1, 20, 20)
+ )
+ var box2 = new Box(50, 50, 100, 100).transform(
+ new Matrix(2, 0, 0, 2, 0, 0)
+ )
+ var box3 = new Box(-200, -200, 100, 100).transform(
+ new Matrix(1, 0, 0, 1, -20, -20)
+ )
- expect(box1.toArray()).toEqual([ 70, 70, 100, 100 ])
- expect(box2.toArray()).toEqual([ 100, 100, 200, 200 ])
- expect(box3.toArray()).toEqual([ -220, -220, 100, 100 ])
+ expect(box1.toArray()).toEqual([70, 70, 100, 100])
+ expect(box2.toArray()).toEqual([100, 100, 200, 200])
+ expect(box3.toArray()).toEqual([-220, -220, 100, 100])
})
it('also works with matrix like input', () => {
- var box1 = new Box(50, 50, 100, 100).transform(new Matrix(1, 0, 0, 1, 20, 20).toArray())
- var box2 = new Box(50, 50, 100, 100).transform(new Matrix(2, 0, 0, 2, 0, 0).toArray())
- var box3 = new Box(-200, -200, 100, 100).transform(new Matrix(1, 0, 0, 1, -20, -20).toArray())
-
- expect(box1.toArray()).toEqual([ 70, 70, 100, 100 ])
- expect(box2.toArray()).toEqual([ 100, 100, 200, 200 ])
- expect(box3.toArray()).toEqual([ -220, -220, 100, 100 ])
+ var box1 = new Box(50, 50, 100, 100).transform(
+ new Matrix(1, 0, 0, 1, 20, 20).toArray()
+ )
+ var box2 = new Box(50, 50, 100, 100).transform(
+ new Matrix(2, 0, 0, 2, 0, 0).toArray()
+ )
+ var box3 = new Box(-200, -200, 100, 100).transform(
+ new Matrix(1, 0, 0, 1, -20, -20).toArray()
+ )
+
+ expect(box1.toArray()).toEqual([70, 70, 100, 100])
+ expect(box2.toArray()).toEqual([100, 100, 200, 200])
+ expect(box3.toArray()).toEqual([-220, -220, 100, 100])
})
})
@@ -171,7 +198,7 @@ describe('Box.js', () => {
withWindow({ pageXOffset: 50, pageYOffset: 25 }, () => {
const box = new Box(100, 100, 100, 100).addOffset()
- expect(box.toArray()).toEqual([ 150, 125, 100, 100 ])
+ expect(box.toArray()).toEqual([150, 125, 100, 100])
})
})
})
@@ -184,7 +211,7 @@ describe('Box.js', () => {
describe('toArray()', () => {
it('returns an array representation of the box', () => {
- expect(new Box(1, 2, 3, 4).toArray()).toEqual([ 1, 2, 3, 4 ])
+ expect(new Box(1, 2, 3, 4).toArray()).toEqual([1, 2, 3, 4])
})
})
@@ -203,17 +230,21 @@ describe('Box.js', () => {
const rect = new Rect().size(100, 200).move(20, 30).addTo(canvas)
expect(rect.bbox()).toEqual(any(Box))
- expect(rect.bbox().toArray()).toEqual([ 20, 30, 100, 200 ])
+ expect(rect.bbox().toArray()).toEqual([20, 30, 100, 200])
})
it('returns the bounding box of the element even if the node is not in the dom', () => {
const rect = new Rect().size(100, 200).move(20, 30)
- expect(rect.bbox().toArray()).toEqual([ 20, 30, 100, 200 ])
+ expect(rect.bbox().toArray()).toEqual([20, 30, 100, 200])
})
it('throws when it is not possible to get a bbox', () => {
- const spy = spyOn(getWindow().SVGGraphicsElement.prototype, 'getBBox')
- .and.callFake(() => { throw new Error('No BBox for you') })
+ const spy = spyOn(
+ getWindow().SVGGraphicsElement.prototype,
+ 'getBBox'
+ ).and.callFake(() => {
+ throw new Error('No BBox for you')
+ })
const rect = new Rect()
expect(() => rect.bbox()).toThrow()
expect(spy).toHaveBeenCalled()
@@ -223,21 +254,27 @@ describe('Box.js', () => {
describe('rbox()', () => {
it('returns the BoundingClientRect of the element', () => {
const canvas = SVG().addTo(container)
- const rect = new Rect().size(100, 200).move(20, 30).addTo(canvas)
- .attr('transform', new Matrix({ scale: 2, translate: [ 40, 50 ] }))
+ const rect = new Rect()
+ .size(100, 200)
+ .move(20, 30)
+ .addTo(canvas)
+ .attr('transform', new Matrix({ scale: 2, translate: [40, 50] }))
expect(rect.rbox()).toEqual(any(Box))
- expect(rect.rbox().toArray()).toEqual([ 80, 110, 200, 400 ])
+ expect(rect.rbox().toArray()).toEqual([80, 110, 200, 400])
})
it('returns the rbox box of the element in the coordinate system of the passed element', () => {
const canvas = SVG().addTo(container)
const group = canvas.group().translate(1, 1)
- const rect = new Rect().size(100, 200).move(20, 30).addTo(canvas)
- .attr('transform', new Matrix({ scale: 2, translate: [ 40, 50 ] }))
+ const rect = new Rect()
+ .size(100, 200)
+ .move(20, 30)
+ .addTo(canvas)
+ .attr('transform', new Matrix({ scale: 2, translate: [40, 50] }))
expect(rect.rbox(group)).toEqual(any(Box))
- expect(rect.rbox(group).toArray()).toEqual([ 79, 109, 200, 400 ])
+ expect(rect.rbox(group).toArray()).toEqual([79, 109, 200, 400])
})
// svgdom actually only throws here because a new Rect without dimensions has no bounding box
@@ -267,30 +304,47 @@ describe('Box.js', () => {
it('gets the viewbox of the element', () => {
const canvas = SVG().addTo(container).viewbox(10, 10, 200, 200)
expect(canvas.viewbox()).toEqual(any(Box))
- expect(canvas.viewbox().toArray()).toEqual([ 10, 10, 200, 200 ])
+ expect(canvas.viewbox().toArray()).toEqual([10, 10, 200, 200])
})
})
describe('zoom()', () => {
it('zooms around the center by default', () => {
- const canvas = SVG().size(100, 50).viewbox(0, 0, 100, 50).addTo(container).zoom(2)
+ const canvas = SVG()
+ .size(100, 50)
+ .viewbox(0, 0, 100, 50)
+ .addTo(container)
+ .zoom(2)
expect(canvas.attr('viewBox')).toEqual('25 12.5 50 25')
})
it('zooms around a point', () => {
- const canvas = SVG().size(100, 50).viewbox(0, 0, 100, 50).addTo(container).zoom(2, [ 0, 0 ])
+ const canvas = SVG()
+ .size(100, 50)
+ .viewbox(0, 0, 100, 50)
+ .addTo(container)
+ .zoom(2, [0, 0])
expect(canvas.attr('viewBox')).toEqual('0 0 50 25')
})
it('gets the zoom', () => {
// We use a nested here because its actually harder to get a width and height for a nested svg because clientHeight
// is not available
- const svg = SVG().size(100, 50).addTo(container).nested().size(100, 50).viewbox(0, 0, 100, 50).zoom(2)
+ const svg = SVG()
+ .size(100, 50)
+ .addTo(container)
+ .nested()
+ .size(100, 50)
+ .viewbox(0, 0, 100, 50)
+ .zoom(2)
expect(svg.zoom()).toEqual(2)
})
it('gets the zoom with clientHeight', () => {
- const svg = SVG().css({ width: '100px', height: '50px' }).addTo(container).viewbox(25, 12.5, 50, 25)
+ const svg = SVG()
+ .css({ width: '100px', height: '50px' })
+ .addTo(container)
+ .viewbox(25, 12.5, 50, 25)
const node = svg.node
@@ -305,17 +359,32 @@ describe('Box.js', () => {
})
it('throws an error if it is impossible to get an absolute value', () => {
- const svg = SVG().size(100, 50).addTo(container).nested().viewbox(0, 0, 100, 50)
- expect(() => svg.zoom()).toThrowError('Impossible to get absolute width and height. Please provide an absolute width and height attribute on the zooming element')
+ const svg = SVG()
+ .size(100, 50)
+ .addTo(container)
+ .nested()
+ .viewbox(0, 0, 100, 50)
+ expect(() => svg.zoom()).toThrowError(
+ 'Impossible to get absolute width and height. Please provide an absolute width and height attribute on the zooming element'
+ )
})
it('handles zoom level 0 which is - which basically sets the viewbox to a very high value', () => {
- const svg = SVG().size(100, 50).viewbox(0, 0, 100, 50).addTo(container).zoom(0)
+ const svg = SVG()
+ .size(100, 50)
+ .viewbox(0, 0, 100, 50)
+ .addTo(container)
+ .zoom(0)
expect(svg.zoom()).toBeCloseTo(0, 10)
})
it('handles zoom level 0 and can recover from it', () => {
- const svg = SVG().size(100, 50).viewbox(0, 0, 100, 50).addTo(container).zoom(0).zoom(1)
+ const svg = SVG()
+ .size(100, 50)
+ .viewbox(0, 0, 100, 50)
+ .addTo(container)
+ .zoom(0)
+ .zoom(1)
expect(svg.zoom()).toBe(1)
})
})
diff --git a/spec/spec/types/Color.js b/spec/spec/types/Color.js
index 64161eb..4bbd626 100644
--- a/spec/spec/types/Color.js
+++ b/spec/spec/types/Color.js
@@ -12,7 +12,6 @@ describe('Color.js', () => {
})
describe('()', () => {
-
describe('constructs a color from an object in the correct color space', () => {
it('rgb', () => {
const color = new Color({ r: 255, g: 0, b: 128 })
@@ -73,7 +72,7 @@ describe('Color.js', () => {
})
it('constructs a color from an array', () => {
- const color = new Color([ 30, 24, 50 ])
+ const color = new Color([30, 24, 50])
expect(color.r).toBe(30)
expect(color.g).toBe(24)
expect(color.b).toBe(50)
@@ -81,7 +80,7 @@ describe('Color.js', () => {
})
it('constructs a color from an array with space in array', () => {
- const color = new Color([ 50, 50, 5, 'lab' ])
+ const color = new Color([50, 50, 5, 'lab'])
expect(color.l).toBe(50)
expect(color.a).toBe(50)
expect(color.b).toBe(5)
@@ -89,7 +88,7 @@ describe('Color.js', () => {
})
it('constructs a color from an array with space given', () => {
- const color = new Color([ 50, 50, 5 ], 'lab')
+ const color = new Color([50, 50, 5], 'lab')
expect(color.l).toBe(50)
expect(color.a).toBe(50)
expect(color.b).toBe(5)
@@ -118,7 +117,9 @@ describe('Color.js', () => {
})
it('throws an error if unsupported string format was given', () => {
- expect(() => new Color('#0066')).toThrowError('Unsupported string format, can\'t construct Color')
+ expect(() => new Color('#0066')).toThrowError(
+ "Unsupported string format, can't construct Color"
+ )
})
})
@@ -137,7 +138,6 @@ describe('Color.js', () => {
})
describe('color spaces: The color spaces supported by our library', () => {
-
describe('lab()', () => {
it('can convert rgb to lab', () => {
const color = new Color(255, 0, 128)
@@ -225,7 +225,6 @@ describe('Color.js', () => {
})
describe('hsl()', () => {
-
it('can convert from rgb to hsl', () => {
const color = new Color(255, 0, 128)
const hsl = color.hsl()
@@ -315,7 +314,6 @@ describe('Color.js', () => {
// })
describe('cmyk()', () => {
-
it('can convert from rgb to cmyk', () => {
const color = new Color(255, 0, 128)
const cmyk = color.cmyk()
@@ -357,9 +355,7 @@ describe('Color.js', () => {
expect(color.b).toBeCloseTo(255, 0)
expect(color.toHex()).toBe('#ffffff')
})
-
})
-
})
describe('static methods', () => {
@@ -397,7 +393,9 @@ describe('Color.js', () => {
})
it('throws an error if mode is unknown', () => {
- expect(() => Color.random('foo')).toThrowError('Unsupported random color mode')
+ expect(() => Color.random('foo')).toThrowError(
+ 'Unsupported random color mode'
+ )
})
})
@@ -446,5 +444,4 @@ describe('Color.js', () => {
})
})
})
-
})
diff --git a/spec/spec/types/EventTarget.js b/spec/spec/types/EventTarget.js
index 82e5a94..f19fe11 100644
--- a/spec/spec/types/EventTarget.js
+++ b/spec/spec/types/EventTarget.js
@@ -32,7 +32,9 @@ describe('EventTarget.js', () => {
const options = { cancelable: false }
const event = target.dispatch('bla', 'foo', options)
expect(spy).toHaveBeenCalledWith(event)
- expect(event).toEqual(objectContaining({ type: 'bla', detail: 'foo', cancelable: false }))
+ expect(event).toEqual(
+ objectContaining({ type: 'bla', detail: 'foo', cancelable: false })
+ )
})
})
diff --git a/spec/spec/types/List.js b/spec/spec/types/List.js
index eb0b40b..a6cab09 100644
--- a/spec/spec/types/List.js
+++ b/spec/spec/types/List.js
@@ -7,7 +7,7 @@ const { any, createSpy, objectContaining } = jasmine
describe('List.js', () => {
describe('()', () => {
it('creates a new List from Array', () => {
- const list = new List([ 1, 2, 3 ])
+ const list = new List([1, 2, 3])
expect(list).toEqual(any(List))
})
@@ -17,55 +17,57 @@ describe('List.js', () => {
})
it('is instance of Array', () => {
- const list = new List([ 1, 2, 3 ])
+ const list = new List([1, 2, 3])
expect(list).toEqual(any(Array))
})
it('allows index access', () => {
- const list = new List([ 1, 2, 3 ])
+ const list = new List([1, 2, 3])
expect(list[1]).toBe(2)
})
})
describe('each()', () => {
it('works like map but with context set to the element when a function is passed', () => {
- const list = new List([ 1, 2, 3 ]).each((el) => el * 2)
+ const list = new List([1, 2, 3]).each((el) => el * 2)
expect(list).toEqual(any(List))
- expect(list).toEqual([ 2, 4, 6 ])
+ expect(list).toEqual([2, 4, 6])
const spy = createSpy()
const obj = {}
- const list2 = new List([ obj ])
+ const list2 = new List([obj])
list2.each(spy)
- expect(spy.calls.first()).toEqual(objectContaining({
- object: obj,
- args: [ obj, 0, list2 ]
- }))
+ expect(spy.calls.first()).toEqual(
+ objectContaining({
+ object: obj,
+ args: [obj, 0, list2]
+ })
+ )
})
it('calls a method on every element in the list and passes arguments when a string is passed', () => {
- const list = new List([ 10, 11, 12 ])
- expect(list.each('toString', 16)).toEqual([ 'a', 'b', 'c' ])
+ const list = new List([10, 11, 12])
+ expect(list.each('toString', 16)).toEqual(['a', 'b', 'c'])
})
})
describe('toArray()', () => {
it('returns a plain array from the contents of the list', () => {
- const list = new List([ 1, 2, 3 ])
+ const list = new List([1, 2, 3])
const arr = list.toArray()
expect(arr).toEqual(any(Array))
expect(arr).not.toEqual(any(List))
- expect(arr).toEqual([ 1, 2, 3 ])
+ expect(arr).toEqual([1, 2, 3])
})
})
describe('static extend()', () => {
it('adds new method names to the List', () => {
- List.extend([ 'fooBar' ])
+ List.extend(['fooBar'])
expect(new List().fooBar).toEqual(any(Function))
const obj = { fooBar: createSpy() }
- new List([ obj ]).fooBar()
+ new List([obj]).fooBar()
expect(obj.fooBar).toHaveBeenCalled()
delete List.prototype.fooBar
@@ -73,12 +75,14 @@ describe('List.js', () => {
it('skips reserved names', () => {
const { constructor, each, toArray } = List.prototype
- List.extend([ 'constructor', 'each', 'toArray' ])
- expect(List.prototype).toEqual(objectContaining({ constructor, each, toArray }))
+ List.extend(['constructor', 'each', 'toArray'])
+ expect(List.prototype).toEqual(
+ objectContaining({ constructor, each, toArray })
+ )
})
it('skips private methods starting with an underscore', () => {
- List.extend([ '_private' ])
+ List.extend(['_private'])
expect(new List()._private).toBe(undefined)
})
})
diff --git a/spec/spec/types/Matrix.js b/spec/spec/types/Matrix.js
index bddf6fd..f395c43 100644
--- a/spec/spec/types/Matrix.js
+++ b/spec/spec/types/Matrix.js
@@ -9,12 +9,11 @@ describe('Matrix.js', () => {
const comp = { a: 2, b: 0, c: 0, d: 2, e: 100, f: 50 }
describe('initialization', () => {
-
it('creates a new matrix with default values', () => {
const matrix = new Matrix()
- expect(matrix).toEqual(objectContaining(
- { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0 }
- ))
+ expect(matrix).toEqual(
+ objectContaining({ a: 1, b: 0, c: 0, d: 1, e: 0, f: 0 })
+ )
})
it('parses the current transform matrix from an element', () => {
@@ -29,7 +28,7 @@ describe('Matrix.js', () => {
})
it('parses an array correctly', () => {
- const matrix = new Matrix([ 2, 0, 0, 2, 100, 50 ])
+ const matrix = new Matrix([2, 0, 0, 2, 100, 50])
expect(matrix).toEqual(objectContaining(comp))
})
@@ -39,7 +38,7 @@ describe('Matrix.js', () => {
})
it('parses a transform object correctly', () => {
- const matrix = new Matrix({ scale: 2, translate: [ 100, 50 ] })
+ const matrix = new Matrix({ scale: 2, translate: [100, 50] })
expect(matrix).toEqual(objectContaining(comp))
})
@@ -79,7 +78,11 @@ describe('Matrix.js', () => {
describe('decompose()', () => {
it('decomposes a matrix properly', () => {
- var matrix = new Matrix().scale(3, 2.5).shear(4).rotate(30).translate(20, 30)
+ var matrix = new Matrix()
+ .scale(3, 2.5)
+ .shear(4)
+ .rotate(30)
+ .translate(20, 30)
var decomposed = matrix.decompose()
expect(decomposed.scaleX).toBeCloseTo(3)
expect(decomposed.scaleY).toBeCloseTo(2.5)
@@ -90,7 +93,11 @@ describe('Matrix.js', () => {
})
it('can be recomposed to the same matrix', () => {
- var matrix = new Matrix().scale(3, 2.5).shear(4).rotate(30).translate(20, 30)
+ var matrix = new Matrix()
+ .scale(3, 2.5)
+ .shear(4)
+ .rotate(30)
+ .translate(20, 30)
var decomposed = matrix.decompose()
// Get rid of the matrix values before recomposing with the matrix constructor
@@ -141,7 +148,7 @@ describe('Matrix.js', () => {
it('inverses matrix', () => {
var matrix1 = new Matrix(2, 0, 0, 5, 4, 3)
var matrix2 = matrix1.inverse()
- var abcdef = [ 0.5, 0, 0, 0.2, -2, -0.6 ]
+ var abcdef = [0.5, 0, 0, 0.2, -2, -0.6]
for (var i in 'abcdef') {
expect(matrix2['abcdef'[i]]).toBeCloseTo(abcdef[i])
@@ -150,7 +157,9 @@ describe('Matrix.js', () => {
it('throws if matrix is not invertible', () => {
const matrix = new Matrix(0, 0, 0, 0, 0, 0)
- expect(() => matrix.inverse()).toThrowError('Cannot invert matrix(0,0,0,0,0,0)')
+ expect(() => matrix.inverse()).toThrowError(
+ 'Cannot invert matrix(0,0,0,0,0,0)'
+ )
})
})
@@ -411,13 +420,21 @@ describe('Matrix.js', () => {
describe('around()', () => {
it('performs a matrix operation around an origin by shifting the origin to 0,0', () => {
- const matrix = new Matrix(1, 0, 0, 1, 0, 0).around(10, 10, new Matrix().scale(2))
+ const matrix = new Matrix(1, 0, 0, 1, 0, 0).around(
+ 10,
+ 10,
+ new Matrix().scale(2)
+ )
expect(matrix).toEqual(new Matrix(2, 0, 0, 2, -10, -10))
})
it('defaults to around center of 0,0', () => {
- const matrix = new Matrix(1, 0, 0, 1, 0, 0).around(0, 0, new Matrix().scale(2))
+ const matrix = new Matrix(1, 0, 0, 1, 0, 0).around(
+ 0,
+ 0,
+ new Matrix().scale(2)
+ )
expect(matrix).toEqual(new Matrix(2, 0, 0, 2, 0, 0))
})
@@ -451,14 +468,14 @@ describe('Matrix.js', () => {
describe('toArray', () => {
it('converts matrix to array', () => {
const arr = new Matrix().toArray()
- expect(arr).toEqual([ 1, 0, 0, 1, 0, 0 ])
+ expect(arr).toEqual([1, 0, 0, 1, 0, 0])
})
})
describe('static', () => {
describe('fromArray()', () => {
it('creates a matrix like object from an array', () => {
- const matrix = Matrix.fromArray([ 1, 2, 3, 4, 5, 6 ])
+ const matrix = Matrix.fromArray([1, 2, 3, 4, 5, 6])
expect(matrix).not.toEqual(any(Matrix))
expect(matrix).toEqual(new Matrix(1, 2, 3, 4, 5, 6).valueOf())
})
@@ -478,47 +495,74 @@ describe('Matrix.js', () => {
describe('formatTransforms()', () => {
it('formats all transform input varieties to a canonical form', () => {
- expect(Matrix.formatTransforms({
- flip: true,
- skew: 5,
- scale: 5,
- originX: 5,
- originY: 5,
- positionX: 5,
- positionY: 5,
- translateX: 5,
- translateY: 5,
- relativeX: 5,
- relativeY: 5
- })).toEqual({ scaleX: -5, scaleY: -5, skewX: 5, skewY: 5, shear: 0, theta: 0, rx: 5, ry: 5, tx: 5, ty: 5, ox: 5, oy: 5, px: 5, py: 5 })
+ expect(
+ Matrix.formatTransforms({
+ flip: true,
+ skew: 5,
+ scale: 5,
+ originX: 5,
+ originY: 5,
+ positionX: 5,
+ positionY: 5,
+ translateX: 5,
+ translateY: 5,
+ relativeX: 5,
+ relativeY: 5
+ })
+ ).toEqual({
+ scaleX: -5,
+ scaleY: -5,
+ skewX: 5,
+ skewY: 5,
+ shear: 0,
+ theta: 0,
+ rx: 5,
+ ry: 5,
+ tx: 5,
+ ty: 5,
+ ox: 5,
+ oy: 5,
+ px: 5,
+ py: 5
+ })
})
it('respects flip=x', () => {
- expect(Matrix.formatTransforms({
- flip: 'x',
- scale: [ 1, 2 ],
- skew: [ 1, 2 ]
- })).toEqual(objectContaining({ scaleX: -1, scaleY: 2, skewX: 1, skewY: 2 }))
+ expect(
+ Matrix.formatTransforms({
+ flip: 'x',
+ scale: [1, 2],
+ skew: [1, 2]
+ })
+ ).toEqual(
+ objectContaining({ scaleX: -1, scaleY: 2, skewX: 1, skewY: 2 })
+ )
})
it('respects flip=y', () => {
- expect(Matrix.formatTransforms({
- flip: 'y',
- scaleX: 1,
- scaleY: 2,
- skewX: 1,
- skewY: 2
- })).toEqual(objectContaining({ scaleX: 1, scaleY: -2, skewX: 1, skewY: 2 }))
+ expect(
+ Matrix.formatTransforms({
+ flip: 'y',
+ scaleX: 1,
+ scaleY: 2,
+ skewX: 1,
+ skewY: 2
+ })
+ ).toEqual(
+ objectContaining({ scaleX: 1, scaleY: -2, skewX: 1, skewY: 2 })
+ )
})
it('makes position NaN if not passed', () => {
- expect(Matrix.formatTransforms({
- flip: 'y',
- scaleX: 1,
- scaleY: 2,
- skewX: 1,
- skewY: 2
- })).toEqual(objectContaining({ px: NaN, py: NaN }))
+ expect(
+ Matrix.formatTransforms({
+ flip: 'y',
+ scaleX: 1,
+ scaleY: 2,
+ skewX: 1,
+ skewY: 2
+ })
+ ).toEqual(objectContaining({ px: NaN, py: NaN }))
})
})
})
@@ -542,7 +586,10 @@ describe('Matrix.js', () => {
})
it('does extra work for nested svgs because firefox needs it', () => {
- const spy = spyOn(getWindow().SVGGraphicsElement.prototype, 'getScreenCTM')
+ const spy = spyOn(
+ getWindow().SVGGraphicsElement.prototype,
+ 'getScreenCTM'
+ )
const svg = SVG().nested()
svg.screenCTM()
expect(spy).toHaveBeenCalled()
diff --git a/spec/spec/types/PathArray.js b/spec/spec/types/PathArray.js
index 454252a..5c3991c 100644
--- a/spec/spec/types/PathArray.js
+++ b/spec/spec/types/PathArray.js
@@ -7,17 +7,19 @@ describe('PathArray.js', () => {
beforeEach(() => {
p1 = new PathArray('m10 10 h 80 v 80 h -80 l 300 400 z')
- p2 = new PathArray('m10 80 c 40 10 65 10 95 80 s 150 150 180 80 t 300 300 q 52 10 95 80 z')
+ p2 = new PathArray(
+ 'm10 80 c 40 10 65 10 95 80 s 150 150 180 80 t 300 300 q 52 10 95 80 z'
+ )
p3 = new PathArray('m80 80 A 45 45, 0, 0, 0, 125 125 L 125 80 z')
})
it('parses flat arrays correctly', () => {
- const arr = new PathArray([ 'M', 0, 0, 'L', 100, 100, 'z' ])
+ const arr = new PathArray(['M', 0, 0, 'L', 100, 100, 'z'])
expect(arr.toString()).toBe('M0 0L100 100Z ')
})
it('parses nested arrays correctly', () => {
- const arr = new PathArray([ [ 'M', 0, 0 ], [ 'L', 100, 100 ], [ 'z' ] ])
+ const arr = new PathArray([['M', 0, 0], ['L', 100, 100], ['z']])
expect(arr.toString()).toBe('M0 0L100 100Z ')
})
@@ -25,20 +27,26 @@ describe('PathArray.js', () => {
it('returns the valueOf when PathArray is given', () => {
const p = new PathArray('m10 10 h 80 v 80 h -80 l 300 400 z')
- expect((new PathArray(p))).toEqual(p)
+ expect(new PathArray(p)).toEqual(p)
})
describe('move()', () => {
it('moves all points in a straight path', () => {
- expect(p1.move(100, 200).toString()).toBe('M100 200H180V280H100L400 680Z ')
+ expect(p1.move(100, 200).toString()).toBe(
+ 'M100 200H180V280H100L400 680Z '
+ )
})
it('moves all points in a curved path', () => {
- expect(p2.move(100, 200).toString()).toBe('M100 200C140 210 165 210 195 280S345 430 375 360T675 660Q727 670 770 740Z ')
+ expect(p2.move(100, 200).toString()).toBe(
+ 'M100 200C140 210 165 210 195 280S345 430 375 360T675 660Q727 670 770 740Z '
+ )
})
it('moves all points in a arc path', () => {
- expect(p3.move(100, 200).toString()).toBe('M100 200A45 45 0 0 0 145 245L145 200Z ')
+ expect(p3.move(100, 200).toString()).toBe(
+ 'M100 200A45 45 0 0 0 145 245L145 200Z '
+ )
})
it('does nothing if passed number is not a number', () => {
@@ -48,26 +56,32 @@ describe('PathArray.js', () => {
describe('size()', () => {
it('resizes all points in a straight path', () => {
- expect(p1.size(600, 200).toString()).toBe('M10 10H170V43.333333333333336H10L610 210Z ')
+ expect(p1.size(600, 200).toString()).toBe(
+ 'M10 10H170V43.333333333333336H10L610 210Z '
+ )
})
it('resizes all points in a curved path', () => {
- expect(p2.size(600, 200).toString()).toBe('M10 80C45.82089552238806 83.70370370370371 68.2089552238806 83.70370370370371 95.07462686567165 109.62962962962963S229.40298507462686 165.1851851851852 256.2686567164179 139.25925925925927T524.9253731343283 250.37037037037038Q571.4925373134329 254.07407407407408 610 280Z ')
+ expect(p2.size(600, 200).toString()).toBe(
+ 'M10 80C45.82089552238806 83.70370370370371 68.2089552238806 83.70370370370371 95.07462686567165 109.62962962962963S229.40298507462686 165.1851851851852 256.2686567164179 139.25925925925927T524.9253731343283 250.37037037037038Q571.4925373134329 254.07407407407408 610 280Z '
+ )
})
it('resizes all points in a arc path', () => {
const expected = [
- [ 'M', 80, 80 ],
- [ 'A', 600, 200, 0, 0, 0, 680, 280 ],
- [ 'L', 680, 80 ],
- [ 'Z' ]
+ ['M', 80, 80],
+ ['A', 600, 200, 0, 0, 0, 680, 280],
+ ['L', 680, 80],
+ ['Z']
]
const toBeTested = p3.size(600, 200)
- for (let i = toBeTested.length; i--;) {
- expect(toBeTested[i].shift().toUpperCase()).toBe(expected[i].shift().toUpperCase())
- for (let j = toBeTested[i].length; j--;) {
+ for (let i = toBeTested.length; i--; ) {
+ expect(toBeTested[i].shift().toUpperCase()).toBe(
+ expected[i].shift().toUpperCase()
+ )
+ for (let j = toBeTested[i].length; j--; ) {
expect(toBeTested[i][j]).toBeCloseTo(expected[i][j])
}
}
diff --git a/spec/spec/types/Point.js b/spec/spec/types/Point.js
index ef0b6f6..ff167b3 100644
--- a/spec/spec/types/Point.js
+++ b/spec/spec/types/Point.js
@@ -6,9 +6,7 @@ describe('Point.js', () => {
var point
describe('initialization', () => {
-
describe('without a source', () => {
-
beforeEach(() => {
point = new Point()
})
@@ -17,7 +15,6 @@ describe('Point.js', () => {
expect(point.x).toBe(0)
expect(point.y).toBe(0)
})
-
})
describe('with x and y given', () => {
@@ -40,7 +37,7 @@ describe('Point.js', () => {
describe('with array given', () => {
it('creates a point from array', () => {
- var point = new Point([ 2, 4 ])
+ var point = new Point([2, 4])
expect(point.x).toBe(2)
expect(point.y).toBe(4)
@@ -68,11 +65,15 @@ describe('Point.js', () => {
describe('transform()', () => {
it('transforms a point with a matrix', () => {
- expect(new Point().transform(new Matrix({ translate: [ 10, 10 ] }))).toEqual(new Point(10, 10))
+ expect(
+ new Point().transform(new Matrix({ translate: [10, 10] }))
+ ).toEqual(new Point(10, 10))
})
it('transforms a point with a transformation object', () => {
- expect(new Point().transform({ translate: [ 10, 10 ] })).toEqual(new Point(10, 10))
+ expect(new Point().transform({ translate: [10, 10] })).toEqual(
+ new Point(10, 10)
+ )
})
})
@@ -89,7 +90,7 @@ describe('Point.js', () => {
describe('toArray()', () => {
it('creates an array representation of Point', () => {
const p = new Point(1, 2)
- expect(p.toArray()).toEqual([ 1, 2 ])
+ expect(p.toArray()).toEqual([1, 2])
})
})
@@ -97,7 +98,9 @@ describe('Point.js', () => {
describe('point()', () => {
it('transforms a screen point into the coordinate system of the element', () => {
const rect = new Rect()
- spyOn(rect, 'screenCTM').and.callFake(() => new Matrix(1, 0, 0, 1, 20, 20))
+ spyOn(rect, 'screenCTM').and.callFake(
+ () => new Matrix(1, 0, 0, 1, 20, 20)
+ )
expect(rect.point({ x: 10, y: 10 })).toEqual(new Point(-10, -10))
})
})
diff --git a/spec/spec/types/PointArray.js b/spec/spec/types/PointArray.js
index cbcc3c1..74cc21f 100644
--- a/spec/spec/types/PointArray.js
+++ b/spec/spec/types/PointArray.js
@@ -6,45 +6,76 @@ describe('PointArray.js', () => {
const squareString = '0,0 1,0 1,1 0,1'
describe('()', () => {
-
it('parses a string to a point array', () => {
var array = new PointArray('0,1 -.05,7.95 1000.0001,-200.222')
- expect(array.valueOf()).toEqual([ [ 0, 1 ], [ -0.05, 7.95 ], [ 1000.0001, -200.222 ] ])
+ expect(array.valueOf()).toEqual([
+ [0, 1],
+ [-0.05, 7.95],
+ [1000.0001, -200.222]
+ ])
})
it('parses a points array correctly to string', () => {
- var array = new PointArray([ [ 0, 0.15 ], [ -100, -3.141592654 ], [ 50, 100 ] ])
+ var array = new PointArray([
+ [0, 0.15],
+ [-100, -3.141592654],
+ [50, 100]
+ ])
expect(array + '').toBe('0,0.15 -100,-3.141592654 50,100')
})
it('parses a flat array of x/y coordinates to a point array', () => {
- var array = new PointArray([ 1, 4, 5, 68, 12, 24 ])
- expect(array.valueOf()).toEqual([ [ 1, 4 ], [ 5, 68 ], [ 12, 24 ] ])
+ var array = new PointArray([1, 4, 5, 68, 12, 24])
+ expect(array.valueOf()).toEqual([
+ [1, 4],
+ [5, 68],
+ [12, 24]
+ ])
})
it('parses points with space delimitered x/y coordinates', () => {
- var array = new PointArray('221.08 191.79 0.46 191.79 0.46 63.92 63.8 0.46 284.46 0.46 284.46 128.37 221.08 191.79')
- expect(array + '').toBe('221.08,191.79 0.46,191.79 0.46,63.92 63.8,0.46 284.46,0.46 284.46,128.37 221.08,191.79')
+ var array = new PointArray(
+ '221.08 191.79 0.46 191.79 0.46 63.92 63.8 0.46 284.46 0.46 284.46 128.37 221.08 191.79'
+ )
+ expect(array + '').toBe(
+ '221.08,191.79 0.46,191.79 0.46,63.92 63.8,0.46 284.46,0.46 284.46,128.37 221.08,191.79'
+ )
})
it('parses points with comma delimitered x/y coordinates', () => {
- var array = new PointArray('221.08,191.79,0.46,191.79,0.46,63.92,63.8,0.46,284.46,0.46,284.46,128.37,221.08,191.79')
- expect(array + '').toBe('221.08,191.79 0.46,191.79 0.46,63.92 63.8,0.46 284.46,0.46 284.46,128.37 221.08,191.79')
+ var array = new PointArray(
+ '221.08,191.79,0.46,191.79,0.46,63.92,63.8,0.46,284.46,0.46,284.46,128.37,221.08,191.79'
+ )
+ expect(array + '').toBe(
+ '221.08,191.79 0.46,191.79 0.46,63.92 63.8,0.46 284.46,0.46 284.46,128.37 221.08,191.79'
+ )
})
it('parses points with comma and space delimitered x/y coordinates', () => {
- var array = new PointArray('221.08, 191.79, 0.46, 191.79, 0.46, 63.92, 63.8, 0.46, 284.46, 0.46, 284.46, 128.37, 221.08, 191.79')
- expect(array + '').toBe('221.08,191.79 0.46,191.79 0.46,63.92 63.8,0.46 284.46,0.46 284.46,128.37 221.08,191.79')
+ var array = new PointArray(
+ '221.08, 191.79, 0.46, 191.79, 0.46, 63.92, 63.8, 0.46, 284.46, 0.46, 284.46, 128.37, 221.08, 191.79'
+ )
+ expect(array + '').toBe(
+ '221.08,191.79 0.46,191.79 0.46,63.92 63.8,0.46 284.46,0.46 284.46,128.37 221.08,191.79'
+ )
})
it('parses points with space and comma delimitered x/y coordinates', () => {
- var array = new PointArray('221.08 ,191.79 ,0.46 ,191.79 ,0.46 ,63.92 ,63.8 ,0.46 ,284.46 ,0.46 ,284.46 ,128.37 ,221.08 ,191.79')
- expect(array + '').toBe('221.08,191.79 0.46,191.79 0.46,63.92 63.8,0.46 284.46,0.46 284.46,128.37 221.08,191.79')
+ var array = new PointArray(
+ '221.08 ,191.79 ,0.46 ,191.79 ,0.46 ,63.92 ,63.8 ,0.46 ,284.46 ,0.46 ,284.46 ,128.37 ,221.08 ,191.79'
+ )
+ expect(array + '').toBe(
+ '221.08,191.79 0.46,191.79 0.46,63.92 63.8,0.46 284.46,0.46 284.46,128.37 221.08,191.79'
+ )
})
it('parses points with redundant spaces at the end', () => {
- var array = new PointArray('2176.6,1708.8 2176.4,1755.8 2245.8,1801.5 2297,1787.8 ')
- expect(array + '').toBe('2176.6,1708.8 2176.4,1755.8 2245.8,1801.5 2297,1787.8')
+ var array = new PointArray(
+ '2176.6,1708.8 2176.4,1755.8 2245.8,1801.5 2297,1787.8 '
+ )
+ expect(array + '').toBe(
+ '2176.6,1708.8 2176.4,1755.8 2245.8,1801.5 2297,1787.8'
+ )
})
it('parses points with space delimitered x/y coordinates - even with leading or trailing space', () => {
@@ -60,38 +91,48 @@ describe('PointArray.js', () => {
it('parses odd number of points in a flat array of x/y coordinates and silently remove the odd point', () => {
// this is according to spec: https://svgwg.org/svg2-draft/shapes.html#DataTypePoints
- var array = new PointArray([ 1, 2, 3 ])
- expect(array.valueOf()).toEqual([ [ 1, 2 ] ])
+ var array = new PointArray([1, 2, 3])
+ expect(array.valueOf()).toEqual([[1, 2]])
})
-
})
describe('move()', () => {
it('moves the whole array by the passed value', () => {
- const arr = new PointArray([ 1, 2, 3, 4 ]).move(10, 10)
- expect(arr.toArray()).toEqual([ 10, 10, 12, 12 ])
+ const arr = new PointArray([1, 2, 3, 4]).move(10, 10)
+ expect(arr.toArray()).toEqual([10, 10, 12, 12])
})
it('does nothing if values not numbers', () => {
- const arr = new PointArray([ 1, 2, 3, 4 ]).move()
- expect(arr.toArray()).toEqual([ 1, 2, 3, 4 ])
+ const arr = new PointArray([1, 2, 3, 4]).move()
+ expect(arr.toArray()).toEqual([1, 2, 3, 4])
})
})
describe('size()', () => {
it('correctly sizes the points over the whole area', () => {
- var array = new PointArray([ 10, 10, 20, 20, 30, 30 ])
- expect(array.size(60, 60).valueOf()).toEqual([ [ 10, 10 ], [ 40, 40 ], [ 70, 70 ] ])
+ var array = new PointArray([10, 10, 20, 20, 30, 30])
+ expect(array.size(60, 60).valueOf()).toEqual([
+ [10, 10],
+ [40, 40],
+ [70, 70]
+ ])
})
it('let coordinates untouched when width/height is zero', () => {
- var array = new PointArray([ 10, 10, 10, 20, 10, 30 ])
- expect(array.size(60, 60).valueOf()).toEqual([ [ 10, 10 ], [ 10, 40 ], [ 10, 70 ] ])
-
- array = new PointArray([ 10, 10, 20, 10, 30, 10 ])
- expect(array.size(60, 60).valueOf()).toEqual([ [ 10, 10 ], [ 40, 10 ], [ 70, 10 ] ])
+ var array = new PointArray([10, 10, 10, 20, 10, 30])
+ expect(array.size(60, 60).valueOf()).toEqual([
+ [10, 10],
+ [10, 40],
+ [10, 70]
+ ])
+
+ array = new PointArray([10, 10, 20, 10, 30, 10])
+ expect(array.size(60, 60).valueOf()).toEqual([
+ [10, 10],
+ [40, 10],
+ [70, 10]
+ ])
})
-
})
describe('toString()', () => {
@@ -103,7 +144,7 @@ describe('PointArray.js', () => {
describe('toLine', () => {
it('returns an object which can be passed to a line as point attributes', () => {
- const arr = new PointArray([ 1, 2, 3, 4 ])
+ const arr = new PointArray([1, 2, 3, 4])
expect(arr.toLine()).toEqual({ x1: 1, y1: 2, x2: 3, y2: 4 })
})
})
@@ -111,7 +152,7 @@ describe('PointArray.js', () => {
describe('transform()', () => {
it('translates correctly', () => {
const square = new PointArray(squareString)
- const translation = new Matrix({ translate: [ 2, 1 ] })
+ const translation = new Matrix({ translate: [2, 1] })
const newSquare = square.transform(translation)
expect(newSquare.toString()).toEqual('2,1 3,1 3,2 2,2')
})
@@ -129,7 +170,7 @@ describe('PointArray.js', () => {
it('works with transform object instead of matrix', () => {
const square = new PointArray(squareString)
- const newSquare = square.transform({ translate: [ 2, 1 ] })
+ const newSquare = square.transform({ translate: [2, 1] })
expect(newSquare.toString()).toEqual('2,1 3,1 3,2 2,2')
})
})
diff --git a/spec/spec/types/SVGArray.js b/spec/spec/types/SVGArray.js
index dc58a89..35c4b85 100644
--- a/spec/spec/types/SVGArray.js
+++ b/spec/spec/types/SVGArray.js
@@ -6,7 +6,6 @@ const { any } = jasmine
describe('SVGArray.js', () => {
describe('()', () => {
-
it('preallocates memory if only number is passed', () => {
const arr = new SVGArray(1)
expect(arr.length).toBe(1)
@@ -14,29 +13,28 @@ describe('SVGArray.js', () => {
it('parses a matrix array correctly to string', () => {
const array = new SVGArray([
- 0.343, 0.669, 0.119, 0, 0,
- 0.249, -0.626, 0.130, 0, 0,
- 0.172, 0.334, 0.111, 0, 0,
- 0.000, 0.000, 0.000, 1, -0
+ 0.343, 0.669, 0.119, 0, 0, 0.249, -0.626, 0.13, 0, 0, 0.172, 0.334,
+ 0.111, 0, 0, 0.0, 0.0, 0.0, 1, -0
])
- expect(array + '').toBe('0.343 0.669 0.119 0 0 0.249 -0.626 0.13 0 0 0.172 0.334 0.111 0 0 0 0 0 1 0')
+ expect(array + '').toBe(
+ '0.343 0.669 0.119 0 0 0.249 -0.626 0.13 0 0 0.172 0.334 0.111 0 0 0 0 0 1 0'
+ )
})
it('parses space separated string and converts it to array', () => {
- expect((new SVGArray('1 2 3 4')).valueOf()).toEqual([ 1, 2, 3, 4 ])
+ expect(new SVGArray('1 2 3 4').valueOf()).toEqual([1, 2, 3, 4])
})
it('parses comma separated string and converts it to array', () => {
- expect((new SVGArray('1,2,3,4')).valueOf()).toEqual([ 1, 2, 3, 4 ])
+ expect(new SVGArray('1,2,3,4').valueOf()).toEqual([1, 2, 3, 4])
})
-
})
describe('reverse()', () => {
it('reverses the array', () => {
- const array = new SVGArray([ 1, 2, 3, 4, 5 ]).reverse()
- expect(array.valueOf()).toEqual([ 5, 4, 3, 2, 1 ])
+ const array = new SVGArray([1, 2, 3, 4, 5]).reverse()
+ expect(array.valueOf()).toEqual([5, 4, 3, 2, 1])
})
it('returns itself', () => {
@@ -47,7 +45,7 @@ describe('SVGArray.js', () => {
describe('clone()', () => {
it('creates a shallow clone of the array', () => {
- const array = new SVGArray([ 1, 2, 3, 4, 5 ])
+ const array = new SVGArray([1, 2, 3, 4, 5])
const clone = array.clone()
expect(array).toEqual(clone)
@@ -55,25 +53,33 @@ describe('SVGArray.js', () => {
})
it('also works with PointArray (one depths clone)', () => {
- const array = new PointArray([ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ])
+ const array = new PointArray([
+ [1, 2],
+ [3, 4],
+ [5, 6]
+ ])
const clone = array.clone()
expect(array).toEqual(clone)
expect(array).not.toBe(clone)
- for (let i = array.length; i--;) {
+ for (let i = array.length; i--; ) {
expect(array[i]).not.toBe(clone[i])
}
})
it('also works with PathArray (one depths clone)', () => {
- const array = new PathArray([ [ 'M', 1, 2 ], [ 'L', 3, 4 ], [ 'L', 5, 6 ] ])
+ const array = new PathArray([
+ ['M', 1, 2],
+ ['L', 3, 4],
+ ['L', 5, 6]
+ ])
const clone = array.clone()
expect(array).toEqual(clone)
expect(array).not.toBe(clone)
- for (let i = array.length; i--;) {
+ for (let i = array.length; i--; ) {
expect(array[i]).not.toBe(clone[i])
}
})
@@ -81,9 +87,9 @@ describe('SVGArray.js', () => {
describe('toSet()', () => {
it('creates a Set from the Array', () => {
- const set = new SVGArray([ 1, 1, 2, 3 ]).toSet()
+ const set = new SVGArray([1, 1, 2, 3]).toSet()
expect(set).toEqual(any(Set))
- expect(set).toEqual(new Set([ 1, 2, 3 ]))
+ expect(set).toEqual(new Set([1, 2, 3]))
})
})
})
diff --git a/spec/spec/types/SVGNumber.js b/spec/spec/types/SVGNumber.js
index 1660724..2002833 100644
--- a/spec/spec/types/SVGNumber.js
+++ b/spec/spec/types/SVGNumber.js
@@ -56,13 +56,15 @@ describe('Number.js', () => {
})
it('falls back to maximum value if given number is positive infinite', () => {
- number = new SVGNumber(1.7976931348623157E+10308)
- expect(number.value).toBe(3.4e+38)
+ // eslint-disable-next-line no-loss-of-precision
+ number = new SVGNumber(1.7976931348623157e10308)
+ expect(number.value).toBe(3.4e38)
})
it('falls back to minimum value if given number is negative infinite', () => {
- number = new SVGNumber(-1.7976931348623157E+10308)
- expect(number.value).toBe(-3.4e+38)
+ // eslint-disable-next-line no-loss-of-precision
+ number = new SVGNumber(-1.7976931348623157e10308)
+ expect(number.value).toBe(-3.4e38)
})
})
diff --git a/spec/spec/utils/adopter.js b/spec/spec/utils/adopter.js
index 60c1642..3c12790 100644
--- a/spec/spec/utils/adopter.js
+++ b/spec/spec/utils/adopter.js
@@ -69,7 +69,9 @@ describe('adopter.js', () => {
const rect = makeInstance('<rect width="200px" />')
expect(adoptSpy).toHaveBeenCalledWith(any(Node))
- expect(adoptSpy).toHaveBeenCalledWith(objectContaining({ nodeName: 'rect' }))
+ expect(adoptSpy).toHaveBeenCalledWith(
+ objectContaining({ nodeName: 'rect' })
+ )
expect(rect).toEqual(any(Rect))
expect(rect.parent()).toBe(null)
})
@@ -78,7 +80,12 @@ describe('adopter.js', () => {
const div = makeInstance('<div />', true)
expect(adoptSpy).toHaveBeenCalledWith(any(Node))
- expect(adoptSpy).toHaveBeenCalledWith(objectContaining({ nodeName: 'DIV', namespaceURI: 'http://www.w3.org/1999/xhtml' }))
+ expect(adoptSpy).toHaveBeenCalledWith(
+ objectContaining({
+ nodeName: 'DIV',
+ namespaceURI: 'http://www.w3.org/1999/xhtml'
+ })
+ )
expect(div).toEqual(any(Dom))
expect(div.parent()).toBe(null)
})
@@ -106,7 +113,9 @@ describe('adopter.js', () => {
const rect = makeInstance(create('rect'))
expect(adoptSpy).toHaveBeenCalledWith(any(Node))
- expect(adoptSpy).toHaveBeenCalledWith(objectContaining({ nodeName: 'rect' }))
+ expect(adoptSpy).toHaveBeenCalledWith(
+ objectContaining({ nodeName: 'rect' })
+ )
expect(rect).toEqual(any(Rect))
})
})
@@ -206,7 +215,10 @@ describe('adopter.js', () => {
const A = class {}
extend(A, {
- test () { this.prop = 'test'; return this }
+ test() {
+ this.prop = 'test'
+ return this
+ }
})
expect(typeof A.prototype.test).toBe('function')
@@ -218,8 +230,11 @@ describe('adopter.js', () => {
const B = class {}
const C = class {}
- extend([ A, B, C ], {
- test () { this.prop = 'test'; return this }
+ extend([A, B, C], {
+ test() {
+ this.prop = 'test'
+ return this
+ }
})
expect(typeof A.prototype.test).toBe('function')
@@ -238,7 +253,8 @@ describe('adopter.js', () => {
const A = class {}
extend(A, {
test: wrapWithAttrCheck(function () {
- this.prop = 'test'; return this
+ this.prop = 'test'
+ return this
}),
attr: attrSpy
})
diff --git a/spec/spec/utils/methods.js b/spec/spec/utils/methods.js
index 10d50d8..457a078 100644
--- a/spec/spec/utils/methods.js
+++ b/spec/spec/utils/methods.js
@@ -1,6 +1,10 @@
/* globals describe, expect, it */
-import { registerMethods, getMethodsFor, getMethodNames } from '../../../src/utils/methods.js'
+import {
+ registerMethods,
+ getMethodsFor,
+ getMethodNames
+} from '../../../src/utils/methods.js'
describe('methods.js', () => {
describe('registerMethods() / getMethodsFor() / addMethodNames / getMethodNames()', () => {
diff --git a/spec/spec/utils/pathParser.js b/spec/spec/utils/pathParser.js
index 09cfa4a..15d0453 100644
--- a/spec/spec/utils/pathParser.js
+++ b/spec/spec/utils/pathParser.js
@@ -5,136 +5,159 @@ import { pathParser } from '../../../src/utils/pathParser.js'
describe('pathParser.js', () => {
describe('pathParser()', () => {
it('parses all paths correctly', () => {
- expect(pathParser('M2,0a2 2 0 00-2 2a2 2 0 002 2a.5.5 0 011 0z')).toEqual([
- [ 'M', 2, 0 ],
- [ 'A', 2, 2, 0, 0, 0, 0, 2 ],
- [ 'A', 2, 2, 0, 0, 0, 2, 4 ],
- [ 'A', 0.5, 0.5, 0, 0, 1, 3, 4 ],
- [ 'Z' ]
- ])
-
- expect(pathParser('M2,0a2 2 0 00-2 2a2 2 0 002 2a.5.5 0 111 0z')).toEqual([
- [ 'M', 2, 0 ],
- [ 'A', 2, 2, 0, 0, 0, 0, 2 ],
- [ 'A', 2, 2, 0, 0, 0, 2, 4 ],
- [ 'A', 0.5, 0.5, 0, 1, 1, 3, 4 ],
- [ 'Z' ]
- ])
+ expect(pathParser('M2,0a2 2 0 00-2 2a2 2 0 002 2a.5.5 0 011 0z')).toEqual(
+ [
+ ['M', 2, 0],
+ ['A', 2, 2, 0, 0, 0, 0, 2],
+ ['A', 2, 2, 0, 0, 0, 2, 4],
+ ['A', 0.5, 0.5, 0, 0, 1, 3, 4],
+ ['Z']
+ ]
+ )
+
+ expect(pathParser('M2,0a2 2 0 00-2 2a2 2 0 002 2a.5.5 0 111 0z')).toEqual(
+ [
+ ['M', 2, 0],
+ ['A', 2, 2, 0, 0, 0, 0, 2],
+ ['A', 2, 2, 0, 0, 0, 2, 4],
+ ['A', 0.5, 0.5, 0, 1, 1, 3, 4],
+ ['Z']
+ ]
+ )
expect(pathParser('m10 10 h 80 v 80 h -80 l 300 400 z')).toEqual([
- [ 'M', 10, 10 ],
- [ 'H', 90 ],
- [ 'V', 90 ],
- [ 'H', 10 ],
- [ 'L', 310, 490 ],
- [ 'Z' ]
- ])
-
- expect(pathParser('m10 80 c 40 10 65 10 95 80 s 150 150 180 80 t 300 300 q 52 10 95 80 z')).toEqual([
- [ 'M', 10, 80 ],
- [ 'C', 50, 90, 75, 90, 105, 160 ],
- [ 'S', 255, 310, 285, 240 ],
- [ 'T', 585, 540 ],
- [ 'Q', 637, 550, 680, 620 ],
- [ 'Z' ]
- ])
-
- expect(pathParser('m80 80 A 45 45, 0, 0, 0, 125 125 L 125 80 z')).toEqual([
- [ 'M', 80, 80 ],
- [ 'A', 45, 45, 0, 0, 0, 125, 125 ],
- [ 'L', 125, 80 ],
- [ 'Z' ]
- ])
-
- expect(pathParser('M215.458,245.23c0,0,77.403,0,94.274,0S405,216.451,405,138.054S329.581,15,287.9,15c-41.68,0-139.924,0-170.688,0C86.45,15,15,60.65,15,134.084c0,73.434,96.259,112.137,114.122,112.137C146.984,246.221,215.458,245.23,215.458,245.23z')).toEqual([
- [ 'M', 215.458, 245.23 ],
- [ 'C', 215.458, 245.23, 292.861, 245.23, 309.73199999999997, 245.23 ],
- [ 'S', 405, 216.451, 405, 138.054 ],
- [ 'S', 329.581, 15, 287.9, 15 ],
- [ 'C', 246.21999999999997, 15, 147.97599999999997, 15, 117.21199999999999, 15 ],
- [ 'C', 86.45, 15, 15, 60.65, 15, 134.084 ],
- [ 'C', 15, 207.518, 111.259, 246.221, 129.122, 246.221 ],
- [ 'C', 146.984, 246.221, 215.458, 245.23, 215.458, 245.23 ],
- [ 'Z' ]
- ])
-
- expect(pathParser('M10 10-45-30.5.5 .89L2e-2.5.5-.5C.5.5.5.5.5.5L-3-4z')).toEqual([
- [ 'M', 10, 10 ],
- [ 'L', -45, -30.5 ],
- [ 'L', 0.5, 0.89 ],
- [ 'L', 0.02, 0.5 ],
- [ 'L', 0.5, -0.5 ],
- [ 'C', 0.5, 0.5, 0.5, 0.5, 0.5, 0.5 ],
- [ 'L', -3, -4 ],
- [ 'Z' ]
- ])
-
- expect(pathParser('m 0,0 0,3189 2209,0 0,-3189 -2209,0 z m 154,154 1901,0 0,2881 -1901,0 0,-2881 z')).toEqual([
- [ 'M', 0, 0 ],
- [ 'L', 0, 3189 ],
- [ 'L', 2209, 3189 ],
- [ 'L', 2209, 0 ],
- [ 'L', 0, 0 ],
- [ 'Z' ],
- [ 'M', 154, 154 ],
- [ 'L', 2055, 154 ],
- [ 'L', 2055, 3035 ],
- [ 'L', 154, 3035 ],
- [ 'L', 154, 154 ],
- [ 'Z' ]
+ ['M', 10, 10],
+ ['H', 90],
+ ['V', 90],
+ ['H', 10],
+ ['L', 310, 490],
+ ['Z']
+ ])
+
+ expect(
+ pathParser(
+ 'm10 80 c 40 10 65 10 95 80 s 150 150 180 80 t 300 300 q 52 10 95 80 z'
+ )
+ ).toEqual([
+ ['M', 10, 80],
+ ['C', 50, 90, 75, 90, 105, 160],
+ ['S', 255, 310, 285, 240],
+ ['T', 585, 540],
+ ['Q', 637, 550, 680, 620],
+ ['Z']
+ ])
+
+ expect(pathParser('m80 80 A 45 45, 0, 0, 0, 125 125 L 125 80 z')).toEqual(
+ [['M', 80, 80], ['A', 45, 45, 0, 0, 0, 125, 125], ['L', 125, 80], ['Z']]
+ )
+
+ expect(
+ pathParser(
+ 'M215.458,245.23c0,0,77.403,0,94.274,0S405,216.451,405,138.054S329.581,15,287.9,15c-41.68,0-139.924,0-170.688,0C86.45,15,15,60.65,15,134.084c0,73.434,96.259,112.137,114.122,112.137C146.984,246.221,215.458,245.23,215.458,245.23z'
+ )
+ ).toEqual([
+ ['M', 215.458, 245.23],
+ ['C', 215.458, 245.23, 292.861, 245.23, 309.73199999999997, 245.23],
+ ['S', 405, 216.451, 405, 138.054],
+ ['S', 329.581, 15, 287.9, 15],
+ [
+ 'C',
+ 246.21999999999997,
+ 15,
+ 147.97599999999997,
+ 15,
+ 117.21199999999999,
+ 15
+ ],
+ ['C', 86.45, 15, 15, 60.65, 15, 134.084],
+ ['C', 15, 207.518, 111.259, 246.221, 129.122, 246.221],
+ ['C', 146.984, 246.221, 215.458, 245.23, 215.458, 245.23],
+ ['Z']
+ ])
+
+ expect(
+ pathParser('M10 10-45-30.5.5 .89L2e-2.5.5-.5C.5.5.5.5.5.5L-3-4z')
+ ).toEqual([
+ ['M', 10, 10],
+ ['L', -45, -30.5],
+ ['L', 0.5, 0.89],
+ ['L', 0.02, 0.5],
+ ['L', 0.5, -0.5],
+ ['C', 0.5, 0.5, 0.5, 0.5, 0.5, 0.5],
+ ['L', -3, -4],
+ ['Z']
+ ])
+
+ expect(
+ pathParser(
+ 'm 0,0 0,3189 2209,0 0,-3189 -2209,0 z m 154,154 1901,0 0,2881 -1901,0 0,-2881 z'
+ )
+ ).toEqual([
+ ['M', 0, 0],
+ ['L', 0, 3189],
+ ['L', 2209, 3189],
+ ['L', 2209, 0],
+ ['L', 0, 0],
+ ['Z'],
+ ['M', 154, 154],
+ ['L', 2055, 154],
+ ['L', 2055, 3035],
+ ['L', 154, 3035],
+ ['L', 154, 154],
+ ['Z']
])
expect(pathParser('m 0,0 a 45 45, 0, 0, 0, 125 125')).toEqual([
- [ 'M', 0, 0 ],
- [ 'A', 45, 45, 0, 0, 0, 125, 125 ]
+ ['M', 0, 0],
+ ['A', 45, 45, 0, 0, 0, 125, 125]
])
expect(pathParser('M10 10 80 80 30 30 Z')).toEqual([
- [ 'M', 10, 10 ],
- [ 'L', 80, 80 ],
- [ 'L', 30, 30 ],
- [ 'Z' ]
+ ['M', 10, 10],
+ ['L', 80, 80],
+ ['L', 30, 30],
+ ['Z']
])
expect(pathParser('M10 10L.5.5.3.3Z')).toEqual([
- [ 'M', 10, 10 ],
- [ 'L', 0.5, 0.5 ],
- [ 'L', 0.3, 0.3 ],
- [ 'Z' ]
+ ['M', 10, 10],
+ ['L', 0.5, 0.5],
+ ['L', 0.3, 0.3],
+ ['Z']
])
// "a" commands without optional whitespace around the flag params and ending coordinate pair
expect(pathParser('a32 32 0 00.03-45.22', false)).toEqual([
- [ 'a', 32.0, 32.0, 0.0, 0.0, 0.0, 0.03, -45.22 ],
+ ['a', 32.0, 32.0, 0.0, 0.0, 0.0, 0.03, -45.22]
])
expect(pathParser('a48 48 0 1148-48', false)).toEqual([
- [ 'a', 48.0, 48.0, 0.0, 1.0, 1.0, 48.0, -48.0],
+ ['a', 48.0, 48.0, 0.0, 1.0, 1.0, 48.0, -48.0]
])
expect(pathParser('a82.6 82.6 0 0033.48-20.25', false)).toEqual([
- [ 'a', 82.6, 82.6, 0.0, 0.0, 0.0, 33.48, -20.25 ],
+ ['a', 82.6, 82.6, 0.0, 0.0, 0.0, 33.48, -20.25]
])
expect(pathParser('a82.45 82.45 0 00-20.24 33.47', false)).toEqual([
- [ 'a', 82.45, 82.45, 0.0, 0.0, 0.0, -20.24, 33.47 ],
+ ['a', 82.45, 82.45, 0.0, 0.0, 0.0, -20.24, 33.47]
])
expect(pathParser('a2.51 2.51 0 01.25.32', false)).toEqual([
- [ 'a', 2.51, 2.51, 0, 0, 1, 0.25, 0.32 ],
+ ['a', 2.51, 2.51, 0, 0, 1, 0.25, 0.32]
])
expect(pathParser('a2.51 2.51 0 00.25.32', false)).toEqual([
- [ 'a', 2.51, 2.51, 0, 0, 0, 0.25, 0.32 ],
+ ['a', 2.51, 2.51, 0, 0, 0, 0.25, 0.32]
])
expect(pathParser('a2.51 2.51 0 000.25.32', false)).toEqual([
- [ 'a', 2.51, 2.51, 0, 0, 0, 0.25, 0.32 ],
+ ['a', 2.51, 2.51, 0, 0, 0, 0.25, 0.32]
])
expect(pathParser('a48 48 0 1148-48 48 48 0 01-48 48', false)).toEqual([
- [ 'a', 48.0, 48.0, 0.0, 1.0, 1.0, 48.0, -48.0 ],
- [ 'a', 48.0, 48.0, 0.0, 0.0, 1.0, -48.0, 48.0 ]
+ ['a', 48.0, 48.0, 0.0, 1.0, 1.0, 48.0, -48.0],
+ ['a', 48.0, 48.0, 0.0, 0.0, 1.0, -48.0, 48.0]
])
})
})
diff --git a/spec/spec/utils/utils.js b/spec/spec/utils/utils.js
index 5a2ae97..0b3015e 100644
--- a/spec/spec/utils/utils.js
+++ b/spec/spec/utils/utils.js
@@ -20,7 +20,7 @@ describe('utils.js', function () {
var arr2
beforeEach(function () {
- arr1 = [ 1, 2, 3, 4 ]
+ arr1 = [1, 2, 3, 4]
arr2 = map(arr1, function (el) {
return el * 2
})
@@ -32,7 +32,7 @@ describe('utils.js', function () {
})
it('executes a function on every element and returns the result in a new array', function () {
- expect(arr2).toEqual([ 2, 4, 6, 8 ])
+ expect(arr2).toEqual([2, 4, 6, 8])
})
})
@@ -41,7 +41,7 @@ describe('utils.js', function () {
var arr2
beforeEach(function () {
- arr1 = [ 1, 2, 3, 4 ]
+ arr1 = [1, 2, 3, 4]
arr2 = filter(arr1, function (el) {
return el % 2 === 0
})
@@ -53,7 +53,7 @@ describe('utils.js', function () {
})
it('filters elements by function', function () {
- expect(arr2).toEqual([ 2, 4 ])
+ expect(arr2).toEqual([2, 4])
})
})
@@ -130,16 +130,28 @@ describe('utils.js', function () {
var el = { bbox: () => ({ width: 200, height: 100 }) }
it('calculates height proportionally', function () {
- expect(proportionalSize(el, 400, null)).toEqual({ width: 400, height: 200 })
+ expect(proportionalSize(el, 400, null)).toEqual({
+ width: 400,
+ height: 200
+ })
})
it('calculates width proportionally', function () {
- expect(proportionalSize(el, null, 200)).toEqual({ width: 400, height: 200 })
+ expect(proportionalSize(el, null, 200)).toEqual({
+ width: 400,
+ height: 200
+ })
})
it('prefers passed box over element', function () {
- expect(proportionalSize(el, 300, null, box)).toEqual({ width: 300, height: 200 })
- expect(proportionalSize(el, null, 200, box)).toEqual({ width: 300, height: 200 })
+ expect(proportionalSize(el, 300, null, box)).toEqual({
+ width: 300,
+ height: 200
+ })
+ expect(proportionalSize(el, null, 200, box)).toEqual({
+ width: 300,
+ height: 200
+ })
})
})
@@ -147,48 +159,48 @@ describe('utils.js', function () {
var el = { bbox: () => ({ width: 200, height: 100, x: 300, y: 400 }) }
it('gets the origin from [ox, oy]', function () {
- var origin = { origin: [ 10, 20 ] }
- expect(getOrigin(origin, el)).toEqual([ 10, 20 ])
+ var origin = { origin: [10, 20] }
+ expect(getOrigin(origin, el)).toEqual([10, 20])
})
it('gets the origin from [ox, oy] as strings', function () {
- var origin = { origin: [ 'center', 'top' ] }
- expect(getOrigin(origin, el)).toEqual([ 400, 400 ])
+ var origin = { origin: ['center', 'top'] }
+ expect(getOrigin(origin, el)).toEqual([400, 400])
})
it('gets the origin from {x, y}', function () {
var origin = { origin: { x: 10, y: 20 } }
- expect(getOrigin(origin, el)).toEqual([ 10, 20 ])
+ expect(getOrigin(origin, el)).toEqual([10, 20])
})
it('gets the origin from {ox, oy}', function () {
var origin = { ox: 10, oy: 20 }
- expect(getOrigin(origin, el)).toEqual([ 10, 20 ])
+ expect(getOrigin(origin, el)).toEqual([10, 20])
})
it('gets the origin from {ox, oy} as strings', function () {
var origin = { ox: 'center', oy: 'top' }
- expect(getOrigin(origin, el)).toEqual([ 400, 400 ])
+ expect(getOrigin(origin, el)).toEqual([400, 400])
})
it('gets the origin from {originX, originY}', function () {
var origin = { originX: 10, originY: 20 }
- expect(getOrigin(origin, el)).toEqual([ 10, 20 ])
+ expect(getOrigin(origin, el)).toEqual([10, 20])
})
it('gets the origin from {originX, originY} as strings', function () {
var origin = { originX: 'center', originY: 'top' }
- expect(getOrigin(origin, el)).toEqual([ 400, 400 ])
+ expect(getOrigin(origin, el)).toEqual([400, 400])
})
it('gets the origin from string', function () {
var origin = { origin: 'center top' }
- expect(getOrigin(origin, el)).toEqual([ 400, 400 ])
+ expect(getOrigin(origin, el)).toEqual([400, 400])
})
it('gets the origin from number', function () {
var origin = { origin: 5 }
- expect(getOrigin(origin, el)).toEqual([ 5, 5 ])
+ expect(getOrigin(origin, el)).toEqual([5, 5])
})
})
})
diff --git a/spec/spec/utils/window.js b/spec/spec/utils/window.js
index 65fbcab..e681491 100644
--- a/spec/spec/utils/window.js
+++ b/spec/spec/utils/window.js
@@ -1,6 +1,13 @@
/* globals describe, expect, it */
-import { registerWindow, globals, withWindow, getWindow, saveWindow, restoreWindow } from '../../../src/utils/window.js'
+import {
+ registerWindow,
+ globals,
+ withWindow,
+ getWindow,
+ saveWindow,
+ restoreWindow
+} from '../../../src/utils/window.js'
describe('window.js', () => {
describe('registerWindow()', () => {