PHP Classes

File: toastui/test/rotation.spec.js

Recommend this page to a friend!
  Classes of Mark de Leon   PHP Document Scanner using SANE or eSCL AirPrint   toastui/test/rotation.spec.js   Download  
File: toastui/test/rotation.spec.js
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: PHP Document Scanner using SANE or eSCL AirPrint
Web interface to scan printed documents
Author: By
Last change:
Date: 4 years ago
Size: 2,079 bytes
 

Contents

Class file image Download
/** * @author NHN Ent. FE Development Team <dl_javascript@nhn.com> * @fileoverview Test cases of "src/js/component/rotation.js" */ import fabric from 'fabric/dist/fabric.require'; import $ from 'jquery'; import Graphics from '../src/js/graphics'; import Rotation from '../src/js/component/rotation'; describe('Rotation', () => { let graphics, rotationModule, mockImage, canvas; beforeAll(() => { graphics = new Graphics($('<canvas>')[0]); canvas = graphics.getCanvas(); rotationModule = new Rotation(graphics); }); beforeEach(() => { mockImage = new fabric.Image(); graphics.setCanvasImage('mockImage', mockImage); }); it('"getCurrentAngle()" should return current angle value', () => { mockImage.angle = 30; expect(rotationModule.getCurrentAngle()).toEqual(30); }); it('"setAngle()" should set angle value', () => { rotationModule.setAngle(40); expect(rotationModule.getCurrentAngle()).toEqual(40); }); it('"rotate()" should add angle value', () => { let current = rotationModule.getCurrentAngle(); rotationModule.rotate(10); expect(rotationModule.getCurrentAngle()).toBe(current + 10); current = rotationModule.getCurrentAngle(); rotationModule.rotate(20); expect(rotationModule.getCurrentAngle()).toBe(current + 20); }); it('"rotate()" should add angle value modular 360(===2*PI)', done => { rotationModule.setAngle(10).then(() => rotationModule.rotate(380)).then(() => { expect(rotationModule.getCurrentAngle()).toBe(30); done(); }); }); // @todo Move this tc to main.spec.js it('"adjustCanvasDimension()" should set canvas dimension from image-rect', () => { spyOn(mockImage, 'getBoundingRect').and.returnValue({ width: 100, height: 110 }); rotationModule.adjustCanvasDimension(); expect(canvas.getWidth()).toEqual(100); expect(canvas.getHeight()).toEqual(110); }); });