aboutsummaryrefslogtreecommitdiffstats
path: root/spec/spec/elements/Image.js
diff options
context:
space:
mode:
Diffstat (limited to 'spec/spec/elements/Image.js')
-rw-r--r--spec/spec/elements/Image.js49
1 files changed, 28 insertions, 21 deletions
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)
})
})