1. /**
    
  2.  * Copyright (c) Meta Platforms, Inc. and affiliates.
    
  3.  *
    
  4.  * This source code is licensed under the MIT license found in the
    
  5.  * LICENSE file in the root directory of this source tree.
    
  6.  *
    
  7.  * @jest-environment node
    
  8.  */
    
  9. 'use strict';
    
  10. 
    
  11. class MockMessageChannel {
    
  12.   constructor() {
    
  13.     this.port1 = jest.fn();
    
  14.     this.port2 = jest.fn();
    
  15.   }
    
  16. }
    
  17. 
    
  18. describe('Scheduling UMD bundle', () => {
    
  19.   beforeEach(() => {
    
  20.     // Fool SECRET_INTERNALS object into including UMD forwarding methods.
    
  21.     global.__UMD__ = true;
    
  22. 
    
  23.     jest.resetModules();
    
  24.     jest.unmock('scheduler');
    
  25. 
    
  26.     global.MessageChannel = MockMessageChannel;
    
  27.   });
    
  28. 
    
  29.   afterEach(() => {
    
  30.     global.MessageChannel = undefined;
    
  31.   });
    
  32. 
    
  33.   function validateForwardedAPIs(api, forwardedAPIs) {
    
  34.     const apiKeys = Object.keys(api).sort();
    
  35.     forwardedAPIs.forEach(forwardedAPI => {
    
  36.       expect(Object.keys(forwardedAPI).sort()).toEqual(apiKeys);
    
  37.     });
    
  38.   }
    
  39. 
    
  40.   it('should define the same scheduling API', () => {
    
  41.     const api = require('../../index');
    
  42.     const umdAPIDev = require('../../npm/umd/scheduler.development');
    
  43.     const umdAPIProd = require('../../npm/umd/scheduler.production.min');
    
  44.     const umdAPIProfiling = require('../../npm/umd/scheduler.profiling.min');
    
  45.     const secretAPI =
    
  46.       require('react/src/forks/ReactSharedInternals.umd').default;
    
  47.     validateForwardedAPIs(api, [
    
  48.       umdAPIDev,
    
  49.       umdAPIProd,
    
  50.       umdAPIProfiling,
    
  51.       secretAPI.Scheduler,
    
  52.     ]);
    
  53.   });
    
  54. });