@@ -118,15 +118,28 @@ describe('lib/viewers/box3d/video360/Video360Viewer', () => {
118118 expect ( videoAsset . destroy ) . toBeCalled ( ) ;
119119 } ) ;
120120
121- test ( 'should invoke .destroyControls() if it exists' , ( ) => {
121+ test ( 'should invoke .destroyControls() if video360Controls exists' , ( ) => {
122122 const destroyStub = jest . spyOn ( viewer , 'destroyControls' ) . mockImplementation ( ) ;
123123
124- viewer . controls = { } ;
124+ viewer . video360Controls = { } ;
125125 viewer . destroy ( ) ;
126126
127127 expect ( destroyStub ) . toBeCalled ( ) ;
128128 } ) ;
129129
130+ test ( 'should not invoke .destroyControls() when only DashViewer React controls exist' , ( ) => {
131+ const destroyStub = jest . spyOn ( viewer , 'destroyControls' ) . mockImplementation ( ) ;
132+
133+ viewer . controls = {
134+ destroy : jest . fn ( ) ,
135+ render : jest . fn ( ) ,
136+ } ;
137+ viewer . destroy ( ) ;
138+
139+ expect ( destroyStub ) . not . toBeCalled ( ) ;
140+ expect ( viewer . controls . destroy ) . toBeCalled ( ) ;
141+ } ) ;
142+
130143 describe ( 'if renderer exists' , ( ) => {
131144 let rendererMock ;
132145 let b3dMock ;
@@ -282,12 +295,14 @@ describe('lib/viewers/box3d/video360/Video360Viewer', () => {
282295 } ) ;
283296
284297 afterEach ( ( ) => {
298+ viewer . video360Controls = null ;
285299 viewer . controls = null ;
286300 } ) ;
287301
288302 test ( 'should create and store an instance of Video360Controls' , ( ) => {
289303 viewer . createControls ( ) ;
290- expect ( viewer . controls ) . toBeInstanceOf ( Video360Controls ) ;
304+ expect ( viewer . video360Controls ) . toBeInstanceOf ( Video360Controls ) ;
305+ expect ( viewer . controls ) . toBe ( viewer . video360Controls ) ;
291306 } ) ;
292307
293308 test ( 'should attach event handler for vr toggle by invoking .controls.on() with EVENT_TOGGLE_VR and .handleToggleVr()' , ( ) => {
@@ -319,7 +334,7 @@ describe('lib/viewers/box3d/video360/Video360Viewer', () => {
319334 removeListener : jest . fn ( ) ,
320335 destroy : jest . fn ( ) ,
321336 } ;
322- viewer . controls = controls ;
337+ viewer . video360Controls = controls ;
323338 viewer . destroyControls ( ) ;
324339 canvas = {
325340 removeEventListener : jest . fn ( ) ,
@@ -336,14 +351,15 @@ describe('lib/viewers/box3d/video360/Video360Viewer', () => {
336351 } ) ;
337352
338353 afterEach ( ( ) => {
354+ viewer . video360Controls = null ;
339355 viewer . controls = null ;
340356 } ) ;
341357
342- test ( 'should remove event handler for EVENT_TOGGLE_VR by invoking .controls .removeListener() with EVENT_TOGGLE_VR and .handleToggleVr()' , ( ) => {
358+ test ( 'should remove event handler for EVENT_TOGGLE_VR by invoking .video360Controls .removeListener() with EVENT_TOGGLE_VR and .handleToggleVr()' , ( ) => {
343359 expect ( controls . removeListener ) . toBeCalledWith ( EVENT_TOGGLE_VR , viewer . handleToggleVr ) ;
344360 } ) ;
345361
346- test ( 'should invoke .controls .destroy()' , ( ) => {
362+ test ( 'should invoke .video360Controls .destroy()' , ( ) => {
347363 expect ( controls . destroy ) . toBeCalled ( ) ;
348364 } ) ;
349365
@@ -552,14 +568,14 @@ describe('lib/viewers/box3d/video360/Video360Viewer', () => {
552568 } ) ;
553569
554570 describe ( 'handleShowVrButton()' , ( ) => {
555- test ( 'should invoke .controls .showVrButton()' , ( ) => {
556- viewer . controls = {
571+ test ( 'should invoke .video360Controls .showVrButton()' , ( ) => {
572+ viewer . video360Controls = {
557573 showVrButton : jest . fn ( ) ,
558574 } ;
559575 viewer . handleShowVrButton ( ) ;
560- expect ( viewer . controls . showVrButton ) . toBeCalled ( ) ;
576+ expect ( viewer . video360Controls . showVrButton ) . toBeCalled ( ) ;
561577
562- viewer . controls = null ;
578+ viewer . video360Controls = null ;
563579 } ) ;
564580 } ) ;
565581
0 commit comments