diff options
author | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2020-04-10 16:03:05 +1000 |
---|---|---|
committer | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2020-04-10 16:03:05 +1000 |
commit | 6ac53822882f5cc852c8e8e41e9507333fed2180 (patch) | |
tree | 6790d232b7666d1278af7998317bc4e9b4ae9558 /spec | |
parent | a61525e02014062d09f0ce65495d6144636389ef (diff) | |
download | svg.js-6ac53822882f5cc852c8e8e41e9507333fed2180.tar.gz svg.js-6ac53822882f5cc852c8e8e41e9507333fed2180.zip |
added tests for Polygon and Polyline
Diffstat (limited to 'spec')
-rw-r--r-- | spec/spec/elements/Polygon.js | 35 | ||||
-rw-r--r-- | spec/spec/elements/Polyline.js | 35 |
2 files changed, 70 insertions, 0 deletions
diff --git a/spec/spec/elements/Polygon.js b/spec/spec/elements/Polygon.js new file mode 100644 index 0000000..8a3f226 --- /dev/null +++ b/spec/spec/elements/Polygon.js @@ -0,0 +1,35 @@ +/* globals describe, expect, it, jasmine */ + +import { Polygon, G } from '../../../src/main.js' + +const { any } = jasmine + +describe('Polygon.js', () => { + describe('()', () => { + it('creates a new object of type Polygon', () => { + expect(new Polygon()).toEqual(any(Polygon)) + }) + + it('sets passed attributes on the element', () => { + expect(new Polygon({ id: 'foo' }).id()).toBe('foo') + }) + }) + + describe('Container', () => { + 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 ] ]) + expect(polygon).toEqual(any(Polygon)) + }) + }) + + 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).toEqual(any(Polygon)) + }) + }) +}) diff --git a/spec/spec/elements/Polyline.js b/spec/spec/elements/Polyline.js new file mode 100644 index 0000000..76dca30 --- /dev/null +++ b/spec/spec/elements/Polyline.js @@ -0,0 +1,35 @@ +/* globals describe, expect, it, jasmine */ + +import { Polyline, G } from '../../../src/main.js' + +const { any } = jasmine + +describe('Polyline.js', () => { + describe('()', () => { + it('creates a new object of type Polyline', () => { + expect(new Polyline()).toEqual(any(Polyline)) + }) + + it('sets passed attributes on the element', () => { + expect(new Polyline({ id: 'foo' }).id()).toBe('foo') + }) + }) + + describe('Container', () => { + 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 ] ]) + 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).toEqual(any(Polyline)) + }) + }) + }) +}) |