@@ -6,6 +6,7 @@ import sinon, { SinonSpy } from 'sinon';
66import { TestContext } from 'ember-test-helpers' ;
77import { Sizes } from 'ember-element-query/-private/modifier' ;
88import pause from '../helpers/pause' ;
9+ import { setupWindowMock } from 'ember-window-mock' ;
910
1011interface TestContextCustom extends TestContext {
1112 callback ?: SinonSpy ;
@@ -17,11 +18,35 @@ interface TestContextCustom extends TestContext {
1718}
1819
1920module ( 'Integration | Modifier | element-query' , function ( hooks ) {
21+ let m ;
22+
2023 setupRenderingTest ( hooks ) ;
24+ setupWindowMock ( hooks ) ;
25+
26+ // eslint-disable-next-line @typescript-eslint/no-misused-promises
27+ test ( 'do not crash on missing resize observer' , async function ( this : TestContextCustom , assert ) {
28+ // @ts -ignore https://github.com/Microsoft/TypeScript/issues/28502#issuecomment-609607344
29+ const resizeObserver = window . ResizeObserver as unknown ;
30+ // @ts -ignore https://github.com/Microsoft/TypeScript/issues/28502#issuecomment-609607344
31+ window . ResizeObserver = undefined ;
32+
33+ await render ( hbs `
34+ {{! template-lint-disable no-inline-styles }}
35+ <div
36+ {{element-query}}
37+ >
38+ </div>
39+ ` ) ;
40+
41+ m = 'Element is rendered' ;
42+ assert . ok ( true , m ) ;
43+
44+ // @ts -ignore https://github.com/Microsoft/TypeScript/issues/28502#issuecomment-609607344
45+ window . ResizeObserver = resizeObserver ;
46+ } ) ;
2147
2248 // eslint-disable-next-line @typescript-eslint/no-misused-promises
2349 test ( 'calls the onResize callback' , async function ( this : TestContextCustom , assert ) {
24- let m ;
2550 let callCount = 0 ;
2651 this . callback = sinon . spy ( ( ) => callCount ++ ) ;
2752
@@ -79,7 +104,6 @@ module('Integration | Modifier | element-query', function (hooks) {
79104
80105 // eslint-disable-next-line @typescript-eslint/no-misused-promises
81106 test ( 'does not call the onResize when isDisabled is initially set' , async function ( this : TestContextCustom , assert ) {
82- let m ;
83107 let callCount = 0 ;
84108 this . callback = sinon . spy ( ( ) => callCount ++ ) ;
85109
@@ -110,7 +134,6 @@ module('Integration | Modifier | element-query', function (hooks) {
110134
111135 // eslint-disable-next-line @typescript-eslint/no-misused-promises
112136 test ( 'stops calling the onResize callback after updating isDisabled after rendering' , async function ( this : TestContextCustom , assert ) {
113- let m ;
114137 let callCount = 0 ;
115138 this . callback = sinon . spy ( ( ) => callCount ++ ) ;
116139 this . set ( 'isDisabled' , false ) ;
@@ -163,7 +186,6 @@ module('Integration | Modifier | element-query', function (hooks) {
163186
164187 // eslint-disable-next-line @typescript-eslint/no-misused-promises
165188 test ( 'attributes smoke test + update on arguments change test' , async function ( this : TestContextCustom , assert ) {
166- let m ;
167189 this . set ( 'sizes' , { small : 0 , large : 300 } ) ;
168190
169191 await render ( hbs `
@@ -199,8 +221,6 @@ module('Integration | Modifier | element-query', function (hooks) {
199221
200222 // eslint-disable-next-line @typescript-eslint/no-misused-promises
201223 test ( 'usning multiple modifiers on the same element with custom sizes' , async function ( this : TestContextCustom , assert ) {
202- let m ;
203-
204224 await render ( hbs `
205225 {{! template-lint-disable no-inline-styles }}
206226 <div
@@ -233,8 +253,6 @@ module('Integration | Modifier | element-query', function (hooks) {
233253
234254 // eslint-disable-next-line @typescript-eslint/no-misused-promises
235255 test ( 'usning multiple modifiers on the same element with custom prefixes' , async function ( this : TestContextCustom , assert ) {
236- let m ;
237-
238256 await render ( hbs `
239257 {{! template-lint-disable no-inline-styles }}
240258 <div
@@ -314,7 +332,6 @@ module('Integration | Modifier | element-query', function (hooks) {
314332 cases . forEach ( ( { actualWidth, expectedAttributes, prefix } ) => {
315333 // eslint-disable-next-line @typescript-eslint/no-misused-promises, @typescript-eslint/restrict-template-expressions
316334 test ( `width ${ actualWidth } , prefix ${ prefix } ` , async function ( this : TestContextCustom , assert ) {
317- let m ;
318335 this . actualWidth = actualWidth ;
319336 this . prefix = prefix ;
320337
@@ -396,7 +413,6 @@ module('Integration | Modifier | element-query', function (hooks) {
396413 cases . forEach ( ( { actualWidth, expectedAttributes, prefix } ) => {
397414 // eslint-disable-next-line @typescript-eslint/no-misused-promises, @typescript-eslint/restrict-template-expressions
398415 test ( `width ${ actualWidth } , prefix: ${ prefix } ` , async function ( this : TestContextCustom , assert ) {
399- let m ;
400416 this . actualWidth = actualWidth ;
401417 this . sizes = sizes ;
402418 this . prefix = prefix ;
@@ -492,7 +508,6 @@ module('Integration | Modifier | element-query', function (hooks) {
492508 cases . forEach ( ( { actualHeight, expectedAttributes, prefix } ) => {
493509 // eslint-disable-next-line @typescript-eslint/no-misused-promises, @typescript-eslint/restrict-template-expressions
494510 test ( `height ${ actualHeight } , prefix ${ prefix } ` , async function ( this : TestContextCustom , assert ) {
495- let m ;
496511 this . actualHeight = actualHeight ;
497512 this . prefix = prefix ;
498513
@@ -574,7 +589,6 @@ module('Integration | Modifier | element-query', function (hooks) {
574589 cases . forEach ( ( { actualHeight, expectedAttributes, prefix } ) => {
575590 // eslint-disable-next-line @typescript-eslint/no-misused-promises, @typescript-eslint/restrict-template-expressions
576591 test ( `height ${ actualHeight } , prefix: ${ prefix } ` , async function ( this : TestContextCustom , assert ) {
577- let m ;
578592 this . actualHeight = actualHeight ;
579593 this . sizes = sizes ;
580594 this . prefix = prefix ;
0 commit comments