1
- import { equal , deepStrictEqual } from 'assert' ;
1
+ import { deepStrictEqual , strictEqual } from 'assert' ;
2
2
import PDFJSAnnotate from '../../src/PDFJSAnnotate' ;
3
3
import { firePointerEvent } from '../fireEvent' ;
4
4
import mockAddAnnotation from '../mockAddAnnotation' ;
@@ -69,7 +69,7 @@ describe('UI::pen', function() {
69
69
disablePen ( ) ;
70
70
simulateCreateDrawingAnnotation ( ) ;
71
71
setTimeout ( function ( ) {
72
- equal ( addAnnotationSpy . called , false ) ;
72
+ strictEqual ( addAnnotationSpy . called , false ) ;
73
73
done ( ) ;
74
74
} , 0 ) ;
75
75
} ) ;
@@ -79,14 +79,49 @@ describe('UI::pen', function() {
79
79
enablePen ( ) ;
80
80
simulateCreateDrawingAnnotation ( ) ;
81
81
setTimeout ( function ( ) {
82
- equal ( addAnnotationSpy . called , true ) ;
83
- let args = addAnnotationSpy . getCall ( 0 ) . args ;
84
- equal ( args [ 0 ] , 'test-document-id' ) ;
85
- equal ( args [ 1 ] , '1' ) ;
86
- equal ( args [ 2 ] . type , 'drawing' ) ;
87
- equal ( args [ 2 ] . width , 1 ) ;
88
- equal ( args [ 2 ] . color , '000000' ) ;
89
- equal ( args [ 2 ] . lines . length , 2 ) ;
82
+ strictEqual ( addAnnotationSpy . called , true ) ;
83
+ const args = addAnnotationSpy . getCall ( 0 ) . args ;
84
+ strictEqual ( args [ 0 ] , 'test-document-id' ) ;
85
+ strictEqual ( args [ 1 ] , 1 ) ;
86
+ strictEqual ( args [ 2 ] . type , 'drawing' ) ;
87
+ strictEqual ( args [ 2 ] . width , 1 ) ;
88
+ strictEqual ( args [ 2 ] . color , '000000' ) ;
89
+ strictEqual ( args [ 2 ] . lines . length , 2 ) ;
90
+ done ( ) ;
91
+ } , 0 ) ;
92
+ } ) ;
93
+
94
+ it ( 'should not create annotation if started outside annotation layer' , ( done ) => {
95
+ disablePen ( ) ;
96
+ enablePen ( ) ;
97
+ setPen ( ) ;
98
+
99
+ firePointerEvent ( svg , 'pointerdown' , {
100
+ clientX : 2000 ,
101
+ clientY : 10 ,
102
+ pointerType : 'mouse'
103
+ } ) ;
104
+
105
+ firePointerEvent ( svg , 'pointermove' , {
106
+ clientX : 15 ,
107
+ clientY : 15 ,
108
+ pointerType : 'mouse'
109
+ } ) ;
110
+
111
+ firePointerEvent ( svg , 'pointermove' , {
112
+ clientX : 30 ,
113
+ clientY : 30 ,
114
+ pointerType : 'mouse'
115
+ } ) ;
116
+
117
+ firePointerEvent ( svg , 'pointerup' , {
118
+ clientX : 30 ,
119
+ clientY : 30 ,
120
+ pointerType : 'mouse'
121
+ } ) ;
122
+
123
+ setTimeout ( ( ) => {
124
+ strictEqual ( addAnnotationSpy . called , false ) ;
90
125
done ( ) ;
91
126
} , 0 ) ;
92
127
} ) ;
0 commit comments