aboutsummaryrefslogtreecommitdiffstats
path: root/library/cropperjs/test/specs/options/aspectRatio.spec.js
blob: 4524d2810e5b3c4c1193f7a52cbcec56b9f39f58 (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
describe('aspectRatio (option)', () => {
  it('should be `NaN` by default', () => {
    const image = window.createImage();
    const cropper = new Cropper(image);

    expect(cropper.options.aspectRatio).to.be.NaN;
  });

  it('should match the given aspect ratio', (done) => {
    const image = window.createImage();
    const cropper = new Cropper(image, {
      aspectRatio: 1,

      crop() {
        const cropBoxData = cropper.getCropBoxData();

        expect(cropBoxData.width).to.equal(cropBoxData.height);
        done();
      },
    });

    expect(cropper.options.aspectRatio).to.equal(1);
  });
});