@@ -247,5 +247,136 @@ describe('SectionBackdrop', () => {
247247
248248 expect ( listener ) . toHaveBeenCalled ( ) ;
249249 } ) ;
250+
251+ } ) ;
252+
253+ describe ( 'change:ignoreMissingMotif event' , ( ) => {
254+ it ( 'is triggered when ignoreMissingMotif changes on backdrop image file' , ( ) => {
255+ const entry = createEntry ( {
256+ imageFiles : [ { id : 100 , perma_id : 10 } ] ,
257+ sections : [ { id : 1 , configuration : { backdropImage : 10 } } ]
258+ } ) ;
259+ const backdrop = entry . sections . get ( 1 ) . configuration . getBackdrop ( ) ;
260+ const file = entry . getFileCollection ( 'image_files' ) . get ( 100 ) ;
261+ const listener = jest . fn ( ) ;
262+
263+ backdrop . on ( 'change:ignoreMissingMotif' , listener ) ;
264+ file . configuration . set ( 'ignoreMissingMotif' , true ) ;
265+
266+ expect ( listener ) . toHaveBeenCalled ( ) ;
267+ } ) ;
268+
269+ it ( 'is triggered when ignoreMissingMotif changes on backdrop image mobile file' , ( ) => {
270+ const entry = createEntry ( {
271+ imageFiles : [ { id : 100 , perma_id : 10 } ] ,
272+ sections : [ { id : 1 , configuration : { backdropImageMobile : 10 } } ]
273+ } ) ;
274+ const backdrop = entry . sections . get ( 1 ) . configuration . getBackdrop ( ) ;
275+ const file = entry . getFileCollection ( 'image_files' ) . get ( 100 ) ;
276+ const listener = jest . fn ( ) ;
277+
278+ backdrop . on ( 'change:ignoreMissingMotif' , listener ) ;
279+ file . configuration . set ( 'ignoreMissingMotif' , true ) ;
280+
281+ expect ( listener ) . toHaveBeenCalled ( ) ;
282+ } ) ;
283+
284+ it ( 'is triggered when ignoreMissingMotif changes on new backdrop image file' , ( ) => {
285+ const entry = createEntry ( {
286+ imageFiles : [ { id : 100 , perma_id : 10 } , { id : 101 , perma_id : 11 } ] ,
287+ sections : [ { id : 1 , configuration : { backdropImage : 10 } } ]
288+ } ) ;
289+ const backdrop = entry . sections . get ( 1 ) . configuration . getBackdrop ( ) ;
290+ const newFile = entry . getFileCollection ( 'image_files' ) . get ( 101 ) ;
291+ const listener = jest . fn ( ) ;
292+
293+ entry . sections . get ( 1 ) . configuration . set ( 'backdropImage' , 11 ) ;
294+ backdrop . on ( 'change:ignoreMissingMotif' , listener ) ;
295+ newFile . configuration . set ( 'ignoreMissingMotif' , true ) ;
296+
297+ expect ( listener ) . toHaveBeenCalled ( ) ;
298+ } ) ;
299+
300+ it ( 'is not triggered when ignoreMissingMotif changes on old backdrop image file' , ( ) => {
301+ const entry = createEntry ( {
302+ imageFiles : [ { id : 100 , perma_id : 10 } , { id : 101 , perma_id : 11 } ] ,
303+ sections : [ { id : 1 , configuration : { backdropImage : 10 } } ]
304+ } ) ;
305+ const backdrop = entry . sections . get ( 1 ) . configuration . getBackdrop ( ) ;
306+ const oldFile = entry . getFileCollection ( 'image_files' ) . get ( 100 ) ;
307+ const listener = jest . fn ( ) ;
308+
309+ entry . sections . get ( 1 ) . configuration . set ( 'backdropImage' , 11 ) ;
310+ backdrop . on ( 'change:ignoreMissingMotif' , listener ) ;
311+ oldFile . configuration . set ( 'ignoreMissingMotif' , true ) ;
312+
313+ expect ( listener ) . not . toHaveBeenCalled ( ) ;
314+ } ) ;
315+
316+ it ( 'is triggered when ignoreMissingMotif changes on new backdrop image mobile file' , ( ) => {
317+ const entry = createEntry ( {
318+ imageFiles : [ { id : 100 , perma_id : 10 } , { id : 101 , perma_id : 11 } ] ,
319+ sections : [ { id : 1 , configuration : { backdropImageMobile : 10 } } ]
320+ } ) ;
321+ const backdrop = entry . sections . get ( 1 ) . configuration . getBackdrop ( ) ;
322+ const newFile = entry . getFileCollection ( 'image_files' ) . get ( 101 ) ;
323+ const listener = jest . fn ( ) ;
324+
325+ entry . sections . get ( 1 ) . configuration . set ( 'backdropImageMobile' , 11 ) ;
326+ backdrop . on ( 'change:ignoreMissingMotif' , listener ) ;
327+ newFile . configuration . set ( 'ignoreMissingMotif' , true ) ;
328+
329+ expect ( listener ) . toHaveBeenCalled ( ) ;
330+ } ) ;
331+
332+ it ( 'is not triggered when ignoreMissingMotif changes on old backdrop image mobile file' , ( ) => {
333+ const entry = createEntry ( {
334+ imageFiles : [ { id : 100 , perma_id : 10 } , { id : 101 , perma_id : 11 } ] ,
335+ sections : [ { id : 1 , configuration : { backdropImageMobile : 10 } } ]
336+ } ) ;
337+ const backdrop = entry . sections . get ( 1 ) . configuration . getBackdrop ( ) ;
338+ const oldFile = entry . getFileCollection ( 'image_files' ) . get ( 100 ) ;
339+ const listener = jest . fn ( ) ;
340+
341+ entry . sections . get ( 1 ) . configuration . set ( 'backdropImageMobile' , 11 ) ;
342+ backdrop . on ( 'change:ignoreMissingMotif' , listener ) ;
343+ oldFile . configuration . set ( 'ignoreMissingMotif' , true ) ;
344+
345+ expect ( listener ) . not . toHaveBeenCalled ( ) ;
346+ } ) ;
347+
348+ it ( 'is triggered when ignoreMissingMotif changes on video file after switching to video backdrop' , ( ) => {
349+ const entry = createEntry ( {
350+ imageFiles : [ { id : 100 , perma_id : 10 } ] ,
351+ videoFiles : [ { id : 200 , perma_id : 20 } ] ,
352+ sections : [ { id : 1 , configuration : { backdropImage : 10 , backdropVideo : 20 } } ]
353+ } ) ;
354+ const backdrop = entry . sections . get ( 1 ) . configuration . getBackdrop ( ) ;
355+ const videoFile = entry . getFileCollection ( 'video_files' ) . get ( 200 ) ;
356+ const listener = jest . fn ( ) ;
357+
358+ entry . sections . get ( 1 ) . configuration . set ( 'backdropType' , 'video' ) ;
359+ backdrop . on ( 'change:ignoreMissingMotif' , listener ) ;
360+ videoFile . configuration . set ( 'ignoreMissingMotif' , true ) ;
361+
362+ expect ( listener ) . toHaveBeenCalled ( ) ;
363+ } ) ;
364+
365+ it ( 'is not triggered when ignoreMissingMotif changes on image file after switching to video backdrop' , ( ) => {
366+ const entry = createEntry ( {
367+ imageFiles : [ { id : 100 , perma_id : 10 } ] ,
368+ videoFiles : [ { id : 200 , perma_id : 20 } ] ,
369+ sections : [ { id : 1 , configuration : { backdropImage : 10 , backdropVideo : 20 } } ]
370+ } ) ;
371+ const backdrop = entry . sections . get ( 1 ) . configuration . getBackdrop ( ) ;
372+ const imageFile = entry . getFileCollection ( 'image_files' ) . get ( 100 ) ;
373+ const listener = jest . fn ( ) ;
374+
375+ entry . sections . get ( 1 ) . configuration . set ( 'backdropType' , 'video' ) ;
376+ backdrop . on ( 'change:ignoreMissingMotif' , listener ) ;
377+ imageFile . configuration . set ( 'ignoreMissingMotif' , true ) ;
378+
379+ expect ( listener ) . not . toHaveBeenCalled ( ) ;
380+ } ) ;
250381 } ) ;
251382} ) ;
0 commit comments