aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2019-02-18 09:44:27 +0100
committerUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2019-02-18 09:44:27 +0100
commit9e75004466f251d765f72fd80fad846e71fae107 (patch)
tree6f1610a7bc384e86c43ff1afd43c4042485896f1 /spec
parenta118f5e8ea4c596d9f9e39f8cc7a388136f958c9 (diff)
downloadsvg.js-9e75004466f251d765f72fd80fad846e71fae107.tar.gz
svg.js-9e75004466f251d765f72fd80fad846e71fae107.zip
added foreignObject to the core
Diffstat (limited to 'spec')
-rw-r--r--spec/spec/elements/ForeignObject.js47
1 files changed, 47 insertions, 0 deletions
diff --git a/spec/spec/elements/ForeignObject.js b/spec/spec/elements/ForeignObject.js
new file mode 100644
index 0000000..56ab081
--- /dev/null
+++ b/spec/spec/elements/ForeignObject.js
@@ -0,0 +1,47 @@
+import { makeInstance, ForeignObject } from '../../../src/main.js';
+
+const { any, createSpy, objectContaining } = jasmine
+
+
+describe('ForeignObject.js', () => {
+
+ describe('()', () => {
+ it('creates a new object of type ForeignObject', () => {
+ expect(new ForeignObject()).toEqual(any(ForeignObject))
+ })
+
+ it('sets passed attributes on the element', () => {
+ expect(new ForeignObject({id:'foo'}).id()).toBe('foo')
+ })
+ })
+
+ describe('Container', () => {
+ describe('foreignObject()', () => {
+ it('creates a foreignObject in the container', () => {
+ const canvas = makeInstance().addTo('#canvas')
+ const foreignObject = canvas.foreignObject()
+ expect(foreignObject).toEqual(any(ForeignObject))
+ expect(foreignObject.parent()).toBe(canvas)
+ })
+
+ it('sets width and height correctly on construction', () => {
+ const canvas = makeInstance().addTo('#canvas')
+ const foreignObject = canvas.foreignObject(100, 200)
+ expect(foreignObject.width()).toBe(100)
+ expect(foreignObject.height()).toBe(200)
+ })
+ })
+ })
+
+ describe('Element methods', () => {
+ it('is usable with Elements methods such as height() and width()', () => {
+ const canvas = makeInstance().addTo('#canvas')
+ const foreignObject = canvas.foreignObject()
+ foreignObject.width(100).height(200).x(10).y(20)
+ expect(foreignObject.width()).toBe(100)
+ expect(foreignObject.height()).toBe(200)
+ expect(foreignObject.x()).toBe(10)
+ expect(foreignObject.y()).toBe(20)
+ })
+ })
+})