15
15
import componentsModule from 'common/components/components_module' ;
16
16
17
17
describe ( 'Middle ellipsis directive' , ( ) => {
18
- /** @type {! angular.Scope } */
18
+ /** @type {angular.Scope } */
19
19
let scope ;
20
20
/** @type {function(!angular.Scope):!angular.JQLite } */
21
21
let compileFn ;
22
- /** @type {! angular.$window } */
22
+ /** @type {angular.$window } */
23
23
let window ;
24
+ /** @type {Event } **/
25
+ let resizeEvent ;
24
26
25
27
beforeEach ( ( ) => {
26
28
angular . mock . module ( componentsModule . name ) ;
27
29
28
30
angular . mock . inject ( ( $rootScope , $compile , $window ) => {
31
+ resizeEvent = $window . document . createEvent ( 'UIEvent' ) ;
32
+ resizeEvent . initEvent ( 'resize' , true , false ) ;
29
33
scope = $rootScope . $new ( ) ;
30
34
window = $window ;
31
35
compileFn = $compile ( `<div><kd-middle-ellipsis display-string="{{displayString}}"
@@ -42,23 +46,23 @@ describe('Middle ellipsis directive', () => {
42
46
43
47
// when
44
48
element [ 0 ] . style . width = '500px' ;
45
- window . dispatchEvent ( new Event ( 'resize' ) ) ;
49
+ window . dispatchEvent ( resizeEvent ) ;
46
50
scope . $digest ( ) ;
47
51
48
52
// then
49
53
expect ( element . text ( ) . trim ( ) . length ) . toEqual ( stringLength ) ;
50
54
51
55
// when
52
56
element [ 0 ] . style . width = '1px' ;
53
- window . dispatchEvent ( new Event ( 'resize' ) ) ;
57
+ window . dispatchEvent ( resizeEvent ) ;
54
58
scope . $digest ( ) ;
55
59
56
60
// then
57
61
expect ( element . text ( ) . trim ( ) . length ) . toEqual ( 0 ) ;
58
62
59
63
// when
60
64
element [ 0 ] . style . width = '50px' ;
61
- window . dispatchEvent ( new Event ( 'resize' ) ) ;
65
+ window . dispatchEvent ( resizeEvent ) ;
62
66
scope . $digest ( ) ;
63
67
64
68
// then
0 commit comments