summaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2020-04-08 11:07:53 +1000
committerUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2020-04-08 11:07:53 +1000
commit9a67cc3bbaf2e3f83368dc9706a06ec245a22c6a (patch)
treef9a4c38b668577117d7833a308c7868580d10617 /spec
parente4e7e11da50c8129bcf31de03a2849f323aa4299 (diff)
downloadsvg.js-9a67cc3bbaf2e3f83368dc9706a06ec245a22c6a.tar.gz
svg.js-9a67cc3bbaf2e3f83368dc9706a06ec245a22c6a.zip
added tests for Circle
Diffstat (limited to 'spec')
-rw-r--r--spec/spec/elements/Circle.js66
1 files changed, 66 insertions, 0 deletions
diff --git a/spec/spec/elements/Circle.js b/spec/spec/elements/Circle.js
new file mode 100644
index 0000000..e9b8b56
--- /dev/null
+++ b/spec/spec/elements/Circle.js
@@ -0,0 +1,66 @@
+/* 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))
+ })
+ })
+ })
+})