Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crop preset review #84

Merged
merged 11 commits into from
Oct 31, 2018
Prev Previous commit
Next Next commit
fixed test code
  • Loading branch information
jinwoo-kim-nhn committed Oct 31, 2018
commit d8ec6049b3ca71131ce754d13e8b2880129e2471
36 changes: 14 additions & 22 deletions test/cropper.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,68 +241,62 @@ describe('Cropper', () => {
});

describe('"presets - setCropzoneRect()"', () => {
it('should return cropzone rect as a square', () => {
beforeEach(() => {
cropper.start();
});

afterEach(() => {
cropper.end();
});

it('should return cropzone rect as a square', () => {
spyOn(cropper._cropzone, 'isValid').and.returnValue(true);
cropper.setCropzoneRect(1 / 1);
expect(cropper.getCropzoneRect()).toBeTruthy();

expect(cropper.getCropzoneRect().width).toBe(cropper.getCropzoneRect().height);
cropper.end();
});

it('should return cropzone rect as a 3:2 aspect box', () => {
cropper.start();
spyOn(cropper._cropzone, 'isValid').and.returnValue(true);
cropper.setCropzoneRect(3 / 2);
expect(cropper.getCropzoneRect()).toBeTruthy();

expect((cropper.getCropzoneRect().width / cropper.getCropzoneRect().height).toFixed(1))
.toBe((3 / 2).toFixed(1));
cropper.end();
});

it('should return cropzone rect as a 4:3 aspect box', () => {
cropper.start();
spyOn(cropper._cropzone, 'isValid').and.returnValue(true);
cropper.setCropzoneRect(4 / 3);
expect(cropper.getCropzoneRect()).toBeTruthy();

expect((cropper.getCropzoneRect().width / cropper.getCropzoneRect().height).toFixed(1))
.toBe((4 / 3).toFixed(1));
cropper.end();
});

it('should return cropzone rect as a 5:4 aspect box', () => {
cropper.start();
spyOn(cropper._cropzone, 'isValid').and.returnValue(true);
cropper.setCropzoneRect(5 / 4);
expect(cropper.getCropzoneRect()).toBeTruthy();

expect((cropper.getCropzoneRect().width / cropper.getCropzoneRect().height).toFixed(1))
.toBe((5 / 4).toFixed(1));
cropper.end();
});

it('should return cropzone rect as a 7:5 aspect box', () => {
cropper.start();
spyOn(cropper._cropzone, 'isValid').and.returnValue(true);
cropper.setCropzoneRect(7 / 5);
expect(cropper.getCropzoneRect()).toBeTruthy();

expect((cropper.getCropzoneRect().width / cropper.getCropzoneRect().height).toFixed(1))
.toBe((7 / 5).toFixed(1));
cropper.end();
});

it('should return cropzone rect as a 16:9 aspect box', () => {
cropper.start();
spyOn(cropper._cropzone, 'isValid').and.returnValue(true);
cropper.setCropzoneRect(16 / 9);
expect(cropper.getCropzoneRect()).toBeTruthy();

expect((cropper.getCropzoneRect().width / cropper.getCropzoneRect().height).toFixed(1))
.toBe((16 / 9).toFixed(1));
cropper.end();
});

it('should remove cropzone of cropper when falsy is passed', () => {
cropper.start();

cropper.setCropzoneRect();
expect(cropper.getCropzoneRect()).toBeFalsy();

Expand All @@ -311,8 +305,6 @@ describe('Cropper', () => {

cropper.setCropzoneRect(null);
expect(cropper.getCropzoneRect()).toBeFalsy();

cropper.end();
});
});

Expand Down