@@ -58,7 +58,7 @@ if (wysihtml5.browser.supported()) {
58
58
59
59
// EVENTS TESTS
60
60
asyncTest ( "Check events" , function ( ) {
61
- expect ( 8 ) ;
61
+ expect ( 17 ) ;
62
62
63
63
var that = this ;
64
64
var editor = new wysihtml5 . Editor ( this . editableArea ) ;
@@ -70,28 +70,32 @@ if (wysihtml5.browser.supported()) {
70
70
editor . on ( "load" , function ( ) {
71
71
var composerElement = that . editableArea ;
72
72
73
- editor . on ( "focus" , function ( ) {
73
+ editor . on ( "focus" , function ( event ) {
74
74
ok ( true , "'focus' event correctly fired" ) ;
75
+ ok ( event , "event is defined" ) ;
76
+ ok ( event instanceof Event , "event is instance of 'Event'" ) ;
77
+ ok ( event && event . type === 'focus' , "event is of type 'focus'" ) ;
75
78
} ) ;
76
79
77
- editor . on ( "blur" , function ( ) {
80
+ editor . on ( "blur" , function ( event ) {
78
81
ok ( true , "'blur' event correctly fired" ) ;
82
+ ok ( event , "event is defined" ) ;
83
+ ok ( event instanceof Event , "event is instance of 'Event'" ) ;
84
+ ok ( event && event . type === 'blur' , "event is of type 'blur'" ) ;
79
85
} ) ;
80
86
81
- editor . on ( "change" , function ( ) {
87
+ editor . on ( "change" , function ( event ) {
82
88
ok ( true , "'change' event correctly fired" ) ;
89
+ ok ( event , "event is defined" ) ;
90
+ ok ( event instanceof Event , "event is instance of 'Event'" ) ;
91
+ ok ( event && event . type === 'change' , "event is of type 'change'" ) ;
83
92
} ) ;
84
93
85
- editor . on ( "paste" , function ( ) {
86
- ok ( true , "'paste' event correctly fired" ) ;
87
- } ) ;
88
-
89
- editor . on ( "drop" , function ( ) {
90
- ok ( true , "'drop' event correctly fired" ) ;
91
- } ) ;
92
94
93
- editor . on ( "custom_event" , function ( ) {
95
+ editor . on ( "custom_event" , function ( event ) {
94
96
ok ( true , "'custom_event' correctly fired" ) ;
97
+ ok ( event , "event is defined" ) ;
98
+ ok ( event && event . type === 'custom_event' , "event is of type 'custom_event'" ) ;
95
99
} ) ;
96
100
97
101
happen . once ( composerElement , { type : "focus" } ) ;
@@ -104,15 +108,83 @@ if (wysihtml5.browser.supported()) {
104
108
105
109
equal ( wysihtml5 . dom . getStyle ( "margin-top" ) . from ( composerElement ) , "5px" , ":focus styles are correctly unset" ) ;
106
110
111
+
112
+ editor . fire ( "custom_event" , { type : 'custom_event' } ) ;
113
+
114
+ setTimeout ( function ( ) { start ( ) ; } , 100 ) ;
115
+ } ) ;
116
+ } ) ;
117
+
118
+ asyncTest ( "Check events paste" , function ( ) {
119
+ expect ( 12 ) ;
120
+
121
+ var that = this ;
122
+ var editor = new wysihtml5 . Editor ( this . editableArea ) ;
123
+
124
+ editor . on ( "load" , function ( ) {
125
+ var composerElement = that . editableArea ;
126
+
127
+ editor . on ( "paste" , function ( event ) {
128
+ ok ( event , "event is defined" ) ;
129
+ ok ( event instanceof Event , "event is instance of 'Event'" ) ;
130
+ ok ( event && event . type === 'paste' , "event is of type 'paste'" ) ;
131
+ } ) ;
132
+
133
+ //Assure that the event on the dom element works as expected
134
+ that . editableArea . addEventListener ( 'paste' , function ( event ) {
135
+ ok ( event , "event is defined" ) ;
136
+ ok ( event instanceof Event , "event is instance of 'Event'" ) ;
137
+ ok ( event && event . type === 'paste' , "event is of type 'paste'" ) ;
138
+ } ) ;
139
+
107
140
happen . once ( composerElement , { type : "paste" } ) ;
108
- happen . once ( composerElement , { type : "drop" } ) ;
141
+ //Just to show that not happen.js is the source of error
142
+ var event = new Event ( 'paste' ) ;
143
+ that . editableArea . dispatchEvent ( event ) ;
144
+ //QUnit.triggerEvent(composerElement, 'paste');
109
145
110
- editor . fire ( "custom_event" ) ;
146
+ setTimeout ( function ( ) { start ( ) ; } , 100 ) ;
147
+ } ) ;
148
+ } ) ;
149
+
150
+ asyncTest ( "Check events drop" , function ( ) {
151
+ expect ( 12 ) ;
152
+
153
+ var that = this ;
154
+ var editor = new wysihtml5 . Editor ( this . editableArea ) ;
155
+
156
+ editor . on ( "load" , function ( ) {
157
+ var composerElement = that . editableArea ;
111
158
159
+ //if changing from drop to paste it works
160
+ editor . on ( 'drop' , function ( event ) {
161
+ ok ( event , "event is defined" ) ;
162
+ ok ( event instanceof Event , "event is instance of 'Event'" ) ;
163
+ ok ( event && event . type === 'drop' , "event is of type 'drop'" ) ;
164
+ } ) ;
165
+
166
+ editor . on ( 'paste' , function ( event ) {
167
+ ok ( false , "No 'paste' event was fired." ) ;
168
+ } ) ;
169
+
170
+ //Assure that the event on the dom element works as expected
171
+ that . editableArea . addEventListener ( 'drop' , function ( event ) {
172
+ ok ( event , "event is defined" ) ;
173
+ ok ( event instanceof Event , "event is instance of 'Event'" ) ;
174
+ ok ( event && event . type === 'drop' , "event is of type 'drop'" ) ;
175
+ } ) ;
176
+
177
+ happen . once ( composerElement , { type : "drop" } ) ;
178
+ //Just to show that not happen.js is the source of error
179
+ var event = new Event ( 'drop' ) ;
180
+ that . editableArea . dispatchEvent ( event ) ;
181
+ //QUnit.triggerEvent(composerElement, 'drop');
182
+
112
183
setTimeout ( function ( ) { start ( ) ; } , 100 ) ;
113
184
} ) ;
114
185
} ) ;
115
186
187
+
116
188
// Placeholder tests
117
189
asyncTest ( "Check placeholder" , function ( ) {
118
190
expect ( 12 ) ;
0 commit comments