|
1 | | -import { equal } from 'assert'; |
| 1 | +import { equal, deepStrictEqual } from 'assert'; |
2 | 2 | import PDFJSAnnotate from '../../src/PDFJSAnnotate'; |
3 | 3 | import { firePointerEvent } from '../fireEvent'; |
4 | 4 | import mockAddAnnotation from '../mockAddAnnotation'; |
5 | 5 | import mockGetAnnotations from '../mockGetAnnotations'; |
6 | 6 | import mockSVGContainer from '../mockSVGContainer'; |
7 | | -import { setPen, enablePen, disablePen } from '../../src/UI/pen'; |
| 7 | +import { setPen, getPen, enablePen, disablePen } from '../../src/UI/pen'; |
8 | 8 |
|
9 | 9 | let svg; |
10 | 10 | let addAnnotationSpy; |
11 | 11 | let __addAnnotation = PDFJSAnnotate.__storeAdapter.addAnnotation; |
12 | 12 | let __getAnnotations = PDFJSAnnotate.__storeAdapter.getAnnotations; |
13 | 13 |
|
14 | | -function simulateCreateDrawingAnnotation(penSize, penColor) { |
15 | | - setPen(penSize, penColor); |
| 14 | +function simulateCreateDrawingAnnotation() { |
| 15 | + setPen(); |
16 | 16 |
|
17 | 17 | firePointerEvent(svg, 'pointerdown', { |
18 | 18 | clientX: 10, |
@@ -90,4 +90,19 @@ describe('UI::pen', function() { |
90 | 90 | done(); |
91 | 91 | }, 0); |
92 | 92 | }); |
| 93 | + |
| 94 | + it('allow floating point pen size', () => { |
| 95 | + setPen(0.1); |
| 96 | + deepStrictEqual(getPen(), {size: 0.1, color: '000000'}); |
| 97 | + }); |
| 98 | + |
| 99 | + it('round floating point pen size to 2 decimal points', () => { |
| 100 | + setPen(0.123456); |
| 101 | + deepStrictEqual(getPen(), {size: 0.12, color: '000000'}); |
| 102 | + }); |
| 103 | + |
| 104 | + it('parseFloat run on penSize', () => { |
| 105 | + setPen('0.12'); |
| 106 | + deepStrictEqual(getPen(), {size: 0.12, color: '000000'}); |
| 107 | + }); |
93 | 108 | }); |
0 commit comments