aboutsummaryrefslogblamecommitdiffstats
path: root/library/cropperjs/test/specs/events/crop.spec.js
blob: 04ec1fd10e700d5fa12043a4484ef56378202870 (plain) (tree)





























                                                                                                                             
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);
  });
});