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

(开头部分) 2KB

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

describe('getData (method)', () => {
  const initialData = {
    x: 0,
    y: 0,
    width: 0,
    height: 0,
    rotate: 0,
    scaleX: 1,
    scaleY: 1,
  };

  it('should get initial data when it is not ready', () => {
    const image = window.createImage();
    const cropper = new Cropper(image);

    expect(cropper.getData()).to.deep.equal(initialData);
  });

  it('should get initial data when it is not cropped', (done) => {
    const image = window.createImage();
    const cropper = new Cropper(image, {
      autoCrop: false,

      ready() {
        expect(cropper.cropped).to.be.false;
        expect(cropper.getData()).to.deep.equal(initialData);
        done();
      },
    });
  });

  it('should get data with expected properties', (done) => {
    const image = window.createImage();
    const cropper = new Cropper(image, {
      ready() {
        const data = cropper.getData();

        expect(data).to.be.an('object').that.has.all.keys(['x', 'y', 'width', 'height', 'rotate', 'scaleX', 'scaleY']);
        expect(data.x).to.be.a('number');
        expect(data.y).to.be.a('number');
        expect(data.width).to.be.a('number');
        expect(data.height).to.be.a('number');
        expect(data.rotate).to.be.a('number');
        expect(data.scaleX).to.be.a('number');
        expect(data.scaleY).to.be.a('number');
        done();
      },
    });
  });

  it('should get data with rounded property values', (done) => {
    const image = window.createImage();
    const cropper = new Cropper(image, {
      ready() {
        const data = cropper.getData(true);

        expect(data.x % 1).to.equal(0);
        expect(data.y % 1).to.equal(0);
        expect(data.width % 1).to.equal(0);
        expect(data.height % 1).to.equal(0);
后面还有 31 行代码,解锁后查看完整代码

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

AI 解读 AI

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

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