diff options
Diffstat (limited to 'library/cropperjs/test/specs/options/zoom.spec.js')
-rw-r--r-- | library/cropperjs/test/specs/options/zoom.spec.js | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/library/cropperjs/test/specs/options/zoom.spec.js b/library/cropperjs/test/specs/options/zoom.spec.js new file mode 100644 index 000000000..3d11f3a2f --- /dev/null +++ b/library/cropperjs/test/specs/options/zoom.spec.js @@ -0,0 +1,46 @@ +describe('zoom (option)', () => { + it('should be `null` be default', () => { + const image = window.createImage(); + const cropper = new Cropper(image); + + expect(cropper.options.zoom).to.be.null; + }); + + it('should execute the `zoom` hook function', (done) => { + const image = window.createImage(); + const cropper = new Cropper(image, { + ready() { + cropper.zoom(0.1); + }, + + zoom(event) { + expect(event.type).to.equal('zoom'); + expect(event.detail).to.be.an('object').that.has.all.keys(['ratio', 'oldRatio', 'originalEvent']); + expect(event.detail.ratio).to.be.a('number'); + expect(event.detail.oldRatio).to.be.a('number'); + expect(event.detail.ratio).to.be.above(0); + expect(event.detail.oldRatio).to.be.above(0); + expect(event.detail.ratio).to.be.above(event.detail.oldRatio); + done(); + }, + }); + + expect(cropper.options.zoom).to.be.a('function'); + }); + + it('should not change the canvas sizes when default prevented', (done) => { + const image = window.createImage(); + const cropper = new Cropper(image, { + ready() { + const canvasData = cropper.getCanvasData(); + + expect(cropper.zoom(0.1).getCanvasData()).to.deep.equal(canvasData); + done(); + }, + + zoom(event) { + event.preventDefault(); + }, + }); + }); +}); |