diff options
author | Mario <mario@mariovavti.com> | 2020-01-11 10:30:12 +0000 |
---|---|---|
committer | Mario <mario@mariovavti.com> | 2020-01-11 10:30:12 +0000 |
commit | f645c6f3a57bf5f53bbb2bde362b2447f725c977 (patch) | |
tree | 9b37650aad46296c5d98a55969348ebb4ee2d097 /library/cropperjs/test/specs/options/preview.spec.js | |
parent | 4c1c6908165e5c4fb1b7238f66764f89faa2301a (diff) | |
download | volse-hubzilla-f645c6f3a57bf5f53bbb2bde362b2447f725c977.tar.gz volse-hubzilla-f645c6f3a57bf5f53bbb2bde362b2447f725c977.tar.bz2 volse-hubzilla-f645c6f3a57bf5f53bbb2bde362b2447f725c977.zip |
update cropperjs to the recent version
Diffstat (limited to 'library/cropperjs/test/specs/options/preview.spec.js')
-rw-r--r-- | library/cropperjs/test/specs/options/preview.spec.js | 105 |
1 files changed, 105 insertions, 0 deletions
diff --git a/library/cropperjs/test/specs/options/preview.spec.js b/library/cropperjs/test/specs/options/preview.spec.js new file mode 100644 index 000000000..2d2bc34d4 --- /dev/null +++ b/library/cropperjs/test/specs/options/preview.spec.js @@ -0,0 +1,105 @@ +describe('preview (option)', () => { + it('should be an empty string be default', () => { + const image = window.createImage(); + const cropper = new Cropper(image); + + expect(cropper.options.preview).to.be.a('string').that.is.empty; + }); + + it('should support element', (done) => { + const image = window.createImage(); + const preview = document.createElement('div'); + + image.ownerDocument.body.appendChild(preview); + + const cropper = new Cropper(image, { + preview, + + ready() { + expect(preview.firstElementChild).to.not.be.null; + expect(preview.firstElementChild.src).to.equal(image.src); + done(); + }, + }); + + expect(cropper.options.preview).to.equal(preview); + }); + + it('should support array of elements', (done) => { + const image = window.createImage(); + const previews = document.createElement('ul'); + const preview1 = document.createElement('li'); + const preview2 = document.createElement('li'); + const preview = [preview1, preview2]; + + previews.appendChild(preview1); + previews.appendChild(preview2); + image.ownerDocument.body.appendChild(previews); + + const cropper = new Cropper(image, { + preview, + + ready() { + expect(preview1.firstElementChild).to.not.be.null; + expect(preview2.firstElementChild).to.not.be.null; + expect(preview1.firstElementChild.src).to.equal(image.src); + expect(preview2.firstElementChild.src).to.equal(image.src); + done(); + }, + }); + + expect(cropper.options.preview).to.equal(preview); + }); + + it('should support `NodeList` object', (done) => { + const image = window.createImage(); + const previews = document.createElement('ul'); + const preview1 = document.createElement('li'); + const preview2 = document.createElement('li'); + + previews.appendChild(preview1); + previews.appendChild(preview2); + image.ownerDocument.body.appendChild(previews); + + const cropper = new Cropper(image, { + preview: previews.children, + + ready() { + expect(preview1.firstElementChild).to.not.be.null; + expect(preview2.firstElementChild).to.not.be.null; + expect(preview1.firstElementChild.src).to.equal(image.src); + expect(preview2.firstElementChild.src).to.equal(image.src); + done(); + }, + }); + + expect(cropper.options.preview).to.equal(previews.children); + }); + + it('should support selector', (done) => { + const image = window.createImage(); + const previews = document.createElement('ul'); + const preview1 = document.createElement('li'); + const preview2 = document.createElement('li'); + + preview1.className = 'preview'; + preview2.className = 'preview'; + previews.appendChild(preview1); + previews.appendChild(preview2); + image.ownerDocument.body.appendChild(previews); + + const cropper = new Cropper(image, { + preview: '.preview', + + ready() { + expect(preview1.firstElementChild).to.not.be.null; + expect(preview2.firstElementChild).to.not.be.null; + expect(preview1.firstElementChild.src).to.equal(image.src); + expect(preview2.firstElementChild.src).to.equal(image.src); + done(); + }, + }); + + expect(cropper.options.preview).to.equal('.preview'); + }); +}); |