@@ -473,6 +473,103 @@ describe('IntersectionObserver', () => {
473473 new IntersectionObserver ( ( ) => { } , { rnRootThreshold : [ ] } ) . thresholds ,
474474 ) . toEqual ( [ 0 ] ) ;
475475 } ) ;
476+
477+ describe ( 'unsupported options' , ( ) => {
478+ it ( 'should throw if `delay` option is specified' , ( ) => {
479+ expect ( ( ) => {
480+ // $FlowExpectedError[prop-missing] delay is not defined in Flow.
481+ return new IntersectionObserver ( ( ) => { } , { delay : 100 } ) ;
482+ } ) . toThrow (
483+ "Failed to construct 'IntersectionObserver': The 'delay' option is not supported." ,
484+ ) ;
485+ } ) ;
486+
487+ it ( 'should throw if `scrollMargin` option is specified' , ( ) => {
488+ expect ( ( ) => {
489+ // $FlowExpectedError[prop-missing] scrollMargin is not defined in Flow.
490+ return new IntersectionObserver ( ( ) => { } , { scrollMargin : '10px' } ) ;
491+ } ) . toThrow (
492+ "Failed to construct 'IntersectionObserver': The 'scrollMargin' option is not supported." ,
493+ ) ;
494+ } ) ;
495+
496+ it ( 'should throw if `trackVisibility` option is specified' , ( ) => {
497+ expect ( ( ) => {
498+ // $FlowExpectedError[prop-missing] trackVisibility is not defined in Flow.
499+ return new IntersectionObserver ( ( ) => { } , { trackVisibility : true } ) ;
500+ } ) . toThrow (
501+ "Failed to construct 'IntersectionObserver': The 'trackVisibility' option is not supported." ,
502+ ) ;
503+ } ) ;
504+
505+ it ( 'should throw if `delay` option is set to undefined explicitly' , ( ) => {
506+ expect ( ( ) => {
507+ // $FlowExpectedError[prop-missing] delay is not defined in Flow.
508+ return new IntersectionObserver ( ( ) => { } , { delay : undefined } ) ;
509+ } ) . toThrow (
510+ "Failed to construct 'IntersectionObserver': The 'delay' option is not supported." ,
511+ ) ;
512+ } ) ;
513+
514+ it ( 'should throw if `scrollMargin` option is set to null explicitly' , ( ) => {
515+ expect ( ( ) => {
516+ // $FlowExpectedError[prop-missing] scrollMargin is not defined in Flow.
517+ return new IntersectionObserver ( ( ) => { } , { scrollMargin : null } ) ;
518+ } ) . toThrow (
519+ "Failed to construct 'IntersectionObserver': The 'scrollMargin' option is not supported." ,
520+ ) ;
521+ } ) ;
522+
523+ it ( 'should not throw when unsupported options are not specified' , ( ) => {
524+ expect ( ( ) => {
525+ return new IntersectionObserver ( ( ) => { } , {
526+ threshold : 0.5 ,
527+ rootMargin : '10px' ,
528+ } ) ;
529+ } ) . not . toThrow ( ) ;
530+ } ) ;
531+
532+ it ( 'should throw if multiple unsupported options are specified' , ( ) => {
533+ expect ( ( ) => {
534+ // $FlowExpectedError[prop-missing] delay and trackVisibility are not defined in Flow.
535+ return new IntersectionObserver ( ( ) => { } , {
536+ delay : 100 ,
537+ trackVisibility : true ,
538+ } ) ;
539+ } ) . toThrow (
540+ "Failed to construct 'IntersectionObserver': The 'delay' option is not supported." ,
541+ ) ;
542+ } ) ;
543+ } ) ;
544+
545+ describe ( 'unsupported property getters' , ( ) => {
546+ it ( 'should throw when accessing delay getter' , ( ) => {
547+ observer = new IntersectionObserver ( ( ) => { } ) ;
548+ expect ( ( ) => {
549+ return observer . delay ;
550+ } ) . toThrow (
551+ "Failed to read the 'delay' property from 'IntersectionObserver': This property is not supported." ,
552+ ) ;
553+ } ) ;
554+
555+ it ( 'should throw when accessing scrollMargin getter' , ( ) => {
556+ observer = new IntersectionObserver ( ( ) => { } ) ;
557+ expect ( ( ) => {
558+ return observer . scrollMargin ;
559+ } ) . toThrow (
560+ "Failed to read the 'scrollMargin' property from 'IntersectionObserver': This property is not supported." ,
561+ ) ;
562+ } ) ;
563+
564+ it ( 'should throw when accessing trackVisibility getter' , ( ) => {
565+ observer = new IntersectionObserver ( ( ) => { } ) ;
566+ expect ( ( ) => {
567+ return observer . trackVisibility ;
568+ } ) . toThrow (
569+ "Failed to read the 'trackVisibility' property from 'IntersectionObserver': This property is not supported." ,
570+ ) ;
571+ } ) ;
572+ } ) ;
476573 } ) ;
477574
478575 describe ( 'observe(target)' , ( ) => {
0 commit comments