aboutsummaryrefslogtreecommitdiffstats
path: root/library/cropperjs/test/specs/methods/setCanvasData.spec.js
blob: 316161acc2e42cc91f33e01f572a4c129fd965db (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
describe('setCanvasData (method)', () => {
  it('should change the positions only', (done) => {
    const image = window.createImage();
    const cropper = new Cropper(image, {
      ready() {
        const canvasData = cropper.getCanvasData();
        const changedCanvasData = cropper.setCanvasData({
          left: 16,
          top: 9,
        }).getCanvasData();

        expect(changedCanvasData.left).to.not.equal(canvasData.left);
        expect(changedCanvasData.top).to.not.equal(canvasData.top);
        expect(changedCanvasData.width).to.equal(canvasData.width);
        expect(changedCanvasData.height).to.equal(canvasData.height);
        done();
      },
    });
  });

  it('should change the sizes only', (done) => {
    const image = window.createImage();
    const cropper = new Cropper(image, {
      ready() {
        const canvasData = cropper.getCanvasData();
        const changedCanvasData = cropper.setCanvasData({
          width: 320,
          height: 180,
        }).getCanvasData();

        expect(changedCanvasData.left).to.equal(canvasData.left);
        expect(changedCanvasData.top).to.equal(canvasData.top);
        expect(changedCanvasData.width).to.not.equal(canvasData.width);
        expect(changedCanvasData.height).to.not.equal(canvasData.height);
        done();
      },
    });
  });
});