aboutsummaryrefslogtreecommitdiffstats
path: root/library/cropperjs/test/specs/options/toggleDragModeOnDblclick.spec.js
blob: b67617f1dfe4d33c420538eaa6bca87631dfc8a3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
describe('toggleDragModeOnDblclick (option)', () => {
  it('should toggle drag mode on double click', (done) => {
    const image = window.createImage();
    const cropper = new Cropper(image, {

      ready() {
        const { dragBox } = cropper;

        expect(dragBox.className).include('cropper-crop');
        expect(dragBox.dataset.cropperAction).to.equal('crop');
        dragBox.dispatchEvent(window.createEvent('dblclick'));
        expect(dragBox.className).include('cropper-move');
        expect(dragBox.dataset.cropperAction).to.equal('move');
        done();
      },
    });

    expect(cropper.options.toggleDragModeOnDblclick).to.be.true;
  });

  it('should not toggle drag mode on double click', (done) => {
    const image = window.createImage();
    const cropper = new Cropper(image, {
      toggleDragModeOnDblclick: false,

      ready() {
        const { dragBox } = cropper;

        expect(dragBox.className).include('cropper-crop');
        expect(dragBox.dataset.cropperAction).to.equal('crop');
        dragBox.dispatchEvent(window.createEvent('dblclick'));
        expect(dragBox.className).include('cropper-crop');
        expect(dragBox.dataset.cropperAction).to.equal('crop');
        done();
      },
    });

    expect(cropper.options.toggleDragModeOnDblclick).to.be.false;
  });
});