RepositorySys/wwwroot/cropperjs-main/test/specs/methods/getCroppedCanvas.spec.js

(开头部分) 5KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

describe('getCroppedCanvas (method)', () => {
  it('should get a canvas with the whole image drew when it is not cropped', (done) => {
    const image = window.createImage();
    const cropper = new Cropper(image, {
      autoCrop: false,

      ready() {
        const canvasData = cropper.getCanvasData();
        const canvas = cropper.getCroppedCanvas();

        expect(canvas).to.be.an.instanceof(HTMLCanvasElement);
        expect(canvas.width).to.equal(canvasData.naturalWidth);
        expect(canvas.height).to.equal(canvasData.naturalHeight);
        done();
      },
    });
  });

  it('should get a canvas with the cropped area of the image drew', (done) => {
    const image = window.createImage();
    const cropper = new Cropper(image, {
      ready() {
        const data = cropper.getData();
        const canvas = cropper.getCroppedCanvas();

        expect(canvas).to.be.an.instanceof(HTMLCanvasElement);
        expect(canvas.width).to.equal(data.width);
        expect(canvas.height).to.equal(data.height);
        done();
      },
    });
  });

  it('should match the given width', (done) => {
    const image = window.createImage();
    const cropper = new Cropper(image, {
      ready() {
        const width = 160;
        const canvas = cropper.getCroppedCanvas({
          width,
        });

        expect(canvas.width).to.equal(width);
        done();
      },
    });
  });

  it('should match the given height', (done) => {
    const image = window.createImage();
    const cropper = new Cropper(image, {
      ready() {
        const height = 90;
        const canvas = cropper.getCroppedCanvas({
          height,
        });

        expect(canvas.height).to.equal(height);
        done();
      },
后面还有 135 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。