- fixed positioning methods of `TSpan` to position them by its bounding box
- fixed `flip()` method which flips correctly by center by default now and accepts correct arguments
- fixed a case in `rbox()` where not always all values of the box were updated
- - fixed `getOrigin()` function used by `transform()` so that all origin (#1085) popssibilities specified in the docs are working
+ - fixed `getOrigin()` function used by `transform()` so that all origin popssibilities specified in the docs are working (#1085)
- fixed positioning of text by its baseline when using `amove()`
- fixed tons of typings in the svg.d.ts file and relaxed type requirements for `put()` and `parent()`
- fixed adopter when adopting an svg/html string. It had still its wrapper as parentNode attached
- added `orient()` method to `Marker`
- added `options` parameter to `dispatch()` and `fire()` to allow for more special needs
- added `newLine()` constructor to `Text` to create a tspan marked as new line (#1088)
- - added lots of tests in es6 format
- added `Fragment` as a wrapper for document-fragment
+ - added lots of tests in es6 format
## [3.0.16] - 2019-11-12
--- /dev/null
+/* globals describe, expect, it, beforeEach, spyOn, jasmine */
+
+import { Circle, G } from '../../../src/main.js'
+
+const { any, objectContaining } = jasmine
+
+describe('Circle.js', () => {
+ let circle
+
+ beforeEach(() => {
+ circle = new Circle()
+ })
+
+ describe('()', () => {
+ it('creates a new object of type Circle', () => {
+ expect(new Circle()).toEqual(any(Circle))
+ })
+
+ it('sets passed attributes on the element', () => {
+ expect(new Circle({ id: 'foo' }).id()).toBe('foo')
+ })
+ })
+
+ describe('radius()', () => {
+ it('calls attr with r', () => {
+ const spy = spyOn(circle, 'attr').and.callThrough()
+ circle.radius(123)
+ expect(spy).toHaveBeenCalledWith('r', 123)
+ })
+ })
+
+ describe('rx()', () => {
+ it('calls attr with r', () => {
+ const spy = spyOn(circle, 'attr')
+ circle.rx(123)
+ expect(spy).toHaveBeenCalledWith('r', 123)
+ })
+ })
+
+ describe('ry()', () => {
+ it('calls rx', () => {
+ const spy = spyOn(circle, 'rx')
+ circle.ry(123)
+ expect(spy).toHaveBeenCalledWith(123)
+ })
+ })
+
+ describe('size()', () => {
+ it('calls radius with half of the size', () => {
+ const spy = spyOn(circle, 'radius')
+ circle.size(100)
+ expect(spy).toHaveBeenCalledWith(objectContaining({ value: 50 }))
+ })
+ })
+
+ describe('Container', () => {
+ describe('circle()', () => {
+ it('creates a circle with given size', () => {
+ const group = new G()
+ const circle = group.circle(50)
+ expect(circle.attr('r')).toBe(25)
+ expect(circle).toEqual(any(Circle))
+ })
+ })
+ })
+})
import { extend, makeInstance } from './utils/adopter.js'
import { getMethodNames, getMethodsFor } from './utils/methods.js'
import Box from './types/Box.js'
-import Circle from './elements/Circle.js'
import Color from './types/Color.js'
import Container from './elements/Container.js'
import Defs from './elements/Defs.js'
extend([
Rect,
Ellipse,
- Circle,
- Gradient
+ Gradient,
+ Runner
], getMethodsFor('radius'))
extend(EventTarget, getMethodsFor('EventTarget'))
registerMethods('radius', {
// Add x and y radius
- radius: function (x, y) {
+ radius: function (x, y = x) {
var type = (this._element || this).type
return type === 'radialGradient' || type === 'radialGradient'
? this.attr('r', new SVGNumber(x))
- : this.rx(x).ry(y == null ? x : y)
+ : this.rx(x).ry(y)
}
})