aboutsummaryrefslogtreecommitdiffstats
path: root/library/cropperjs/test/specs/options/preview.spec.js
diff options
context:
space:
mode:
authorzotlabs <mike@macgirvin.com>2020-01-14 13:34:56 -0800
committerzotlabs <mike@macgirvin.com>2020-01-14 13:34:56 -0800
commit293d411efb28b8f20a0208e3c52883e9fbb8cea7 (patch)
treea8b0af66015815d56342daf8301ab5ae095eda0a /library/cropperjs/test/specs/options/preview.spec.js
parent2a287e6def5ab54037222c963ab0875faf62fc1a (diff)
parentd96f4340e80207a29a5c1c49cae8c25e3934d5ae (diff)
downloadvolse-hubzilla-293d411efb28b8f20a0208e3c52883e9fbb8cea7.tar.gz
volse-hubzilla-293d411efb28b8f20a0208e3c52883e9fbb8cea7.tar.bz2
volse-hubzilla-293d411efb28b8f20a0208e3c52883e9fbb8cea7.zip
Merge branch 'dev' of https://framagit.org/hubzilla/core into dev
Diffstat (limited to 'library/cropperjs/test/specs/options/preview.spec.js')
-rw-r--r--library/cropperjs/test/specs/options/preview.spec.js105
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');
+ });
+});