aboutsummaryrefslogtreecommitdiffstats
path: root/library/cropperjs/test/specs/events/crop.spec.js
blob: 04ec1fd10e700d5fa12043a4484ef56378202870 (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
describe('crop (event)', () => {
  it('should trigger the `crop` event', (done) => {
    const image = window.createImage();

    image.addEventListener('crop', (event) => {
      expect(event.type).to.equal('crop');
      done();
    });

    new Cropper(image);
  });

  it('should have expected properties in `event.detail`', (done) => {
    const image = window.createImage();

    image.addEventListener('crop', (event) => {
      expect(event.detail).to.be.an('object').that.has.all.keys(['x', 'y', 'width', 'height', 'rotate', 'scaleX', 'scaleY']);
      expect(event.detail.x).to.be.a('number');
      expect(event.detail.y).to.be.a('number');
      expect(event.detail.width).to.be.a('number');
      expect(event.detail.height).to.be.a('number');
      expect(event.detail.rotate).to.be.a('number');
      expect(event.detail.scaleX).to.be.a('number');
      expect(event.detail.scaleY).to.be.a('number');
      done();
    });

    new Cropper(image);
  });
});