PHP Classes

File: toastui/test/line.spec.js

Recommend this page to a friend!
  Classes of Mark de Leon   PHP Document Scanner using SANE or eSCL AirPrint   toastui/test/line.spec.js   Download  
File: toastui/test/line.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: 1,895 bytes
 

Contents

Class file image Download
/** * @author NHN Ent. FE Development Team <dl_javascript@nhn.com> * @fileoverview Test cases of "src/js/component/line.js" */ import fabric from 'fabric/dist/fabric.require'; import $ from 'jquery'; import Graphics from '../src/js/graphics'; import Line from '../src/js/component/line'; describe('Line', () => { let canvas, graphics, mockImage, line, fEvent; beforeAll(() => { graphics = new Graphics($('<canvas>')[0]); canvas = graphics.getCanvas(); line = new Line(graphics); }); beforeEach(() => { mockImage = new fabric.Image(); graphics.setCanvasImage('mockImage', mockImage); fEvent = { e: {} }; }); afterEach(() => { canvas.forEachObject(obj => { canvas.remove(obj); }); }); it('_onFabricMouseDown() should insert the line.', () => { line._onFabricMouseDown(fEvent); expect(canvas.getObjects().length).toEqual(1); }); it('_onFabricMouseMove() should draw line located by mouse pointer.', () => { line._line = new fabric.Line([10, 20, 10, 20]); canvas.add(line._line); spyOn(canvas, 'getPointer').and.returnValue({ x: 30, y: 60 }); expect(canvas.getObjects()[0].get('x2')).toEqual(10); expect(canvas.getObjects()[0].get('y2')).toEqual(20); line._onFabricMouseMove(fEvent); expect(canvas.getObjects()[0].get('x2')).toEqual(30); expect(canvas.getObjects()[0].get('y2')).toEqual(60); }); it('end() should restore all drawing objects activated.', () => { const path = new fabric.Path(); canvas.add(path); line.start(); expect(canvas.getObjects()[0].get('evented')).toEqual(false); line.end(); expect(canvas.getObjects()[0].get('evented')).toEqual(true); }); });